Esempio n. 1
0
 def setUp(self):
     self.maxDiff = None
     self.engine  = DutchPairingEngine()
Esempio n. 2
0
def create_pairing():
    #現在のラウンド数を取得する
    round_no = Round.objects.get().round_no
    if round_no is 1:
        #最初のラウンドは、Engineを作成する
        engine = DutchPairingEngine()
    else:
        #2ラウンド以降は、pickle化したエンジンを取得する
        engine = load_engine()

    #タプルに変換するためのリスト
    player_class_list = []
    #検索用
    player_class_dict = {}

    #playerクラスを作る
    players = CurrentRoundPlayerList.objects.order_by('pairing_no').all()
    for p in players:
        if round_no is 1:
            distinct_player = Player(name=p.name,
                                     rating=p.rating,
                                     pairing_no=p.pairing_no,
                                     score=p.score,
                                     float_status=p.float_status)
            player_class_list.append(distinct_player)
            player_class_dict[p.pairing_no] = p.name
        else:
            if (len(p.opponents) is not round_no - 1) or (len(p.colour_hist)
                                                          is not round_no - 1):
                raise SwissException("Round No. must be wrong.")

            distinct_player = Player(name=p.name,
                                     rating=p.rating,
                                     pairing_no=p.pairing_no,
                                     score=p.score,
                                     float_status=p.float_status,
                                     opponents=tuple(p.opponents),
                                     colour_hist=tuple(p.colour_hist))
            player_class_list.append(distinct_player)
            player_class_dict[p.pairing_no] = p.name

    player_class_tuple = tuple(player_class_list)

    current_pairing = engine.pair_round(round_no, player_class_tuple)

    #engineをダンプする
    dump_engine(engine)

    #現在のペアリングをDBに入れる
    for cp in current_pairing:
        if not len(CurrentRoundPlayerList.objects.filter(name=cp.name)) is 1:
            raise SwissException("CurrentRoundPlayerList must be wrong.")

        q = CurrentRoundPlayerList.objects.filter(name=cp.name).get()
        q.score = cp.score
        q.float_status = cp.float_status
        q.opponents = list(cp.opponents)
        q.colour_hist = list(cp.colour_hist)

        q.save()

        #Byeのプレーヤーは、PooledResultをこのタイミングで入れておく
        if cp.colour_hist[-1] is Colour.none:
            q = PooledResults(name=cp.name, result=1)
            q.save()
