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

Function pad_teams_power_of_two

scripts/tournament_single_elim.py:197–211  ·  view source on GitHub ↗

Pads the teams list to a power of two by adding BYEs to the end.

(teams: List[Team])

Source from the content-addressed store, hash-verified

195
196
197def pad_teams_power_of_two(teams: List[Team]) -> List[Team]:
198 """
199 Pads the teams list to a power of two by adding BYEs to the end.
200 """
201 assert len(teams) > 0
202 num_teams_orig = len(teams)
203 num_teams_goal = 2**math.ceil(math.log(num_teams_orig, 2))
204 for ranking in range(len(teams) + 1, num_teams_goal + 1):
205 teams.append(None)
206
207 logging.debug('Padded {} teams to {} teams (goal {})'.format(
208 num_teams_orig, len(teams), num_teams_goal))
209
210 assert len(teams) & (len(teams) - 1) == 0
211 return teams
212
213
214def queue_match(conn, round_num, index, red, blue, maps):

Callers 1

runFunction · 0.85

Calls 2

debugMethod · 0.80
formatMethod · 0.80

Tested by

no test coverage detected