本文整理汇总了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()
示例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