Example #1
0
 def test_parse_seeds(self):
     with self.assertRaises(ValueError):
         pair.parse_seeds(seeds_bad_rating)
     with self.assertRaises(ValueError):
         pair.parse_seeds(seeds_bad_name)
     tourn = pair.parse_seeds(seeds_good)
     self.assertEqual(tourn.events, seeds_good_eventlist)
     self.assertEqual(tourn.players, frozenset(("player1", "player2")))
     self.assertEqual(tourn.seeds, {"player1": 1234.0, "player2": 123})
Example #2
0
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
Example #3
0
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
Example #4
0
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