def test_parse_tournament(self): tourn = pair.parse_tournament(tournament_state_good) self.assertEqual(tourn.events, tournament_state_good_eventlist) self.assertEqual(tourn.players, tournament_state_good_players) self.assertEqual(tourn.seeds, tournament_state_good_seeds) self.assertEqual(tourn.games, tournament_state_good_games) tourn = pair.parse_tournament(tournament_state_early_stop) self.assertEqual(tourn.events, tournament_state_early_stop_eventlist) for state in bad_tournament_states: try: with self.assertRaises(ValueError): pair.parse_tournament(state) except AssertionError: print "parse_tournament did not raise ValueError on:" print state raise
def main(args=None): args = parse_args(args) if args.tournament_state: with open(args.tournament_state) as state_file: tourn = parse_tournament(state_file.read()) else: with open(args.seed_file) as seed_file: tourn = parse_seeds(seed_file.read()) if args.history_file: with open(args.history_file) as history_file: parse_history(tourn, history_file.read()) if args.prelives > 0: filter_players(tourn, args.prelives) pairings, bye = get_pairings(tourn, args) if args.ranks: players = sorted(tourn.players, key=lambda p: tourn.ranks[p]) for p in players: print "#", tourn.ranks[p], p, tourn.player_order[p] pairings, arbitrary = assign_colors(tourn, pairings) pairings.sort(key=lambda pr: min(tourn.ranks[pr[0]], tourn.ranks[pr[1]])) if bye: print "bye", bye for p1, p2 in pairings: if args.show_arbitrary: print "game", p1, p2, "# A" if (p1, p2) in arbitrary else "" else: print "game", p1, p2
def main(args=None): args = parse_args(args) if args.tournament_state: with open(args.tournament_state) as state_file: tourn = parse_tournament(state_file.read()) else: with open(args.seed_file) as seed_file: tourn = parse_seeds(seed_file.read()) if args.history_file: with open(args.history_file) as history_file: parse_history(tourn, history_file.read()) if args.prelives > 0: filter_players(tourn, args.prelives) pairings, bye = get_pairings(tourn, args.virtual) if args.ranks: players = sorted(tourn.players, key=lambda p: tourn.ranks[p]) for p in players: print "#", tourn.ranks[p], p, tourn.player_order[p] pairings, arbitrary = assign_colors(tourn, pairings) if bye: print "bye", bye for p1, p2 in pairings: if args.show_arbitrary: print "game", p1, p2, "A" if (p1, p2) in arbitrary else "" else: print "game", p1, p2
def main(args=None): args = parse_args(args) if args.tournament_state: with open(args.tournament_state) as state_file: tourn = parse_tournament(state_file.read()) else: with open(args.seed_file) as seed_file: seed_data = seed_file.read() tourn = parse_seeds(seed_data) if args.game_file: with open(args.game_file) as history_file: history_data = history_file.read() parse_history(tourn, history_data) if not args.all_games: tourn = filter_games(tourn, args.lives) pairings, bye = get_pairings(tourn, args) if len(pairings) == 0: # tournament is finished, print final ranks print_final_ranking(tourn, args.virtual, args.utpr) if args.ranks: players = sorted(tourn.ranks, key=lambda p: tourn.ranks[p]) for p in players: print "#", tourn.ranks[p], p, tourn.player_order[p][0], for r in tourn.player_order[p][1:]: print -r, print pairings, arbitrary = assign_colors(tourn, pairings) pairings.sort(key=lambda pr: min(tourn.ranks[pr[0]], tourn.ranks[pr[1]])) if bye: print "bye", bye for p1, p2 in pairings: if args.show_arbitrary: print "game", p1, p2, "# A" if (p1, p2) in arbitrary else "" else: print "game", p1, p2
def main(): arg_parser = ArgumentParser() arg_parser.add_argument("--user", "-u") arg_parser.add_argument("--auth", "-a") arg_parser.add_argument("tournament_state") args = arg_parser.parse_args() payload = dict(cmd="users", user=args.user, auth=args.auth) resp = requests.post("http://arimaa.com/arimaa/chat/srv.php", data=payload) users = resp.content[3:].split() with open(args.tournament_state) as state_file: tourn = parse_tournament(state_file.read()) missing = 0 for player in tourn.players: if player not in users: print "Did not find %s in the chatroom" % (player, ) missing += 1 if missing == 0: print "All players present, good to go." else: print "Missing %d players!" % (missing, )
def main(): arg_parser = ArgumentParser() arg_parser.add_argument("--user", "-u") arg_parser.add_argument("--auth", "-a") arg_parser.add_argument("tournament_state") args = arg_parser.parse_args() payload = dict(cmd="users", user=args.user, auth=args.auth) resp = requests.post("http://arimaa.com/arimaa/chat/srv.php", data=payload) users = resp.content[3:].split() with open(args.tournament_state) as state_file: tourn = parse_tournament(state_file.read()) missing = 0 for player in tourn.players: if player not in users: print "Did not find %s in the chatroom" % (player,) missing += 1 if missing == 0: print "All players present, good to go." else: print "Missing %d players!" % (missing,)