def test_unique_id_copied(self): test_board = ProductGameBoard(AbstractTranspositionTable()) test_board.make_move(ProductGameMove(1, 1)) self.assertEqual(test_board.unique_id_int(), test_board.unique_id_faster) copied_board = test_board.copy_board() self.assertEqual(copied_board.unique_id_faster, test_board.unique_id_faster) self.assertEqual(copied_board.unique_id_int(), test_board.unique_id_int()) self.assertEqual(copied_board.unique_id_int(), copied_board.unique_id_faster) new_board = test_board.new_board_from_move(ProductGameMove(1, 2)) self.assertEqual(new_board.unique_id_int(), new_board.unique_id_faster)
def test_unique_id_negative_signflip(self): test_board = ProductGameBoard(AbstractTranspositionTable()) test_board.squares = numpy.array([[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 2, 2, 1, 1, 0], [0, 0, 2, 0, 1, 0], [0, 2, 0, 2, 2, 0], [0, 0, 0, 1, 1, 2]]) test_board.bottomFactor = 9 test_board.topFactor = 9 self.assertFalse(test_board.unique_id_int() < 0)
def test_unique_id_int_harder(self): test_board = ProductGameBoard(AbstractTranspositionTable()) test_board.make_move(ProductGameMove(3, 6)) #that's i=2 j=2, flat 14 test_board.make_move(ProductGameMove(6, 6)) #that's i=4 j=0, flat 24 self.assertEqual((NegamarkBoard.X * 3 ** (4 + 14)) + (NegamarkBoard.O * 3 ** (4 + 24)) + (9 * (6 - 1)) + (6 - 1), test_board.unique_id_int()) self.assertEqual(test_board.unique_id_int(), test_board.unique_id_faster)
def test_unique_id_faster(self): test_board = ProductGameBoard(AbstractTranspositionTable()) test_board.make_move(ProductGameMove(6, 3)) test_board.make_move(ProductGameMove(7, 3)) test_board.make_move(ProductGameMove(7, 4)) test_board.make_move(ProductGameMove(8, 4)) test_board.make_move(ProductGameMove(8, 6)) test_board.make_move(ProductGameMove(7, 6)) test_board.make_move(ProductGameMove(5, 6)) test_board.make_move(ProductGameMove(6, 6)) self.assertEqual(test_board.unique_id_int(), test_board.unique_id_faster)
def test_unique_id_negative(self): test_board = ProductGameBoard(AbstractTranspositionTable()) test_board.bottomFactor = 9 test_board.topFactor = 9 self.assertEqual(80, test_board.unique_id_int())
def test_unique_id_int(self): test_board = ProductGameBoard(AbstractTranspositionTable()) test_board.make_move(ProductGameMove(3, 6)) #that's i=2 j=2, flat 14 self.assertEqual((NegamarkBoard.X * 3 ** (4 + 14)) + (9 * 2) + 5, test_board.unique_id_int())