本文整理汇总了Python中map.Map.board_state_for_json方法的典型用法代码示例。如果您正苦于以下问题:Python Map.board_state_for_json方法的具体用法?Python Map.board_state_for_json怎么用?Python Map.board_state_for_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map.Map
的用法示例。
在下文中一共展示了Map.board_state_for_json方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exec
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import board_state_for_json [as 别名]
if sys.argv[2].endswith(".py"):
exec("from %s import Player as Player2" % sys.argv[2][:-3])
else:
Player2 = partial(NetworkPlayer, sys.argv[2])
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()
示例2: partial
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import board_state_for_json [as 别名]
Player1 = partial(NetworkPlayer, sys.argv[1])
if sys.argv[2].endswith(".py"):
exec('from %s import Player as Player2' % sys.argv[2][:-3])
else:
Player2 = partial(NetworkPlayer, sys.argv[2])
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
示例3: Map
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import board_state_for_json [as 别名]
m = Map()
p1_crashed = False
p2_crashed = False
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,
'p1_name' : sys.argv[1],
'p2_name' : sys.argv[2],
'winner' : 0,
'max_guys': m.max_guys,
'max_gold': m.max_gold,
'max_seeds': m.max_seeds,
'turns': [m.board_state_for_json(0)]}
# Spawn some initial guys.
m.spawn_new_guys()
for turn in range(NUM_TURNS):
print 'Turn #%d' % turn
# Get the players' actions
try:
p1_actions = [] if p1_crashed else p1.take_turn(*m.turn_data_for_p1(turn))
except:
print "P1 Crashed!"
p1_crashed = True
try: