Пример #1
0
 def test_mass_play(self):
     for i in range(1000):
         board = Board(size=7, win_chain_length=4)
         board.make_random_move()
         if board.game_over():
             self.assertTrue(board.game_won() or board.game_assume_drawn())
         if board.game_assume_drawn():
             self.assertTrue(board.game_over())
Пример #2
0
    def test_board_equivalence(self):
        size = 9
        cache = BitBoardCache("../cache/9-magics", size=9, win_chain_length=5, force_build_win_checks=False)
        bitboard = BitBoard(cache, size=9, win_chain_length=5)

        normal_board = Board(size=9, win_chain_length=5)

        fboard_1 = FeatureBoard_v1_1(bitboard)
        fboard_2 = FeatureBoard_v1_1(normal_board)

        for i in range(1000):
            if np.random.rand() < 0.5:
                normal_board.make_random_move()
                bitboard.move(normal_board.get_last_move())
                if normal_board.game_over():
                    break
                fboard_1.move(normal_board.get_last_move())
                fboard_2.move(normal_board.get_last_move())
            elif normal_board.get_last_move():
                normal_board.unmove()
                bitboard.unmove()
                fboard_1.unmove()
                fboard_2.unmove()
            self.verify_sync(normal_board, fboard_2)
            self.verify_sync(bitboard, fboard_1)