Beispiel #1
0
def test_self_play(tc):
    config = default_config()
    config['matchups'] = [
        Matchup_config('t1', 't1', alternating=True),
        Matchup_config('t1', 't1', alternating=False),
        ]
    fx = Playoff_fixture(tc, config)

    jobs = [fx.comp.get_game() for _ in range(20)]
    for i, job in enumerate(jobs):
        response = fake_response(job, 'b' if i < 9 else 'w')
        fx.comp.process_game_result(response)
    fx.check_screen_report(dedent("""\
    t1 v t1#2 (10 games)
    board size: 13   komi: 7.5
           wins              black        white
    t1        6 60.00%       3 60.00%     3 60.00%
    t1#2      4 40.00%       2 40.00%     2 40.00%
                             5 50.00%     5 50.00%

    t1 v t1#2 (10 games)
    board size: 13   komi: 7.5
           wins
    t1        4 40.00%   (black)
    t1#2      6 60.00%   (white)
    """))

    competition_test_support.check_round_trip(tc, fx.comp, config)
Beispiel #2
0
def test_play_many(tc):
    config = default_config()
    config['rounds'] = 30
    fx = Allplayall_fixture(tc, config)

    jobs = [fx.comp.get_game() for _ in xrange(57)]
    for i in xrange(57):
        response = fake_response(jobs[i], 'b')
        fx.comp.process_game_result(response)

    fx.check_screen_report(dedent("""\
    57/90 games played

          A    B    C
    A t1      10-9 10-9
    B t2 9-10      10-9
    C t3 9-10 9-10
    """))

    tc.assertEqual(
        len(fx.comp.get_tournament_results().get_matchup_results('AvB')), 19)

    comp2 = competition_test_support.check_round_trip(tc, fx.comp, config)
    jobs2 = [comp2.get_game() for _ in range(4)]
    tc.assertListEqual([job.game_id for job in jobs2],
                       ['AvB_19', 'AvC_19', 'BvC_19', 'AvB_20'])
    tr = comp2.get_tournament_results()
    tc.assertEqual(len(tr.get_matchup_results('AvB')), 19)
    ms = tr.get_matchup_stats('AvB')
    tc.assertEqual(ms.total, 19)
    tc.assertEqual(ms.wins_1, 10)
    tc.assertIs(ms.alternating, True)
Beispiel #3
0
def test_play_many(tc):
    config = default_config()
    config['rounds'] = 30
    fx = Allplayall_fixture(tc, config)

    jobs = [fx.comp.get_game() for _ in xrange(57)]
    for i in xrange(57):
        response = fake_response(jobs[i], 'b')
        fx.comp.process_game_result(response)

    fx.check_screen_report(
        dedent("""\
    57/90 games played

          A    B    C
    A t1      10-9 10-9
    B t2 9-10      10-9
    C t3 9-10 9-10
    """))

    tc.assertEqual(
        len(fx.comp.get_tournament_results().get_matchup_results('AvB')), 19)

    comp2 = competition_test_support.check_round_trip(tc, fx.comp, config)
    jobs2 = [comp2.get_game() for _ in range(4)]
    tc.assertListEqual([job.game_id for job in jobs2],
                       ['AvB_19', 'AvC_19', 'BvC_19', 'AvB_20'])
    tr = comp2.get_tournament_results()
    tc.assertEqual(len(tr.get_matchup_results('AvB')), 19)
    ms = tr.get_matchup_stats('AvB')
    tc.assertEqual(ms.total, 19)
    tc.assertEqual(ms.wins_1, 10)
    tc.assertIs(ms.alternating, True)
Beispiel #4
0
def test_play_many(tc):
    fx = Playoff_fixture(tc)

    jobs = [fx.comp.get_game() for _ in range(8)]
    for i in [0, 3]:
        response = fake_response(jobs[i], 'b')
        fx.comp.process_game_result(response)
    jobs += [fx.comp.get_game() for _ in range(3)]
    for i in [4, 2, 6, 7]:
        response = fake_response(jobs[i], 'w')
        fx.comp.process_game_result(response)

    fx.check_screen_report(
        dedent("""\
    t1 v t2 (6 games)
    board size: 13   komi: 7.5
         wins              black        white
    t1      2 33.33%       1 25.00%     1 50.00%
    t2      4 66.67%       1 50.00%     3 75.00%
                           2 33.33%     4 66.67%
    """))

    tc.assertEqual(
        len(fx.comp.get_tournament_results().get_matchup_results('0')), 6)

    #tc.assertEqual(fx.comp.scheduler.allocators['0'].issued, 11)
    #tc.assertEqual(fx.comp.scheduler.allocators['0'].fixed, 6)

    comp2 = competition_test_support.check_round_trip(tc, fx.comp,
                                                      default_config())

    #tc.assertEqual(comp2.scheduler.allocators['0'].issued, 6)
    #tc.assertEqual(comp2.scheduler.allocators['0'].fixed, 6)

    jobs2 = [comp2.get_game() for _ in range(4)]
    tc.assertListEqual([job.game_id for job in jobs2],
                       ['0_1', '0_5', '0_8', '0_9'])
    tr = comp2.get_tournament_results()
    tc.assertEqual(len(tr.get_matchup_results('0')), 6)
    ms = tr.get_matchup_stats('0')
    tc.assertEqual(ms.total, 6)
    tc.assertEqual(ms.wins_1, 2)
    tc.assertEqual(ms.wins_b, 2)
Beispiel #5
0
def test_play_many(tc):
    fx = Playoff_fixture(tc)

    jobs = [fx.comp.get_game() for _ in range(8)]
    for i in [0, 3]:
        response = fake_response(jobs[i], 'b')
        fx.comp.process_game_result(response)
    jobs += [fx.comp.get_game() for _ in range(3)]
    for i in [4, 2, 6, 7]:
        response = fake_response(jobs[i], 'w')
        fx.comp.process_game_result(response)

    fx.check_screen_report(dedent("""\
    t1 v t2 (6 games)
    board size: 13   komi: 7.5
         wins              black        white
    t1      2 33.33%       1 25.00%     1 50.00%
    t2      4 66.67%       1 50.00%     3 75.00%
                           2 33.33%     4 66.67%
    """))

    tc.assertEqual(
        len(fx.comp.get_tournament_results().get_matchup_results('0')), 6)

    #tc.assertEqual(fx.comp.scheduler.allocators['0'].issued, 11)
    #tc.assertEqual(fx.comp.scheduler.allocators['0'].fixed, 6)

    comp2 = competition_test_support.check_round_trip(
        tc, fx.comp, default_config())

    #tc.assertEqual(comp2.scheduler.allocators['0'].issued, 6)
    #tc.assertEqual(comp2.scheduler.allocators['0'].fixed, 6)

    jobs2 = [comp2.get_game() for _ in range(4)]
    tc.assertListEqual([job.game_id for job in jobs2],
                       ['0_1', '0_5', '0_8', '0_9'])
    tr = comp2.get_tournament_results()
    tc.assertEqual(len(tr.get_matchup_results('0')), 6)
    ms = tr.get_matchup_stats('0')
    tc.assertEqual(ms.total, 6)
    tc.assertEqual(ms.wins_1, 2)
    tc.assertEqual(ms.wins_b, 2)