MCPcopy Create free account
hub / github.com/battlecode/battlecode-2018 / run_tournament

Function run_tournament

scripts/tournament_single_elim.py:303–339  ·  view source on GitHub ↗

The tournament is run in single elimination format. Maps are used in sets of 3, where the 3rd map of one round overlaps with the 1st map of the next round. So if the set of maps is [1, 2, 3, 4, 5], Round 1 will use maps [1, 2, 3] and Round 2 will use maps [3, 4, 5]. maps - A l

(conn, maps: List[Map], teams: List[Team])

Source from the content-addressed store, hash-verified

301
302
303def run_tournament(conn, maps: List[Map], teams: List[Team]):
304 """
305 The tournament is run in single elimination format. Maps are used in sets
306 of 3, where the 3rd map of one round overlaps with the 1st map of the next
307 round. So if the set of maps is [1, 2, 3, 4, 5], Round 1 will use maps
308 [1, 2, 3] and Round 2 will use maps [3, 4, 5].
309
310 maps - A list of maps for the tournament, run in the order they are given.
311 teams - A power of two number of teams, where some of the teams may be BYEs.
312 """
313 logging.debug('Generating a bracket for {} teams and {} maps'
314 .format(len(teams), len(maps)))
315
316 teams = generate_bracket(teams)
317 num_rounds = int(math.log(len(teams), 2))
318
319 logging.debug('We want {} maps, and we have {}'
320 .format(num_rounds * 2 + 1, len(maps)))
321 assert len(maps) >= num_rounds * 2 + 1
322
323 initial_round = int(input('Start at which round? (0 to {}):\n'
324 .format(num_rounds - 1)))
325
326 logging.debug('Running rounds {} to {}... here we go!'
327 .format(initial_round, num_rounds - 1))
328 for round_num in range(initial_round, num_rounds):
329 if round_num == 0:
330 queue_initial_round(conn, teams, maps[:NUM_MAPS_PER_GAME])
331 continue
332
333 wait_for_empty_queue(conn)
334 logging.debug('Queuing Round {} out of {}...'
335 .format(round_num, num_rounds - 1))
336 round_maps = maps[(NUM_MAPS_PER_GAME - 1) * round_num :
337 (NUM_MAPS_PER_GAME - 1) * (round_num + 1) + 1]
338 logging.debug('Using these maps: {}'.format(round_maps))
339 queue_round(conn, round_num, round_maps)
340
341
342def run(conn) -> None:

Callers 1

runFunction · 0.85

Calls 6

generate_bracketFunction · 0.85
queue_initial_roundFunction · 0.85
wait_for_empty_queueFunction · 0.85
queue_roundFunction · 0.85
debugMethod · 0.80
formatMethod · 0.80

Tested by

no test coverage detected