字符 symbols = ['DD','7','BBB','BB','B','C','0'] random_symbols = random.sample(symbols,3) #概率 symbols_c = [0.03,0.03,0.06,0.25,0.01,0.52] 以概率随机产生symbols里面的三个数组合 [DD DD DD]奖金800 组合[7 7 7] 对应80 组合BBB BBB BBB对应40 组合BB BB BB对应25 组合B B B对应10 组合CC C C C对应10 *代表symbols里任意一项 组合C C *对应5组合C * C对应5 组合C * C对应5 组合* C C对应5 组合C * *对应2组合*C*对应2组合* * C对应2 B BB BBB 任意顺序组合都对应2python代码
时间: 2024-03-21 19:40:56 浏览: 83
以下是添加了新的组合类型,同时修改了之前的判断逻辑的Python代码实现:
```python
import random
symbols = ['DD', '7', 'BBB', 'BB', 'B', 'C', '0']
symbols_c = [0.03, 0.03, 0.06, 0.25, 0.01, 0.52]
# 模拟随机选择三个元素
result = random.sample(symbols, 3)
# 判断组合类型并计算奖金
if result == ['DD', 'DD', 'DD']:
bonus = 800
elif result == ['7', '7', '7']:
bonus = 80
elif result == ['BBB', 'BBB', 'BBB']:
bonus = 40
elif result == ['BB', 'BB', 'BB']:
bonus = 25
elif result == ['B', 'B', 'B']:
bonus = 10
elif result == ['C', 'C', '*']:
bonus = 5
elif result == ['C', '*', 'C']:
bonus = 5
elif result == ['*', 'C', 'C']:
bonus = 5
elif result == ['C', '*', '*']:
bonus = 2
elif result == ['*', 'C', '*']:
bonus = 2
elif result == ['*', '*', 'C']:
bonus = 2
elif set(result) == {'B', 'BB', 'BBB'}:
bonus = 2
else:
bonus = 0
print("随机结果:", result)
print("奖金:", bonus)
```
这个程序中添加了新的组合类型,并修改了判断逻辑。其中,`['C', 'C', '*']`、`['C', '*', 'C']`、`['*', 'C', 'C']`、`['C', '*', '*']`、`['*', 'C', '*']`、`['*', '*', 'C']`分别对应5、5、5、2、2、2的奖金,而`set(result) == {'B', 'BB', 'BBB'}`表示B、BB、BBB三个元素出现的任意顺序都可以获得2的奖金。
阅读全文