Esempio n. 3
0
class Test_DutchPairingEngine(unittest.TestCase):
    def setUp(self):
        self.maxDiff = None
        self.engine  = DutchPairingEngine()

    def test_pair_2nd_round(self):
        input_players = (
            Player(name='Alice',
                   rating=2500,
                   title=FideTitle.GM,
                   pairing_no=1,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(8,),
                   colour_hist=(Colour.white,)),
            Player(name='Bruno',
                   rating=2500,
                   title=FideTitle.IM,
                   pairing_no=2,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(9,),
                   colour_hist=(Colour.black,)),
            Player(name='Carla',
                   rating=2400,
                   title=FideTitle.WGM,
                   pairing_no=3,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(10,),
                   colour_hist=(Colour.white,)),
            Player(name='David',
                   rating=2400,
                   title=FideTitle.FM,
                   pairing_no=4,
                   score=0.5,
                   float_status=FloatStatus.none,
                   opponents=(11,),
                   colour_hist=(Colour.black,)),
            Player(name='Eloise',
                   rating=2350,
                   title=FideTitle.WIM,
                   pairing_no=5,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(12,),
                   colour_hist=(Colour.white,)),
            Player(name='Finn',
                   rating=2300,
                   title=FideTitle.FM,
                   pairing_no=6,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(13,),
                   colour_hist=(Colour.black,)),
            Player(name='Giorgia',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=7,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(14,),
                   colour_hist=(Colour.white,)),
            Player(name='Kevin',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=8,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(1,),
                   colour_hist=(Colour.black,)),
            Player(name='Louise',
                   rating=2150,
                   title=FideTitle.WIM,
                   pairing_no=9,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(2,),
                   colour_hist=(Colour.white,)),
            Player(name='Mark',
                   rating=2150,
                   title=FideTitle.CM,
                   pairing_no=10,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(3,),
                   colour_hist=(Colour.black,)),
            Player(name='Nancy',
                   rating=2100,
                   title=FideTitle.WFM,
                   pairing_no=11,
                   score=0.5,
                   float_status=FloatStatus.none,
                   opponents=(4,),
                   colour_hist=(Colour.white,)),
            Player(name='Patricia',
                   rating=2050,
                   title=0,
                   pairing_no=13,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(6,),
                   colour_hist=(Colour.white,)),
            Player(name='Robert',
                   rating=2000,
                   title=0,
                   pairing_no=14,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(7,),
                   colour_hist=(Colour.black,))
        )
        expected_players = [
            Player(name='Alice',
                   rating=2500,
                   title=FideTitle.GM,
                   pairing_no=1,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(8, 5),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='Bruno',
                   rating=2500,
                   title=FideTitle.IM,
                   pairing_no=2,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(9, 7),
                   colour_hist=(Colour.black, Colour.white)),
            Player(name='Carla',
                   rating=2400,
                   title=FideTitle.WGM,
                   pairing_no=3,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(10, 6),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='David',
                   rating=2400,
                   title=FideTitle.FM,
                   pairing_no=4,
                   score=0.5,
                   float_status=FloatStatus.down,
                   opponents=(11, 9),
                   colour_hist=(Colour.black, Colour.white)),
            Player(name='Eloise',
                   rating=2350,
                   title=FideTitle.WIM,
                   pairing_no=5,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(12, 1),
                   colour_hist=(Colour.white, Colour.white)),
            Player(name='Finn',
                   rating=2300,
                   title=FideTitle.FM,
                   pairing_no=6,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(13, 3),
                   colour_hist=(Colour.black, Colour.white)),
            Player(name='Giorgia',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=7,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(14, 2),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='Kevin',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=8,
                   score=0,
                   float_status=FloatStatus.up,
                   opponents=(1, 11),
                   colour_hist=(Colour.black, Colour.white)),
            Player(name='Louise',
                   rating=2150,
                   title=FideTitle.WIM,
                   pairing_no=9,
                   score=0,
                   float_status=FloatStatus.up,
                   opponents=(2, 4),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='Mark',
                   rating=2150,
                   title=FideTitle.CM,
                   pairing_no=10,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(3, 13),
                   colour_hist=(Colour.black, Colour.white)),
            Player(name='Nancy',
                   rating=2100,
                   title=FideTitle.WFM,
                   pairing_no=11,
                   score=0.5,
                   float_status=FloatStatus.down,
                   opponents=(4, 8),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='Patricia',
                   rating=2050,
                   title=0,
                   pairing_no=13,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(6, 10),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='Robert',
                   rating=2000,
                   title=0,
                   pairing_no=14,
                   score=1,
                   float_status=FloatStatus.down,
                   opponents=(7, 0),
                   colour_hist=(Colour.black, Colour.none))
        ]

        result_players = self.engine.pair_round(2, input_players)
        self.assertCountEqual(result_players, expected_players)

    def test_pair_3rd_round(self):
        input_players = (
            Player(name='Alice',
                   rating=2500,
                   title=FideTitle.GM,
                   pairing_no=1,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(8, 5),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='Bruno',
                   rating=2500,
                   title=FideTitle.IM,
                   pairing_no=2,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(9, 7),
                   colour_hist=(Colour.black, Colour.white)),
            Player(name='Carla',
                   rating=2400,
                   title=FideTitle.WGM,
                   pairing_no=3,
                   score=1.5,
                   float_status=FloatStatus.none,
                   opponents=(10, 6),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='David',
                   rating=2400,
                   title=FideTitle.FM,
                   pairing_no=4,
                   score=1.5,
                   float_status=FloatStatus.down,
                   opponents=(11, 9),
                   colour_hist=(Colour.black, Colour.white)),
            Player(name='Eloise',
                   rating=2350,
                   title=FideTitle.WIM,
                   pairing_no=5,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(12, 1),
                   colour_hist=(Colour.white, Colour.white)),
            Player(name='Finn',
                   rating=2300,
                   title=FideTitle.FM,
                   pairing_no=6,
                   score=1.5,
                   float_status=FloatStatus.none,
                   opponents=(13, 3),
                   colour_hist=(Colour.black, Colour.white)),
            Player(name='Giorgia',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=7,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(14, 2),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='Kevin',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=8,
                   score=0,
                   float_status=FloatStatus.up,
                   opponents=(1, 11),
                   colour_hist=(Colour.black, Colour.white)),
            Player(name='Louise',
                   rating=2150,
                   title=FideTitle.WIM,
                   pairing_no=9,
                   score=0,
                   float_status=FloatStatus.up,
                   opponents=(2, 4),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='Mark',
                   rating=2150,
                   title=FideTitle.CM,
                   pairing_no=10,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(3, 13),
                   colour_hist=(Colour.black, Colour.white)),
            Player(name='Nancy',
                   rating=2100,
                   title=FideTitle.WFM,
                   pairing_no=11,
                   score=1.5,
                   float_status=FloatStatus.down,
                   opponents=(4, 8),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='Oskar',
                   rating=2100,
                   title=0,
                   pairing_no=12,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(5,0),
                   colour_hist=(Colour.black,Colour.none)),
            Player(name='Patricia',
                   rating=2050,
                   title=0,
                   pairing_no=13,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(6, 10),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='Robert',
                   rating=2000,
                   title=0,
                   pairing_no=14,
                   score=1,
                   float_status=FloatStatus.down,
                   opponents=(7, 0),
                   colour_hist=(Colour.black, Colour.none))
        )
        expected_players = [
            Player(name='Alice',
                   rating=2500,
                   title=FideTitle.GM,
                   pairing_no=1,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(8, 5, 14),
                   colour_hist=(Colour.white, Colour.black, Colour.black)),
            Player(name='Bruno',
                   rating=2500,
                   title=FideTitle.IM,
                   pairing_no=2,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(9, 7, 5),
                   colour_hist=(Colour.black, Colour.white, Colour.white)),
            Player(name='Carla',
                   rating=2400,
                   title=FideTitle.WGM,
                   pairing_no=3,
                   score=1.5,
                   float_status=FloatStatus.none,
                   opponents=(10, 6, 4),
                   colour_hist=(Colour.white, Colour.black, Colour.white)),
            Player(name='David',
                   rating=2400,
                   title=FideTitle.FM,
                   pairing_no=4,
                   score=1.5,
                   float_status=FloatStatus.downPrev,
                   opponents=(11, 9, 3),
                   colour_hist=(Colour.black, Colour.white, Colour.black)),
            Player(name='Eloise',
                   rating=2350,
                   title=FideTitle.WIM,
                   pairing_no=5,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(12, 1, 2),
                   colour_hist=(Colour.white, Colour.white, Colour.black)),
            Player(name='Finn',
                   rating=2300,
                   title=FideTitle.FM,
                   pairing_no=6,
                   score=1.5,
                   float_status=FloatStatus.none,
                   opponents=(13, 3, 11),
                   colour_hist=(Colour.black, Colour.white, Colour.black)),
            Player(name='Giorgia',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=7,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(14, 2, 10),
                   colour_hist=(Colour.white, Colour.black, Colour.white)),
            Player(name='Kevin',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=8,
                   score=0,
                   float_status=FloatStatus.upPrev,
                   opponents=(1, 11, 12),
                   colour_hist=(Colour.black, Colour.white, Colour.black)),
            Player(name='Louise',
                   rating=2150,
                   title=FideTitle.WIM,
                   pairing_no=9,
                   score=0,
                   float_status=FloatStatus.upPrev,
                   opponents=(2, 4, 13),
                   colour_hist=(Colour.white, Colour.black, Colour.white)),
            Player(name='Mark',
                   rating=2150,
                   title=FideTitle.CM,
                   pairing_no=10,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(3, 13, 7),
                   colour_hist=(Colour.black, Colour.white, Colour.black)),
            Player(name='Nancy',
                   rating=2100,
                   title=FideTitle.WFM,
                   pairing_no=11,
                   score=1.5,
                   float_status=FloatStatus.downPrev,
                   opponents=(4, 8, 6),
                   colour_hist=(Colour.white, Colour.black, Colour.white)),
            Player(name='Oskar',
                   rating=2100,
                   title=0,
                   pairing_no=12,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(5, 0, 8),
                   colour_hist=(Colour.black, Colour.none, Colour.white)),
            Player(name='Patricia',
                   rating=2050,
                   title=0,
                   pairing_no=13,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(6, 10, 9),
                   colour_hist=(Colour.white, Colour.black, Colour.black)),
            Player(name='Robert',
                   rating=2000,
                   title=0,
                   pairing_no=14,
                   score=1,
                   float_status=FloatStatus.downPrev,
                   opponents=(7, 0, 1),
                   colour_hist=(Colour.black, Colour.none, Colour.white))
        ]

        result_players = self.engine.pair_round(3, input_players)
        self.assertCountEqual(result_players, expected_players)

    def test_pair_4th_round(self):
        input_players = (
            Player(name='Alice',
                   rating=2500,
                   title=FideTitle.GM,
                   pairing_no=1,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(8, 5, 14),
                   colour_hist=(Colour.white, Colour.black, Colour.black)),
            Player(name='Bruno',
                   rating=2500,
                   title=FideTitle.IM,
                   pairing_no=2,
                   score=2.5,
                   float_status=FloatStatus.none,
                   opponents=(9, 7, 5),
                   colour_hist=(Colour.black, Colour.white, Colour.white)),
            Player(name='Carla',
                   rating=2400,
                   title=FideTitle.WGM,
                   pairing_no=3,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(10, 6, 4),
                   colour_hist=(Colour.white, Colour.black, Colour.white)),
            Player(name='David',
                   rating=2400,
                   title=FideTitle.FM,
                   pairing_no=4,
                   score=2,
                   float_status=FloatStatus.downPrev,
                   opponents=(11, 9, 3),
                   colour_hist=(Colour.black, Colour.white, Colour.black)),
            Player(name='Eloise',
                   rating=2350,
                   title=FideTitle.WIM,
                   pairing_no=5,
                   score=2.5,
                   float_status=FloatStatus.none,
                   opponents=(12, 1, 2),
                   colour_hist=(Colour.white, Colour.white, Colour.black)),
            Player(name='Finn',
                   rating=2300,
                   title=FideTitle.FM,
                   pairing_no=6,
                   score=2.5,
                   float_status=FloatStatus.down,
                   opponents=(13, 3, 0),
                   colour_hist=(Colour.black, Colour.white, Colour.none)),
            Player(name='Giorgia',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=7,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(14, 2, 10),
                   colour_hist=(Colour.white, Colour.black, Colour.white)),
            Player(name='Kevin',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=8,
                   score=0.5,
                   float_status=FloatStatus.upPrev,
                   opponents=(1, 11, 12),
                   colour_hist=(Colour.black, Colour.white, Colour.black)),
            Player(name='Louise',
                   rating=2150,
                   title=FideTitle.WIM,
                   pairing_no=9,
                   score=1,
                   float_status=FloatStatus.upPrev,
                   opponents=(2, 4, 13),
                   colour_hist=(Colour.white, Colour.black, Colour.white)),
            Player(name='Mark',
                   rating=2150,
                   title=FideTitle.CM,
                   pairing_no=10,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(3, 13, 7),
                   colour_hist=(Colour.black, Colour.white, Colour.black)),
            Player(name='Nancy',
                   rating=2100,
                   title=FideTitle.WFM,
                   pairing_no=11,
                   score=1.5,
                   float_status=FloatStatus.downPrev,
                   opponents=(4, 8, 0),
                   colour_hist=(Colour.white, Colour.black, Colour.none)),
            Player(name='Oskar',
                   rating=2100,
                   title=0,
                   pairing_no=12,
                   score=0.5,
                   float_status=FloatStatus.none,
                   opponents=(5, 0, 8),
                   colour_hist=(Colour.black, Colour.none, Colour.white)),
            Player(name='Patricia',
                   rating=2050,
                   title=0,
                   pairing_no=13,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(6, 10, 9),
                   colour_hist=(Colour.white, Colour.black, Colour.black)),
            Player(name='Robert',
                   rating=2000,
                   title=0,
                   pairing_no=14,
                   score=1,
                   float_status=FloatStatus.downPrev,
                   opponents=(7, 0, 1),
                   colour_hist=(Colour.black, Colour.none, Colour.white))
        )
        expected_players = [
            Player(name='Alice',
                   rating=2500,
                   title=FideTitle.GM,
                   pairing_no=1,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(8, 5, 14, 3),
                   colour_hist=(Colour.white, Colour.black, Colour.black,
                                Colour.white)),
            Player(name='Bruno',
                   rating=2500,
                   title=FideTitle.IM,
                   pairing_no=2,
                   score=2.5,
                   float_status=FloatStatus.none,
                   opponents=(9, 7, 5, 6),
                   colour_hist=(Colour.black, Colour.white, Colour.white,
                                Colour.black)),
            Player(name='Carla',
                   rating=2400,
                   title=FideTitle.WGM,
                   pairing_no=3,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(10, 6, 4, 1),
                   colour_hist=(Colour.white, Colour.black, Colour.white,
                                Colour.black)),
            Player(name='David',
                   rating=2400,
                   title=FideTitle.FM,
                   pairing_no=4,
                   score=2,
                   float_status=FloatStatus.up,
                   opponents=(11, 9, 3, 5),
                   colour_hist=(Colour.black, Colour.white, Colour.black,
                                Colour.white)),
            Player(name='Eloise',
                   rating=2350,
                   title=FideTitle.WIM,
                   pairing_no=5,
                   score=2.5,
                   float_status=FloatStatus.down,
                   opponents=(12, 1, 2, 4),
                   colour_hist=(Colour.white, Colour.white, Colour.black,
                                Colour.black)),
            Player(name='Finn',
                   rating=2300,
                   title=FideTitle.FM,
                   pairing_no=6,
                   score=2.5,
                   float_status=FloatStatus.downPrev,
                   opponents=(13, 3, 0, 2),
                   colour_hist=(Colour.black, Colour.white, Colour.none,
                                Colour.white)),
            Player(name='Giorgia',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=7,
                   score=2,
                   float_status=FloatStatus.down,
                   opponents=(14, 2, 10, 11),
                   colour_hist=(Colour.white, Colour.black, Colour.white,
                                Colour.black)),
            Player(name='Kevin',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=8,
                   score=0.5,
                   float_status=FloatStatus.up,
                   opponents=(1, 11, 12, 9),
                   colour_hist=(Colour.black, Colour.white, Colour.black,
                                Colour.white)),
            Player(name='Louise',
                   rating=2150,
                   title=FideTitle.WIM,
                   pairing_no=9,
                   score=1,
                   float_status=FloatStatus.down,
                   opponents=(2, 4, 13, 8),
                   colour_hist=(Colour.white, Colour.black, Colour.white,
                                Colour.black)),
            Player(name='Mark',
                   rating=2150,
                   title=FideTitle.CM,
                   pairing_no=10,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(3, 13, 7, 14),
                   colour_hist=(Colour.black, Colour.white, Colour.black,
                                Colour.white)),
            Player(name='Nancy',
                   rating=2100,
                   title=FideTitle.WFM,
                   pairing_no=11,
                   score=1.5,
                   float_status=FloatStatus.up,
                   opponents=(4, 8, 0, 7),
                   colour_hist=(Colour.white, Colour.black, Colour.none,
                                Colour.white)),
            Player(name='Oskar',
                   rating=2100,
                   title=0,
                   pairing_no=12,
                   score=0.5,
                   float_status=FloatStatus.down,
                   opponents=(5, 0, 8, 13),
                   colour_hist=(Colour.black, Colour.none, Colour.white,
                                Colour.black)),
            Player(name='Patricia',
                   rating=2050,
                   title=0,
                   pairing_no=13,
                   score=0,
                   float_status=FloatStatus.up,
                   opponents=(6, 10, 9, 12),
                   colour_hist=(Colour.white, Colour.black, Colour.black,
                                Colour.white)),
            Player(name='Robert',
                   rating=2000,
                   title=0,
                   pairing_no=14,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(7, 0, 1, 10),
                   colour_hist=(Colour.black, Colour.none, Colour.white,
                                Colour.black))
        ]

        result_players = self.engine.pair_round(4, input_players)
        self.assertCountEqual(result_players, expected_players)

    def test_pair_5th_round(self):
        input_players = (
            Player(name='Alice',
                   rating=2500,
                   title=FideTitle.GM,
                   pairing_no=1,
                   score=3,
                   float_status=FloatStatus.none,
                   opponents=(8, 5, 14, 3),
                   colour_hist=(Colour.white, Colour.black, Colour.black,
                                Colour.white)),
            Player(name='Bruno',
                   rating=2500,
                   title=FideTitle.IM,
                   pairing_no=2,
                   score=3.5,
                   float_status=FloatStatus.none,
                   opponents=(9, 7, 5, 6),
                   colour_hist=(Colour.black, Colour.white, Colour.white,
                                Colour.black)),
            Player(name='Carla',
                   rating=2400,
                   title=FideTitle.WGM,
                   pairing_no=3,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(10, 6, 4, 1),
                   colour_hist=(Colour.white, Colour.black, Colour.white,
                                Colour.black)),
            Player(name='David',
                   rating=2400,
                   title=FideTitle.FM,
                   pairing_no=4,
                   score=2.5,
                   float_status=FloatStatus.up,
                   opponents=(11, 9, 3, 5),
                   colour_hist=(Colour.black, Colour.white, Colour.black,
                                Colour.white)),
            Player(name='Eloise',
                   rating=2350,
                   title=FideTitle.WIM,
                   pairing_no=5,
                   score=3,
                   float_status=FloatStatus.down,
                   opponents=(12, 1, 2, 4),
                   colour_hist=(Colour.white, Colour.white, Colour.black,
                                Colour.black)),
            Player(name='Finn',
                   rating=2300,
                   title=FideTitle.FM,
                   pairing_no=6,
                   score=2.5,
                   float_status=FloatStatus.downPrev,
                   opponents=(13, 3, 0, 2),
                   colour_hist=(Colour.black, Colour.white, Colour.none,
                                Colour.white)),
            Player(name='Giorgia',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=7,
                   score=2,
                   float_status=FloatStatus.down,
                   opponents=(14, 2, 10, 11),
                   colour_hist=(Colour.white, Colour.black, Colour.white,
                                Colour.black)),
            Player(name='Kevin',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=8,
                   score=1,
                   float_status=FloatStatus.up,
                   opponents=(1, 11, 12, 9),
                   colour_hist=(Colour.black, Colour.white, Colour.black,
                                Colour.white)),
            Player(name='Louise',
                   rating=2150,
                   title=FideTitle.WIM,
                   pairing_no=9,
                   score=1.5,
                   float_status=FloatStatus.down,
                   opponents=(2, 4, 13, 8),
                   colour_hist=(Colour.white, Colour.black, Colour.white,
                                Colour.black)),
            Player(name='Mark',
                   rating=2150,
                   title=FideTitle.CM,
                   pairing_no=10,
                   score=1.5,
                   float_status=FloatStatus.none,
                   opponents=(3, 13, 7, 14),
                   colour_hist=(Colour.black, Colour.white, Colour.black,
                                Colour.white)),
            Player(name='Nancy',
                   rating=2100,
                   title=FideTitle.WFM,
                   pairing_no=11,
                   score=2.5,
                   float_status=FloatStatus.up,
                   opponents=(4, 8, 0, 7),
                   colour_hist=(Colour.white, Colour.black, Colour.none,
                                Colour.white)),
            Player(name='Oskar',
                   rating=2100,
                   title=0,
                   pairing_no=12,
                   score=0.5,
                   float_status=FloatStatus.down,
                   opponents=(5, 0, 8, 13),
                   colour_hist=(Colour.black, Colour.none, Colour.white,
                                Colour.black)),
            Player(name='Patricia',
                   rating=2050,
                   title=0,
                   pairing_no=13,
                   score=1,
                   float_status=FloatStatus.up,
                   opponents=(6, 10, 9, 12),
                   colour_hist=(Colour.white, Colour.black, Colour.black,
                                Colour.white)),
            Player(name='Robert',
                   rating=2000,
                   title=0,
                   pairing_no=14,
                   score=1.5,
                   float_status=FloatStatus.none,
                   opponents=(7, 0, 1, 10),
                   colour_hist=(Colour.black, Colour.none, Colour.white,
                                Colour.black))
        )
        expected_players = [
            Player(name='Alice',
                   rating=2500,
                   title=FideTitle.GM,
                   pairing_no=1,
                   score=3,
                   float_status=FloatStatus.up,
                   opponents=(8, 5, 14, 3, 2),
                   colour_hist=(Colour.white, Colour.black, Colour.black,
                                Colour.white, Colour.black)),
            Player(name='Bruno',
                   rating=2500,
                   title=FideTitle.IM,
                   pairing_no=2,
                   score=3.5,
                   float_status=FloatStatus.down,
                   opponents=(9, 7, 5, 6, 1),
                   colour_hist=(Colour.black, Colour.white, Colour.white,
                                Colour.black, Colour.white)),
            Player(name='Carla',
                   rating=2400,
                   title=FideTitle.WGM,
                   pairing_no=3,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(10, 6, 4, 1, 7),
                   colour_hist=(Colour.white, Colour.black, Colour.white,
                                Colour.black, Colour.white)),
            Player(name='David',
                   rating=2400,
                   title=FideTitle.FM,
                   pairing_no=4,
                   score=2.5,
                   float_status=FloatStatus.upPrev,
                   opponents=(11, 9, 3, 5, 6),
                   colour_hist=(Colour.black, Colour.white, Colour.black,
                                Colour.white, Colour.white)),
            Player(name='Eloise',
                   rating=2350,
                   title=FideTitle.WIM,
                   pairing_no=5,
                   score=3,
                   float_status=FloatStatus.down,
                   opponents=(12, 1, 2, 4, 11),
                   colour_hist=(Colour.white, Colour.white, Colour.black,
                                Colour.black, Colour.white)),
            Player(name='Finn',
                   rating=2300,
                   title=FideTitle.FM,
                   pairing_no=6,
                   score=2.5,
                   float_status=FloatStatus.none,
                   opponents=(13, 3, 0, 2, 4),
                   colour_hist=(Colour.black, Colour.white, Colour.none,
                                Colour.white, Colour.black)),
            Player(name='Giorgia',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=7,
                   score=2,
                   float_status=FloatStatus.downPrev,
                   opponents=(14, 2, 10, 11, 3),
                   colour_hist=(Colour.white, Colour.black, Colour.white,
                                Colour.black, Colour.black)),
            Player(name='Kevin',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=8,
                   score=1,
                   float_status=FloatStatus.upPrev,
                   opponents=(1, 11, 12, 9, 13),
                   colour_hist=(Colour.black, Colour.white, Colour.black,
                                Colour.white, Colour.black)),
            Player(name='Louise',
                   rating=2150,
                   title=FideTitle.WIM,
                   pairing_no=9,
                   score=1.5,
                   float_status=FloatStatus.downPrev,
                   opponents=(2, 4, 13, 8, 10),
                   colour_hist=(Colour.white, Colour.black, Colour.white,
                                Colour.black, Colour.white)),
            Player(name='Mark',
                   rating=2150,
                   title=FideTitle.CM,
                   pairing_no=10,
                   score=1.5,
                   float_status=FloatStatus.none,
                   opponents=(3, 13, 7, 14, 9),
                   colour_hist=(Colour.black, Colour.white, Colour.black,
                                Colour.white, Colour.black)),
            Player(name='Nancy',
                   rating=2100,
                   title=FideTitle.WFM,
                   pairing_no=11,
                   score=2.5,
                   float_status=FloatStatus.up,
                   opponents=(4, 8, 0, 7, 5),
                   colour_hist=(Colour.white, Colour.black, Colour.none,
                                Colour.white, Colour.black)),
            Player(name='Oskar',
                   rating=2100,
                   title=0,
                   pairing_no=12,
                   score=0.5,
                   float_status=FloatStatus.up,
                   opponents=(5, 0, 8, 13, 14),
                   colour_hist=(Colour.black, Colour.none, Colour.white,
                                Colour.black, Colour.black)),
            Player(name='Patricia',
                   rating=2050,
                   title=0,
                   pairing_no=13,
                   score=1,
                   float_status=FloatStatus.upPrev,
                   opponents=(6, 10, 9, 12, 8),
                   colour_hist=(Colour.white, Colour.black, Colour.black,
                                Colour.white, Colour.white)),
            Player(name='Robert',
                   rating=2000,
                   title=0,
                   pairing_no=14,
                   score=1.5,
                   float_status=FloatStatus.down,
                   opponents=(7, 0, 1, 10, 12),
                   colour_hist=(Colour.black, Colour.none, Colour.white,
                                Colour.black, Colour.white))
        ]

        result_players = self.engine.pair_round(5, input_players)
        self.assertCountEqual(result_players, expected_players)
