MCPcopy Index your code
hub / github.com/battlecode/battlecode-2018 / start_game

Function start_game

battlecode-manager/gui.py:121–173  ·  view source on GitHub ↗
(return_args)

Source from the content-addressed store, hash-verified

119 return str(e)
120
121def start_game(return_args):
122 global WINNER
123 WINNER = 0
124 return_args['map_name'] = return_args['map']
125
126 # check mountpoint for maps first
127 c2 = os.path.abspath(os.path.join('/player/battlecode-maps', return_args['map']))
128 if 'NODOCKER' not in os.environ and os.path.exists(c2):
129 return_args['map'] = cli.get_map(c2)
130 else:
131 c1 = os.path.abspath(os.path.join('..', 'battlecode-maps', return_args['map']))
132 if os.path.exists(c1):
133 return_args['map'] = cli.get_map(c1)
134 else:
135 if 'testmap' not in return_args['map']:
136 print("Can't find map {} in {}, falling back to test map..",
137 return_args['map'],
138 os.path.abspath(os.path.join('..', 'battlecode-maps'))
139 )
140 if 'NODOCKER' not in os.environ:
141 print('(Also looked in /player/battlecode-maps, which should be mounted to the battlecode-maps directory of your scaffold)')
142 return_args['map'] = bc.GameMap.test_map()
143
144 if 'NODOCKER' in os.environ:
145 return_args['docker'] = False
146 return_args['dir_p1'] = os.path.abspath(os.path.join('..', return_args['dir_p1']))
147 return_args['dir_p2'] = os.path.abspath(os.path.join('..', return_args['dir_p2']))
148 else:
149 return_args['docker'] = True
150 return_args['dir_p1'] = os.path.abspath(os.path.join('/player', return_args['dir_p1']))
151 return_args['dir_p2'] = os.path.abspath(os.path.join('/player', return_args['dir_p2']))
152 return_args['terminal_viewer'] = False
153 return_args['extra_delay'] = 0
154
155 global game
156 (game, dockers, sock_file) = cli.create_game(return_args)
157
158 winner = None
159 try:
160 print("Running game...")
161 winner = cli.run_game(game, dockers, return_args, sock_file)
162 finally:
163 cli.cleanup(dockers, return_args, sock_file)
164 lock.release()
165
166 if winner == 'player1':
167 eel.trigger_end_game(1)()
168 elif winner == ' player2':
169 eel.trigger_end_game(2)()
170 else:
171 eel.trigger_end_game(0)()
172
173 print("Ready to run next game.")
174
175
176@eel.expose

Callers

nothing calls this directly

Calls 1

test_mapMethod · 0.80

Tested by

no test coverage detected