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

Method start_turn

battlecode-manager/server.py:276–296  ·  view source on GitHub ↗

This is a blocking function that waits until it client_id's turn to start the game. It attempts to take the game lock and then checks to see if the client_id matches the next player id. If it does it returns and the player can start running. This also handle

(self, client_id: int)

Source from the content-addressed store, hash-verified

274 time.sleep(0.1)
275
276 def start_turn(self, client_id: int):
277 '''
278 This is a blocking function that waits until it client_id's turn to
279 start the game. It attempts to take the game lock and then checks to see
280 if the client_id matches the next player id. If it does it returns and
281 the player can start running.
282
283 This also handles waking the docker instances to start computing
284 '''
285
286 logging.debug("Client %s: entered start turn", client_id)
287 exit_well = False
288 player_index = self.player_id2index(client_id)
289 while not self.game_over:
290 if self.turn_events[player_index].wait(timeout=0.1):
291 self.turn_events[player_index].clear()
292 assert(self.current_player_index == player_index)
293 self.times[client_id] += self.time_additional
294 return True
295
296 return False
297
298 def make_action(self, turn_message: bc.TurnMessage, client_id: int, diff_time: float):
299 '''

Callers 1

player_handlerMethod · 0.45

Calls 2

player_id2indexMethod · 0.95
debugMethod · 0.80

Tested by

no test coverage detected