Esempio n. 4
0
class Test_SwissPairingEngine(unittest.TestCase):
    @staticmethod
    def select_top_seed_colour():
        return Colour.white

    def setUp(self):
        self.maxDiff = None
        self.engine = DutchPairingEngine(self.select_top_seed_colour)

    def test_pair_1st_round(self):
        input_players = (
            Player(name='Bruno',
                   rating=2500,
                   title=FideTitle.IM),
            Player(name='Alice',
                   rating=2500,
                   title=FideTitle.GM),
            Player(name='Carla',
                   rating=2400,
                   title=FideTitle.WGM),
            Player(name='Eloise',
                   rating=2350,
                   title=FideTitle.WIM),
            Player(name='Giorgia',
                   rating=2250,
                   title=FideTitle.FM),
            Player(name='Louise',
                   rating=2150,
                   title=FideTitle.WIM),
            Player(name='Nancy',
                   rating=2100,
                   title=FideTitle.WFM),
            Player(name='Patricia',
                   rating=2050,
                   title=0),
            Player(name='David',
                   rating=2400,
                   title=FideTitle.FM),
            Player(name='Finn',
                   rating=2300,
                   title=FideTitle.FM),
            Player(name='Kevin',
                   rating=2250,
                   title=FideTitle.FM),
            Player(name='Mark',
                   rating=2150,
                   title=FideTitle.CM),
            Player(name='Oskar',
                   rating=2100,
                   title=0),
            Player(name='Robert',
                   rating=2000,
                   title=0)
        )
        expected_players = [
            Player(name='Alice',
                   rating=2500,
                   title=FideTitle.GM,
                   pairing_no=1,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(8,),
                   colour_hist=(Colour.white,)),
            Player(name='Bruno',
                   rating=2500,
                   title=FideTitle.IM,
                   pairing_no=2,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(9,),
                   colour_hist=(Colour.black,)),
            Player(name='Carla',
                   rating=2400,
                   title=FideTitle.WGM,
                   pairing_no=3,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(10,),
                   colour_hist=(Colour.white,)),
            Player(name='David',
                   rating=2400,
                   title=FideTitle.FM,
                   pairing_no=4,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(11,),
                   colour_hist=(Colour.black,)),
            Player(name='Eloise',
                   rating=2350,
                   title=FideTitle.WIM,
                   pairing_no=5,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(12,),
                   colour_hist=(Colour.white,)),
            Player(name='Finn',
                   rating=2300,
                   title=FideTitle.FM,
                   pairing_no=6,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(13,),
                   colour_hist=(Colour.black,)),
            Player(name='Giorgia',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=7,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(14,),
                   colour_hist=(Colour.white,)),
            Player(name='Kevin',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=8,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(1,),
                   colour_hist=(Colour.black,)),
            Player(name='Louise',
                   rating=2150,
                   title=FideTitle.WIM,
                   pairing_no=9,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(2,),
                   colour_hist=(Colour.white,)),
            Player(name='Mark',
                   rating=2150,
                   title=FideTitle.CM,
                   pairing_no=10,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(3,),
                   colour_hist=(Colour.black,)),
            Player(name='Nancy',
                   rating=2100,
                   title=FideTitle.WFM,
                   pairing_no=11,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(4,),
                   colour_hist=(Colour.white,)),
            Player(name='Oskar',
                   rating=2100,
                   title=0,
                   pairing_no=12,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(5,),
                   colour_hist=(Colour.black,)),
            Player(name='Patricia',
                   rating=2050,
                   title=0,
                   pairing_no=13,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(6,),
                   colour_hist=(Colour.white,)),
            Player(name='Robert',
                   rating=2000,
                   title=0,
                   pairing_no=14,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(7,),
                   colour_hist=(Colour.black,))
        ]
        
        result_players = self.engine.pair_round(1, input_players)
        self.assertEqual(result_players, expected_players)
