当前位置: 首页>>代码示例>>Python>>正文


Python Dice.standard_rolls_for_debugging方法代码示例

本文整理汇总了Python中dice.Dice.standard_rolls_for_debugging方法的典型用法代码示例。如果您正苦于以下问题:Python Dice.standard_rolls_for_debugging方法的具体用法?Python Dice.standard_rolls_for_debugging怎么用?Python Dice.standard_rolls_for_debugging使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dice.Dice的用法示例。


在下文中一共展示了Dice.standard_rolls_for_debugging方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Dice

# 需要导入模块: from dice import Dice [as 别名]
# 或者: from dice.Dice import standard_rolls_for_debugging [as 别名]
from dice      import Dice
from stopwatch import Stopwatch
import prompt
import predicate

 
win_count     = 0                            #Win/Lose/Dice Statistics
lose_count    = 0

dice          = Dice([6,6])
game_timer    = Stopwatch()

games_to_play = prompt.for_int('Enter # of games to play', is_legal=predicate.is_positive, error_message='an int, but not > 0')

game_timer.start()
dice.standard_rolls_for_debugging()
for game in irange(1, games_to_play):        #Each iteration plays one game
    first_roll = dice.roll().pip_sum()       #Roll the dice and record their pip sum

    #Based on firstRoll, decide how to continue:
    #  immediate win/loss or trying to make point
    if first_roll == 7 or first_roll == 11:
        win_count += 1                       #Win on the first roll with 7 or 11

    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)
开发者ID:shwilliams,项目名称:ICS33,代码行数:33,代码来源:craps.py


注:本文中的dice.Dice.standard_rolls_for_debugging方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。