本文整理汇总了Python中map.Map.turn_data_for_p2方法的典型用法代码示例。如果您正苦于以下问题:Python Map.turn_data_for_p2方法的具体用法?Python Map.turn_data_for_p2怎么用?Python Map.turn_data_for_p2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map.Map
的用法示例。
在下文中一共展示了Map.turn_data_for_p2方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Map
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import turn_data_for_p2 [as 别名]
m = Map()
p1 = Player1(*m.constructor_data_for_p1())
p2 = Player2(*m.constructor_data_for_p2())
json_data = {'p1_spawn': m.p1_spawn, 'p2_spawn': m.p2_spawn,
'money_payout_rates': m.money_payout_rates, 'turns': [m.board_state_for_json()]}
for i in range(NUM_TURNS):
print 'Turn #%d' % i
# Get the players' actions
p1_actions = p1.take_turn(*m.turn_data_for_p1())
p2_actions = p2.take_turn(*m.turn_data_for_p2())
m.apply_moves(p1_actions, p2_actions)
m.resolve_combat()
m.give_payouts()
m.spawn_new_guys()
m.resolve_combat() #in case the new guys spawned into combat
json_data['turns'].append(m.board_state_for_json())
print '---- FINAL SCORE ----'
print '%s:\t%f' % (sys.argv[1], m.p1_money)
print '%s:\t%f' % (sys.argv[2], m.p2_money)
示例2: range
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import turn_data_for_p2 [as 别名]
json_data = {'p1_spawn': m.p1_spawn, 'p2_spawn': m.p2_spawn,
'money_payout_rates': m.money_payout_rates, 'turns': [m.board_state_for_json()]}
for i in range(NUM_TURNS):
print 'Turn #%d' % i
# Get the players' actions
try:
p1_actions = [] if p1_crashed else p1.take_turn(*m.turn_data_for_p1())
except:
p1_crashed = True
try:
p2_actions = [] if p2_crashed else p2.take_turn(*m.turn_data_for_p2())
except:
p2_crashed = True
m.apply_moves(p1_actions, p2_actions)
m.resolve_combat()
m.give_payouts()
m.spawn_new_guys()
m.resolve_combat() #in case the new guys spawned into combat
json_data['turns'].append(m.board_state_for_json())
print '---- FINAL SCORE ----'