Esempio n. 5
0
    def execute(self, data):
        roundData = data.section['roundData']
        thisRound = roundData[data.round-1]

        if thisRound['status'] == RoundStatus.completed:
            raise tornado.web.HTTPError(403, 'Round {0} has been completed and cannot be paired again'.format(data.round))

        if any(rd['status'] == RoundStatus.paired for rd in roundData):
            raise tornado.web.HTTPError(403, 'Cannot pair another round until current round is completed')
        
        db = self._settings['db']
        dutch = DutchPairingEngine()
        bsonResults = None

        if data.round == 1:
            # First round: extract and prepare player data

            # Fetch tournament
            tournament = yield db.tournaments.find_one({ '_id': data.section['tournamentId'] })
            if not tournament:
                # TODO: Log error
                raise tornado.web.HTTPError(500)

            # Fetch players confirmed registered for section
            playerIds = data.section['confirmedPlayerIds']
            players = yield db.players.find({ '_id': { '$in': playerIds } }).to_list(None)
            if not players:
                # TODO: Log error
                raise tornado.web.HTTPError(500)

            # Create swissdutch players
            ratingType = tournament['ratingType']
            provisionalRating = data.section['provisionalRating']
            dutchPlayers = [self._create_basic_dutch_player(p, ratingType, provisionalRating) for p in players]

            # Pair round
            dutchResults = dutch.pair_round(data.round, dutchPlayers)

            # Convert results for storage
            bsonResults = [self._extract_dutch_result(r) for r in dutchResults]
        else:
            # Subsequent round: load player data
            playerData = data.section['playerData']
            dutchPlayers = [self._create_detailed_dutch_player(pd) for pd in playerData]
        
            # Pair round
            dutchResults = dutch.pair_round(data.round, dutchPlayers)

            # Convert results for storage
            bsonResults = [self._extract_dutch_result(r, self._find_previous_results(r, playerData)) for r in dutchResults]

        # Update section and save to DB
        data.section['playerData'] = bsonResults
        thisRound['status'] = RoundStatus.paired

        yield db.sections.update({ '_id': data.section['_id'] },
                                    { '$set': { 'roundData': roundData,
                                                'playerData': bsonResults } })

        # Return updated section
        return data.section
