本文整理汇总了Python中dice.Dice.rolls方法的典型用法代码示例。如果您正苦于以下问题:Python Dice.rolls方法的具体用法?Python Dice.rolls怎么用?Python Dice.rolls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dice.Dice
的用法示例。
在下文中一共展示了Dice.rolls方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: while
# 需要导入模块: from dice import Dice [as 别名]
# 或者: from dice.Dice import rolls [as 别名]
elif first_roll == 2 or first_roll == 3 or first_roll == 12:
lose_count += 1 #Lose on the first roll with 2, 3, or 12
else: #Try to make the point as the game continues
point = first_roll #point will never store 7, 11, 2, 3, or 12
while(True): #Roll until roll point (win) or 7 (lose)
roll = dice.roll().pip_sum()
if roll == point: #If made the point first
win_count += 1 #...win and this game is over
break
elif roll == 7: #If roll a 7 first
lose_count+= 1 #...lose and this game is over
break
game_timer.stop();
##Display Statistics
print(' Raw Wins/Lose =', '{:,}'.format(win_count), '/', '{:,}'.format(lose_count))
print(' % Wins/Lose =', 100.0*win_count/(win_count+lose_count), '/', 100.0*lose_count/(win_count+lose_count))
print()
print(' Dice Thrown =', '{:,}'.format(dice.rolls()))
print(' Avg Dice/game =', dice.rolls()/games_to_play)
print()
print(' Elapsed Time =' , game_timer.read(), 'seconds')
print(' Speed =', '{:,}'.format(int(games_to_play/game_timer.read())), 'games/second')