- 问答
模仿了一下原神祈愿抽出来金色的概率为啥这么高?哪位python大佬帮忙看一下。
- 2023-12-22 19:53:09 @
import random
def draw_card(draw_count, gold_probability):
if draw_count >= 7:
return "金"
else:
card = random.choices(["紫", "金"], [gold_probability, 1 - gold_probability])[0]
return card
def play_game():
draw_count = 0
gold_probability = 0.05
while True:
user_input = input("你想抽卡吗?输入'y'或'n': ")
if user_input == 'y':
card = draw_card(draw_count, gold_probability)
print("你抽到了一张", card)
draw_count += 1
gold_probability = 0.5 if draw_count >= 3 else gold_probability
elif user_input == 'n':
print("好的,游戏结束。")
break
else:
print("无效的输入,请重新输入。")
play_game()
0 comments
No comments so far...