Esempio n. 6
0
 def setUp(self):
     self.maxDiff = None
     self.engine = DutchPairingEngine(self.select_top_seed_colour)
Esempio n. 7
0
 def setUp(self):
     self.maxDiff = None
     self.engine = DutchPairingEngine()
Esempio n. 8
0
class Test_DutchPairingEngine(unittest.TestCase):
    def setUp(self):
        self.maxDiff = None
        self.engine = DutchPairingEngine()

    def test_pair_2nd_round(self):
        input_players = (Player(name='Alice',
                                rating=2500,
                                title=FideTitle.GM,
                                pairing_no=1,
                                score=1,
                                float_status=FloatStatus.none,
                                opponents=(8, ),
                                colour_hist=(Colour.white, )),
                         Player(name='Bruno',
                                rating=2500,
                                title=FideTitle.IM,
                                pairing_no=2,
                                score=1,
                                float_status=FloatStatus.none,
                                opponents=(9, ),
                                colour_hist=(Colour.black, )),
                         Player(name='Carla',
                                rating=2400,
                                title=FideTitle.WGM,
                                pairing_no=3,
                                score=1,
                                float_status=FloatStatus.none,
                                opponents=(10, ),
                                colour_hist=(Colour.white, )),
                         Player(name='David',
                                rating=2400,
                                title=FideTitle.FM,
                                pairing_no=4,
                                score=0.5,
                                float_status=FloatStatus.none,
                                opponents=(11, ),
                                colour_hist=(Colour.black, )),
                         Player(name='Eloise',
                                rating=2350,
                                title=FideTitle.WIM,
                                pairing_no=5,
                                score=1,
                                float_status=FloatStatus.none,
                                opponents=(12, ),
                                colour_hist=(Colour.white, )),
                         Player(name='Finn',
                                rating=2300,
                                title=FideTitle.FM,
                                pairing_no=6,
                                score=1,
                                float_status=FloatStatus.none,
                                opponents=(13, ),
                                colour_hist=(Colour.black, )),
                         Player(name='Giorgia',
                                rating=2250,
                                title=FideTitle.FM,
                                pairing_no=7,
                                score=1,
                                float_status=FloatStatus.none,
                                opponents=(14, ),
                                colour_hist=(Colour.white, )),
                         Player(name='Kevin',
                                rating=2250,
                                title=FideTitle.FM,
                                pairing_no=8,
                                score=0,
                                float_status=FloatStatus.none,
                                opponents=(1, ),
                                colour_hist=(Colour.black, )),
                         Player(name='Louise',
                                rating=2150,
                                title=FideTitle.WIM,
                                pairing_no=9,
                                score=0,
                                float_status=FloatStatus.none,
                                opponents=(2, ),
                                colour_hist=(Colour.white, )),
                         Player(name='Mark',
                                rating=2150,
                                title=FideTitle.CM,
                                pairing_no=10,
                                score=0,
                                float_status=FloatStatus.none,
                                opponents=(3, ),
                                colour_hist=(Colour.black, )),
                         Player(name='Nancy',
                                rating=2100,
                                title=FideTitle.WFM,
                                pairing_no=11,
                                score=0.5,
                                float_status=FloatStatus.none,
                                opponents=(4, ),
                                colour_hist=(Colour.white, )),
                         Player(name='Patricia',
                                rating=2050,
                                title=0,
                                pairing_no=13,
                                score=0,
                                float_status=FloatStatus.none,
                                opponents=(6, ),
                                colour_hist=(Colour.white, )),
                         Player(name='Robert',
                                rating=2000,
                                title=0,
                                pairing_no=14,
                                score=0,
                                float_status=FloatStatus.none,
                                opponents=(7, ),
                                colour_hist=(Colour.black, )))
        expected_players = [
            Player(name='Alice',
                   rating=2500,
                   title=FideTitle.GM,
                   pairing_no=1,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(8, 5),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='Bruno',
                   rating=2500,
                   title=FideTitle.IM,
                   pairing_no=2,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(9, 7),
                   colour_hist=(Colour.black, Colour.white)),
            Player(name='Carla',
                   rating=2400,
                   title=FideTitle.WGM,
                   pairing_no=3,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(10, 6),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='David',
                   rating=2400,
                   title=FideTitle.FM,
                   pairing_no=4,
                   score=0.5,
                   float_status=FloatStatus.down,
                   opponents=(11, 9),
                   colour_hist=(Colour.black, Colour.white)),
            Player(name='Eloise',
                   rating=2350,
                   title=FideTitle.WIM,
                   pairing_no=5,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(12, 1),
                   colour_hist=(Colour.white, Colour.white)),
            Player(name='Finn',
                   rating=2300,
                   title=FideTitle.FM,
                   pairing_no=6,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(13, 3),
                   colour_hist=(Colour.black, Colour.white)),
            Player(name='Giorgia',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=7,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(14, 2),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='Kevin',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=8,
                   score=0,
                   float_status=FloatStatus.up,
                   opponents=(1, 11),
                   colour_hist=(Colour.black, Colour.white)),
            Player(name='Louise',
                   rating=2150,
                   title=FideTitle.WIM,
                   pairing_no=9,
                   score=0,
                   float_status=FloatStatus.up,
                   opponents=(2, 4),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='Mark',
                   rating=2150,
                   title=FideTitle.CM,
                   pairing_no=10,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(3, 13),
                   colour_hist=(Colour.black, Colour.white)),
            Player(name='Nancy',
                   rating=2100,
                   title=FideTitle.WFM,
                   pairing_no=11,
                   score=0.5,
                   float_status=FloatStatus.down,
                   opponents=(4, 8),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='Patricia',
                   rating=2050,
                   title=0,
                   pairing_no=13,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(6, 10),
                   colour_hist=(Colour.white, Colour.black)),
            Player(name='Robert',
                   rating=2000,
                   title=0,
                   pairing_no=14,
                   score=1,
                   float_status=FloatStatus.down,
                   opponents=(7, 0),
                   colour_hist=(Colour.black, Colour.none))
        ]

        result_players = self.engine.pair_round(2, input_players)
        self.assertCountEqual(result_players, expected_players)

    def test_pair_3rd_round(self):
        input_players = (Player(name='Alice',
                                rating=2500,
                                title=FideTitle.GM,
                                pairing_no=1,
                                score=1,
                                float_status=FloatStatus.none,
                                opponents=(8, 5),
                                colour_hist=(Colour.white, Colour.black)),
                         Player(name='Bruno',
                                rating=2500,
                                title=FideTitle.IM,
                                pairing_no=2,
                                score=2,
                                float_status=FloatStatus.none,
                                opponents=(9, 7),
                                colour_hist=(Colour.black, Colour.white)),
                         Player(name='Carla',
                                rating=2400,
                                title=FideTitle.WGM,
                                pairing_no=3,
                                score=1.5,
                                float_status=FloatStatus.none,
                                opponents=(10, 6),
                                colour_hist=(Colour.white, Colour.black)),
                         Player(name='David',
                                rating=2400,
                                title=FideTitle.FM,
                                pairing_no=4,
                                score=1.5,
                                float_status=FloatStatus.down,
                                opponents=(11, 9),
                                colour_hist=(Colour.black, Colour.white)),
                         Player(name='Eloise',
                                rating=2350,
                                title=FideTitle.WIM,
                                pairing_no=5,
                                score=2,
                                float_status=FloatStatus.none,
                                opponents=(12, 1),
                                colour_hist=(Colour.white, Colour.white)),
                         Player(name='Finn',
                                rating=2300,
                                title=FideTitle.FM,
                                pairing_no=6,
                                score=1.5,
                                float_status=FloatStatus.none,
                                opponents=(13, 3),
                                colour_hist=(Colour.black, Colour.white)),
                         Player(name='Giorgia',
                                rating=2250,
                                title=FideTitle.FM,
                                pairing_no=7,
                                score=1,
                                float_status=FloatStatus.none,
                                opponents=(14, 2),
                                colour_hist=(Colour.white, Colour.black)),
                         Player(name='Kevin',
                                rating=2250,
                                title=FideTitle.FM,
                                pairing_no=8,
                                score=0,
                                float_status=FloatStatus.up,
                                opponents=(1, 11),
                                colour_hist=(Colour.black, Colour.white)),
                         Player(name='Louise',
                                rating=2150,
                                title=FideTitle.WIM,
                                pairing_no=9,
                                score=0,
                                float_status=FloatStatus.up,
                                opponents=(2, 4),
                                colour_hist=(Colour.white, Colour.black)),
                         Player(name='Mark',
                                rating=2150,
                                title=FideTitle.CM,
                                pairing_no=10,
                                score=1,
                                float_status=FloatStatus.none,
                                opponents=(3, 13),
                                colour_hist=(Colour.black, Colour.white)),
                         Player(name='Nancy',
                                rating=2100,
                                title=FideTitle.WFM,
                                pairing_no=11,
                                score=1.5,
                                float_status=FloatStatus.down,
                                opponents=(4, 8),
                                colour_hist=(Colour.white, Colour.black)),
                         Player(name='Oskar',
                                rating=2100,
                                title=0,
                                pairing_no=12,
                                score=0,
                                float_status=FloatStatus.none,
                                opponents=(5, 0),
                                colour_hist=(Colour.black, Colour.none)),
                         Player(name='Patricia',
                                rating=2050,
                                title=0,
                                pairing_no=13,
                                score=0,
                                float_status=FloatStatus.none,
                                opponents=(6, 10),
                                colour_hist=(Colour.white, Colour.black)),
                         Player(name='Robert',
                                rating=2000,
                                title=0,
                                pairing_no=14,
                                score=1,
                                float_status=FloatStatus.down,
                                opponents=(7, 0),
                                colour_hist=(Colour.black, Colour.none)))
        expected_players = [
            Player(name='Alice',
                   rating=2500,
                   title=FideTitle.GM,
                   pairing_no=1,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(8, 5, 14),
                   colour_hist=(Colour.white, Colour.black, Colour.black)),
            Player(name='Bruno',
                   rating=2500,
                   title=FideTitle.IM,
                   pairing_no=2,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(9, 7, 5),
                   colour_hist=(Colour.black, Colour.white, Colour.white)),
            Player(name='Carla',
                   rating=2400,
                   title=FideTitle.WGM,
                   pairing_no=3,
                   score=1.5,
                   float_status=FloatStatus.none,
                   opponents=(10, 6, 4),
                   colour_hist=(Colour.white, Colour.black, Colour.white)),
            Player(name='David',
                   rating=2400,
                   title=FideTitle.FM,
                   pairing_no=4,
                   score=1.5,
                   float_status=FloatStatus.downPrev,
                   opponents=(11, 9, 3),
                   colour_hist=(Colour.black, Colour.white, Colour.black)),
            Player(name='Eloise',
                   rating=2350,
                   title=FideTitle.WIM,
                   pairing_no=5,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(12, 1, 2),
                   colour_hist=(Colour.white, Colour.white, Colour.black)),
            Player(name='Finn',
                   rating=2300,
                   title=FideTitle.FM,
                   pairing_no=6,
                   score=1.5,
                   float_status=FloatStatus.none,
                   opponents=(13, 3, 11),
                   colour_hist=(Colour.black, Colour.white, Colour.black)),
            Player(name='Giorgia',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=7,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(14, 2, 10),
                   colour_hist=(Colour.white, Colour.black, Colour.white)),
            Player(name='Kevin',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=8,
                   score=0,
                   float_status=FloatStatus.upPrev,
                   opponents=(1, 11, 12),
                   colour_hist=(Colour.black, Colour.white, Colour.black)),
            Player(name='Louise',
                   rating=2150,
                   title=FideTitle.WIM,
                   pairing_no=9,
                   score=0,
                   float_status=FloatStatus.upPrev,
                   opponents=(2, 4, 13),
                   colour_hist=(Colour.white, Colour.black, Colour.white)),
            Player(name='Mark',
                   rating=2150,
                   title=FideTitle.CM,
                   pairing_no=10,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(3, 13, 7),
                   colour_hist=(Colour.black, Colour.white, Colour.black)),
            Player(name='Nancy',
                   rating=2100,
                   title=FideTitle.WFM,
                   pairing_no=11,
                   score=1.5,
                   float_status=FloatStatus.downPrev,
                   opponents=(4, 8, 6),
                   colour_hist=(Colour.white, Colour.black, Colour.white)),
            Player(name='Oskar',
                   rating=2100,
                   title=0,
                   pairing_no=12,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(5, 0, 8),
                   colour_hist=(Colour.black, Colour.none, Colour.white)),
            Player(name='Patricia',
                   rating=2050,
                   title=0,
                   pairing_no=13,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(6, 10, 9),
                   colour_hist=(Colour.white, Colour.black, Colour.black)),
            Player(name='Robert',
                   rating=2000,
                   title=0,
                   pairing_no=14,
                   score=1,
                   float_status=FloatStatus.downPrev,
                   opponents=(7, 0, 1),
                   colour_hist=(Colour.black, Colour.none, Colour.white))
        ]

        result_players = self.engine.pair_round(3, input_players)
        self.assertCountEqual(result_players, expected_players)

    def test_pair_4th_round(self):
        input_players = (
            Player(name='Alice',
                   rating=2500,
                   title=FideTitle.GM,
                   pairing_no=1,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(8, 5, 14),
                   colour_hist=(Colour.white, Colour.black, Colour.black)),
            Player(name='Bruno',
                   rating=2500,
                   title=FideTitle.IM,
                   pairing_no=2,
                   score=2.5,
                   float_status=FloatStatus.none,
                   opponents=(9, 7, 5),
                   colour_hist=(Colour.black, Colour.white, Colour.white)),
            Player(name='Carla',
                   rating=2400,
                   title=FideTitle.WGM,
                   pairing_no=3,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(10, 6, 4),
                   colour_hist=(Colour.white, Colour.black, Colour.white)),
            Player(name='David',
                   rating=2400,
                   title=FideTitle.FM,
                   pairing_no=4,
                   score=2,
                   float_status=FloatStatus.downPrev,
                   opponents=(11, 9, 3),
                   colour_hist=(Colour.black, Colour.white, Colour.black)),
            Player(name='Eloise',
                   rating=2350,
                   title=FideTitle.WIM,
                   pairing_no=5,
                   score=2.5,
                   float_status=FloatStatus.none,
                   opponents=(12, 1, 2),
                   colour_hist=(Colour.white, Colour.white, Colour.black)),
            Player(name='Finn',
                   rating=2300,
                   title=FideTitle.FM,
                   pairing_no=6,
                   score=2.5,
                   float_status=FloatStatus.down,
                   opponents=(13, 3, 0),
                   colour_hist=(Colour.black, Colour.white, Colour.none)),
            Player(name='Giorgia',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=7,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(14, 2, 10),
                   colour_hist=(Colour.white, Colour.black, Colour.white)),
            Player(name='Kevin',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=8,
                   score=0.5,
                   float_status=FloatStatus.upPrev,
                   opponents=(1, 11, 12),
                   colour_hist=(Colour.black, Colour.white, Colour.black)),
            Player(name='Louise',
                   rating=2150,
                   title=FideTitle.WIM,
                   pairing_no=9,
                   score=1,
                   float_status=FloatStatus.upPrev,
                   opponents=(2, 4, 13),
                   colour_hist=(Colour.white, Colour.black, Colour.white)),
            Player(name='Mark',
                   rating=2150,
                   title=FideTitle.CM,
                   pairing_no=10,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(3, 13, 7),
                   colour_hist=(Colour.black, Colour.white, Colour.black)),
            Player(name='Nancy',
                   rating=2100,
                   title=FideTitle.WFM,
                   pairing_no=11,
                   score=1.5,
                   float_status=FloatStatus.downPrev,
                   opponents=(4, 8, 0),
                   colour_hist=(Colour.white, Colour.black, Colour.none)),
            Player(name='Oskar',
                   rating=2100,
                   title=0,
                   pairing_no=12,
                   score=0.5,
                   float_status=FloatStatus.none,
                   opponents=(5, 0, 8),
                   colour_hist=(Colour.black, Colour.none, Colour.white)),
            Player(name='Patricia',
                   rating=2050,
                   title=0,
                   pairing_no=13,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(6, 10, 9),
                   colour_hist=(Colour.white, Colour.black, Colour.black)),
            Player(name='Robert',
                   rating=2000,
                   title=0,
                   pairing_no=14,
                   score=1,
                   float_status=FloatStatus.downPrev,
                   opponents=(7, 0, 1),
                   colour_hist=(Colour.black, Colour.none, Colour.white)))
        expected_players = [
            Player(name='Alice',
                   rating=2500,
                   title=FideTitle.GM,
                   pairing_no=1,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(8, 5, 14, 3),
                   colour_hist=(Colour.white, Colour.black, Colour.black,
                                Colour.white)),
            Player(name='Bruno',
                   rating=2500,
                   title=FideTitle.IM,
                   pairing_no=2,
                   score=2.5,
                   float_status=FloatStatus.none,
                   opponents=(9, 7, 5, 6),
                   colour_hist=(Colour.black, Colour.white, Colour.white,
                                Colour.black)),
            Player(name='Carla',
                   rating=2400,
                   title=FideTitle.WGM,
                   pairing_no=3,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(10, 6, 4, 1),
                   colour_hist=(Colour.white, Colour.black, Colour.white,
                                Colour.black)),
            Player(name='David',
                   rating=2400,
                   title=FideTitle.FM,
                   pairing_no=4,
                   score=2,
                   float_status=FloatStatus.up,
                   opponents=(11, 9, 3, 5),
                   colour_hist=(Colour.black, Colour.white, Colour.black,
                                Colour.white)),
            Player(name='Eloise',
                   rating=2350,
                   title=FideTitle.WIM,
                   pairing_no=5,
                   score=2.5,
                   float_status=FloatStatus.down,
                   opponents=(12, 1, 2, 4),
                   colour_hist=(Colour.white, Colour.white, Colour.black,
                                Colour.black)),
            Player(name='Finn',
                   rating=2300,
                   title=FideTitle.FM,
                   pairing_no=6,
                   score=2.5,
                   float_status=FloatStatus.downPrev,
                   opponents=(13, 3, 0, 2),
                   colour_hist=(Colour.black, Colour.white, Colour.none,
                                Colour.white)),
            Player(name='Giorgia',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=7,
                   score=2,
                   float_status=FloatStatus.down,
                   opponents=(14, 2, 10, 11),
                   colour_hist=(Colour.white, Colour.black, Colour.white,
                                Colour.black)),
            Player(name='Kevin',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=8,
                   score=0.5,
                   float_status=FloatStatus.up,
                   opponents=(1, 11, 12, 9),
                   colour_hist=(Colour.black, Colour.white, Colour.black,
                                Colour.white)),
            Player(name='Louise',
                   rating=2150,
                   title=FideTitle.WIM,
                   pairing_no=9,
                   score=1,
                   float_status=FloatStatus.down,
                   opponents=(2, 4, 13, 8),
                   colour_hist=(Colour.white, Colour.black, Colour.white,
                                Colour.black)),
            Player(name='Mark',
                   rating=2150,
                   title=FideTitle.CM,
                   pairing_no=10,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(3, 13, 7, 14),
                   colour_hist=(Colour.black, Colour.white, Colour.black,
                                Colour.white)),
            Player(name='Nancy',
                   rating=2100,
                   title=FideTitle.WFM,
                   pairing_no=11,
                   score=1.5,
                   float_status=FloatStatus.up,
                   opponents=(4, 8, 0, 7),
                   colour_hist=(Colour.white, Colour.black, Colour.none,
                                Colour.white)),
            Player(name='Oskar',
                   rating=2100,
                   title=0,
                   pairing_no=12,
                   score=0.5,
                   float_status=FloatStatus.down,
                   opponents=(5, 0, 8, 13),
                   colour_hist=(Colour.black, Colour.none, Colour.white,
                                Colour.black)),
            Player(name='Patricia',
                   rating=2050,
                   title=0,
                   pairing_no=13,
                   score=0,
                   float_status=FloatStatus.up,
                   opponents=(6, 10, 9, 12),
                   colour_hist=(Colour.white, Colour.black, Colour.black,
                                Colour.white)),
            Player(name='Robert',
                   rating=2000,
                   title=0,
                   pairing_no=14,
                   score=1,
                   float_status=FloatStatus.none,
                   opponents=(7, 0, 1, 10),
                   colour_hist=(Colour.black, Colour.none, Colour.white,
                                Colour.black))
        ]

        result_players = self.engine.pair_round(4, input_players)
        self.assertCountEqual(result_players, expected_players)

    def test_pair_5th_round(self):
        input_players = (Player(name='Alice',
                                rating=2500,
                                title=FideTitle.GM,
                                pairing_no=1,
                                score=3,
                                float_status=FloatStatus.none,
                                opponents=(8, 5, 14, 3),
                                colour_hist=(Colour.white, Colour.black,
                                             Colour.black, Colour.white)),
                         Player(name='Bruno',
                                rating=2500,
                                title=FideTitle.IM,
                                pairing_no=2,
                                score=3.5,
                                float_status=FloatStatus.none,
                                opponents=(9, 7, 5, 6),
                                colour_hist=(Colour.black, Colour.white,
                                             Colour.white, Colour.black)),
                         Player(name='Carla',
                                rating=2400,
                                title=FideTitle.WGM,
                                pairing_no=3,
                                score=2,
                                float_status=FloatStatus.none,
                                opponents=(10, 6, 4, 1),
                                colour_hist=(Colour.white, Colour.black,
                                             Colour.white, Colour.black)),
                         Player(name='David',
                                rating=2400,
                                title=FideTitle.FM,
                                pairing_no=4,
                                score=2.5,
                                float_status=FloatStatus.up,
                                opponents=(11, 9, 3, 5),
                                colour_hist=(Colour.black, Colour.white,
                                             Colour.black, Colour.white)),
                         Player(name='Eloise',
                                rating=2350,
                                title=FideTitle.WIM,
                                pairing_no=5,
                                score=3,
                                float_status=FloatStatus.down,
                                opponents=(12, 1, 2, 4),
                                colour_hist=(Colour.white, Colour.white,
                                             Colour.black, Colour.black)),
                         Player(name='Finn',
                                rating=2300,
                                title=FideTitle.FM,
                                pairing_no=6,
                                score=2.5,
                                float_status=FloatStatus.downPrev,
                                opponents=(13, 3, 0, 2),
                                colour_hist=(Colour.black, Colour.white,
                                             Colour.none, Colour.white)),
                         Player(name='Giorgia',
                                rating=2250,
                                title=FideTitle.FM,
                                pairing_no=7,
                                score=2,
                                float_status=FloatStatus.down,
                                opponents=(14, 2, 10, 11),
                                colour_hist=(Colour.white, Colour.black,
                                             Colour.white, Colour.black)),
                         Player(name='Kevin',
                                rating=2250,
                                title=FideTitle.FM,
                                pairing_no=8,
                                score=1,
                                float_status=FloatStatus.up,
                                opponents=(1, 11, 12, 9),
                                colour_hist=(Colour.black, Colour.white,
                                             Colour.black, Colour.white)),
                         Player(name='Louise',
                                rating=2150,
                                title=FideTitle.WIM,
                                pairing_no=9,
                                score=1.5,
                                float_status=FloatStatus.down,
                                opponents=(2, 4, 13, 8),
                                colour_hist=(Colour.white, Colour.black,
                                             Colour.white, Colour.black)),
                         Player(name='Mark',
                                rating=2150,
                                title=FideTitle.CM,
                                pairing_no=10,
                                score=1.5,
                                float_status=FloatStatus.none,
                                opponents=(3, 13, 7, 14),
                                colour_hist=(Colour.black, Colour.white,
                                             Colour.black, Colour.white)),
                         Player(name='Nancy',
                                rating=2100,
                                title=FideTitle.WFM,
                                pairing_no=11,
                                score=2.5,
                                float_status=FloatStatus.up,
                                opponents=(4, 8, 0, 7),
                                colour_hist=(Colour.white, Colour.black,
                                             Colour.none, Colour.white)),
                         Player(name='Oskar',
                                rating=2100,
                                title=0,
                                pairing_no=12,
                                score=0.5,
                                float_status=FloatStatus.down,
                                opponents=(5, 0, 8, 13),
                                colour_hist=(Colour.black, Colour.none,
                                             Colour.white, Colour.black)),
                         Player(name='Patricia',
                                rating=2050,
                                title=0,
                                pairing_no=13,
                                score=1,
                                float_status=FloatStatus.up,
                                opponents=(6, 10, 9, 12),
                                colour_hist=(Colour.white, Colour.black,
                                             Colour.black, Colour.white)),
                         Player(name='Robert',
                                rating=2000,
                                title=0,
                                pairing_no=14,
                                score=1.5,
                                float_status=FloatStatus.none,
                                opponents=(7, 0, 1, 10),
                                colour_hist=(Colour.black, Colour.none,
                                             Colour.white, Colour.black)))
        expected_players = [
            Player(name='Alice',
                   rating=2500,
                   title=FideTitle.GM,
                   pairing_no=1,
                   score=3,
                   float_status=FloatStatus.up,
                   opponents=(8, 5, 14, 3, 2),
                   colour_hist=(Colour.white, Colour.black, Colour.black,
                                Colour.white, Colour.black)),
            Player(name='Bruno',
                   rating=2500,
                   title=FideTitle.IM,
                   pairing_no=2,
                   score=3.5,
                   float_status=FloatStatus.down,
                   opponents=(9, 7, 5, 6, 1),
                   colour_hist=(Colour.black, Colour.white, Colour.white,
                                Colour.black, Colour.white)),
            Player(name='Carla',
                   rating=2400,
                   title=FideTitle.WGM,
                   pairing_no=3,
                   score=2,
                   float_status=FloatStatus.none,
                   opponents=(10, 6, 4, 1, 7),
                   colour_hist=(Colour.white, Colour.black, Colour.white,
                                Colour.black, Colour.white)),
            Player(name='David',
                   rating=2400,
                   title=FideTitle.FM,
                   pairing_no=4,
                   score=2.5,
                   float_status=FloatStatus.upPrev,
                   opponents=(11, 9, 3, 5, 6),
                   colour_hist=(Colour.black, Colour.white, Colour.black,
                                Colour.white, Colour.white)),
            Player(name='Eloise',
                   rating=2350,
                   title=FideTitle.WIM,
                   pairing_no=5,
                   score=3,
                   float_status=FloatStatus.down,
                   opponents=(12, 1, 2, 4, 11),
                   colour_hist=(Colour.white, Colour.white, Colour.black,
                                Colour.black, Colour.white)),
            Player(name='Finn',
                   rating=2300,
                   title=FideTitle.FM,
                   pairing_no=6,
                   score=2.5,
                   float_status=FloatStatus.none,
                   opponents=(13, 3, 0, 2, 4),
                   colour_hist=(Colour.black, Colour.white, Colour.none,
                                Colour.white, Colour.black)),
            Player(name='Giorgia',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=7,
                   score=2,
                   float_status=FloatStatus.downPrev,
                   opponents=(14, 2, 10, 11, 3),
                   colour_hist=(Colour.white, Colour.black, Colour.white,
                                Colour.black, Colour.black)),
            Player(name='Kevin',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=8,
                   score=1,
                   float_status=FloatStatus.upPrev,
                   opponents=(1, 11, 12, 9, 13),
                   colour_hist=(Colour.black, Colour.white, Colour.black,
                                Colour.white, Colour.black)),
            Player(name='Louise',
                   rating=2150,
                   title=FideTitle.WIM,
                   pairing_no=9,
                   score=1.5,
                   float_status=FloatStatus.downPrev,
                   opponents=(2, 4, 13, 8, 10),
                   colour_hist=(Colour.white, Colour.black, Colour.white,
                                Colour.black, Colour.white)),
            Player(name='Mark',
                   rating=2150,
                   title=FideTitle.CM,
                   pairing_no=10,
                   score=1.5,
                   float_status=FloatStatus.none,
                   opponents=(3, 13, 7, 14, 9),
                   colour_hist=(Colour.black, Colour.white, Colour.black,
                                Colour.white, Colour.black)),
            Player(name='Nancy',
                   rating=2100,
                   title=FideTitle.WFM,
                   pairing_no=11,
                   score=2.5,
                   float_status=FloatStatus.up,
                   opponents=(4, 8, 0, 7, 5),
                   colour_hist=(Colour.white, Colour.black, Colour.none,
                                Colour.white, Colour.black)),
            Player(name='Oskar',
                   rating=2100,
                   title=0,
                   pairing_no=12,
                   score=0.5,
                   float_status=FloatStatus.up,
                   opponents=(5, 0, 8, 13, 14),
                   colour_hist=(Colour.black, Colour.none, Colour.white,
                                Colour.black, Colour.black)),
            Player(name='Patricia',
                   rating=2050,
                   title=0,
                   pairing_no=13,
                   score=1,
                   float_status=FloatStatus.upPrev,
                   opponents=(6, 10, 9, 12, 8),
                   colour_hist=(Colour.white, Colour.black, Colour.black,
                                Colour.white, Colour.white)),
            Player(name='Robert',
                   rating=2000,
                   title=0,
                   pairing_no=14,
                   score=1.5,
                   float_status=FloatStatus.down,
                   opponents=(7, 0, 1, 10, 12),
                   colour_hist=(Colour.black, Colour.none, Colour.white,
                                Colour.black, Colour.white))
        ]

        result_players = self.engine.pair_round(5, input_players)
        self.assertCountEqual(result_players, expected_players)
