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


Python GameState.print_scores方法代码示例

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


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

示例1: play_whist

# 需要导入模块: from game_state import GameState [as 别名]
# 或者: from game_state.GameState import print_scores [as 别名]
def play_whist(record_game):
    players, partners = get_players_and_partners()
    game_state = GameState(players, partners)

    dealer_index = 0
    while not game_state.is_game_over():
        play_deal(game_state, dealer_index)
        dealer_index = (dealer_index + 1) % NUM_PLAYERS

    print 'The game is over! Final scores:'
    game_state.print_scores()
    if record_game:
        outfile = open(GAME_RECORD_FILE, 'a')
        outfile.write(game_state.get_team_scores_str())
        outfile.close()
开发者ID:kwyngarden,项目名称:CS221-Whist,代码行数:17,代码来源:whist.py

示例2: play_oracle_whist

# 需要导入模块: from game_state import GameState [as 别名]
# 或者: from game_state.GameState import print_scores [as 别名]
def play_oracle_whist(num_iters=1000, silent=True):
    # random.seed(42)
    oracles = ['Oracle1', 'Oracle2']
    opponents = ['Opponent1', 'Opponent2']
    players, partners, oracle_name = get_oracle_players_and_partners(oracles, opponents)
    oracle_wins = 0
    opponent_wins = 0
    points_for = 0
    points_against = 0
    
    for i in xrange(num_iters):
        game_state = GameState(players, partners)

        dealer_index = 0
        while not game_state.is_game_over():
            play_oracle_deal(game_state, dealer_index, oracle_name, silent=silent)
            dealer_index = (dealer_index + 1) % NUM_PLAYERS
            #raw_input()
        
        if not silent:
            print 'The game is over! Final scores:'
            game_state.print_scores()
        
        oracle_score = sum([game_state.scores[oracle] for oracle in oracles])
        opp_score = sum([game_state.scores[opp] for opp in opponents])
        if oracle_score > opp_score:
            print "Game %s: oracles win" % (i+1)
            oracle_wins += 1
        else:
            print "Game %s: opponents win" % (i+1)
            opponent_wins += 1
        points_for += oracle_score
        points_against += opp_score

    print "Oracle record: %s-%s" % (oracle_wins, opponent_wins)
    print "Points for: %s" % points_for
    print "Points against: %s" % points_against
开发者ID:kwyngarden,项目名称:CS221-Whist,代码行数:39,代码来源:whist.py


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