# #字符 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 *
时间: 2023-12-24 21:05:46 浏览: 103
SF Symbols.7z
这是一个概率问题,我们可以用Python的random.choices()函数来模拟这个过程。具体实现如下:
```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.choices(symbols, weights=symbols_c, k=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 set(result) == {'C'}:
bonus = 10
else:
bonus = 0
print("随机结果:", result)
print("奖金:", bonus)
```
这个程序可以模拟随机选择三个元素,并根据不同的组合类型计算奖金。注意,这里使用了Python的set()函数来判断是否是三个相同的C,因为如果直接比较三个元素是否相等,可能会出现顺序不同的情况。
阅读全文