Esempio n. 9
0
class Test_SwissPairingEngine(unittest.TestCase):
    @staticmethod
    def select_top_seed_colour():
        return Colour.white

    def setUp(self):
        self.maxDiff = None
        self.engine = DutchPairingEngine(self.select_top_seed_colour)

    def test_pair_1st_round(self):
        input_players = (Player(name='Bruno', rating=2500, title=FideTitle.IM),
                         Player(name='Alice', rating=2500, title=FideTitle.GM),
                         Player(name='Carla', rating=2400,
                                title=FideTitle.WGM),
                         Player(name='Eloise',
                                rating=2350,
                                title=FideTitle.WIM),
                         Player(name='Giorgia',
                                rating=2250,
                                title=FideTitle.FM),
                         Player(name='Louise',
                                rating=2150,
                                title=FideTitle.WIM),
                         Player(name='Nancy', rating=2100,
                                title=FideTitle.WFM),
                         Player(name='Patricia', rating=2050, title=0),
                         Player(name='David', rating=2400, title=FideTitle.FM),
                         Player(name='Finn', rating=2300, title=FideTitle.FM),
                         Player(name='Kevin', rating=2250, title=FideTitle.FM),
                         Player(name='Mark', rating=2150, title=FideTitle.CM),
                         Player(name='Oskar', rating=2100, title=0),
                         Player(name='Robert', rating=2000, title=0))
        expected_players = [
            Player(name='Alice',
                   rating=2500,
                   title=FideTitle.GM,
                   pairing_no=1,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(8, ),
                   colour_hist=(Colour.white, )),
            Player(name='Bruno',
                   rating=2500,
                   title=FideTitle.IM,
                   pairing_no=2,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(9, ),
                   colour_hist=(Colour.black, )),
            Player(name='Carla',
                   rating=2400,
                   title=FideTitle.WGM,
                   pairing_no=3,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(10, ),
                   colour_hist=(Colour.white, )),
            Player(name='David',
                   rating=2400,
                   title=FideTitle.FM,
                   pairing_no=4,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(11, ),
                   colour_hist=(Colour.black, )),
            Player(name='Eloise',
                   rating=2350,
                   title=FideTitle.WIM,
                   pairing_no=5,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(12, ),
                   colour_hist=(Colour.white, )),
            Player(name='Finn',
                   rating=2300,
                   title=FideTitle.FM,
                   pairing_no=6,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(13, ),
                   colour_hist=(Colour.black, )),
            Player(name='Giorgia',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=7,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(14, ),
                   colour_hist=(Colour.white, )),
            Player(name='Kevin',
                   rating=2250,
                   title=FideTitle.FM,
                   pairing_no=8,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(1, ),
                   colour_hist=(Colour.black, )),
            Player(name='Louise',
                   rating=2150,
                   title=FideTitle.WIM,
                   pairing_no=9,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(2, ),
                   colour_hist=(Colour.white, )),
            Player(name='Mark',
                   rating=2150,
                   title=FideTitle.CM,
                   pairing_no=10,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(3, ),
                   colour_hist=(Colour.black, )),
            Player(name='Nancy',
                   rating=2100,
                   title=FideTitle.WFM,
                   pairing_no=11,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(4, ),
                   colour_hist=(Colour.white, )),
            Player(name='Oskar',
                   rating=2100,
                   title=0,
                   pairing_no=12,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(5, ),
                   colour_hist=(Colour.black, )),
            Player(name='Patricia',
                   rating=2050,
                   title=0,
                   pairing_no=13,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(6, ),
                   colour_hist=(Colour.white, )),
            Player(name='Robert',
                   rating=2000,
                   title=0,
                   pairing_no=14,
                   score=0,
                   float_status=FloatStatus.none,
                   opponents=(7, ),
                   colour_hist=(Colour.black, ))
        ]

        result_players = self.engine.pair_round(1, input_players)
        self.assertEqual(result_players, expected_players)
Esempio n. 10
0
 def setUp(self):
     self.maxDiff = None
     self.engine = DutchPairingEngine(self.select_top_seed_colour)