所以我试图简单地掷骰子,看看你是否赢了(借口如果有些东西缩进错误,副本n粘贴有点不对,如果你愿意那么http://pastebin.com/thg7ruT1这里是贴纸)。我不确定会发生什么,但是当我运行YouMightWin功能时,无论StanDice的结果如何,它总是说“你赢了!”#34;即使它低于6,我也不确定它应该对我有用,至少从我玩过的其他事情来看。如果你能帮助谢谢。
def StanDice():
num_dice = 2
num_sides = 6
rand_num = random.randint(1, num_dice*num_sides)
print rand_num
def YouMightWin():
Ans = raw_input("Roll the dice? [Y/N]: ")
Ans = Ans.lower()
dice_roll = StanDice()
if Ans in ("y" or "yes"):
print dice_roll, "This is the Dice"
if dice_roll < 6:
print "You win!"
elif dice_roll > 6:
print "You lose!"
else:
print "Something went wrong!"
elif Ans in ('n' or 'no'):
print "Are you sure you don't want to roll?"
YouMightWin()
else:
print "Something went in the main if statement"
答案 0 :(得分:1)
您print
rand_num
的值return
而不是None
,因此该函数返回{{1}},小于6。
那就是说,你的骰子太天真了 - 真的没有机会滚动2和7.检查概率表。你应该独立地滚动每个模具并将它们加在一起。