Esempio n. 1
0
 def test_large_boards(self):
     board1 = self.board.copy()
     board1[0:3, 0:3] = self.left
     board2 = self.board.copy()
     board2[0:3, 0:3] = self.right
     board3 = self.board.copy()
     board3[0:3, 3:6] = self.left + 3
     board4 = self.board.copy()
     board4[0:3, 3:6] = self.right + 3
     board5 = self.board.copy()
     board5[3:6, 0:3] = self.left + 18
     board6 = self.board.copy()
     board6[3:6, 0:3] = self.right + 18
     board7 = self.board.copy()
     board7[3:6, 3:6] = self.left + 21
     board8 = self.board.copy()
     board8[3:6, 3:6] = self.right + 21
     expected_board = np.vstack((board1.ravel(), board2.ravel(), board3.ravel(), board4.ravel(), \
         board5.ravel(), board6.ravel(), board7.ravel(), board8.ravel())).T
     temp_board = np.ones(
         (1, 8), dtype=int) * np.expand_dims(self.board.ravel(), axis=1)
     quad_dirs = [(1, -1), (1, 1), (2, -1), (2, 1), (3, -1), (3, 1),
                  (4, -1), (4, 1)]
     for (ix, (quad, dir_)) in enumerate(quad_dirs):
         temp = temp_board.copy()
         pentago.rotate_board(temp, quadrant=quad, direction=dir_)
         np.testing.assert_array_equal(
             temp[:, ix], expected_board[:, ix],
             'Quad {}, Dir {}, ix {}'.format(quad, dir_, ix))
Esempio n. 2
0
 def test_not_inplace(self):
     expected_board = self.board.copy()
     expected_board[0:3, 0:3] = self.left
     temp1 = np.expand_dims(self.board.ravel(), axis=1)
     temp2 = self.board.copy().ravel()
     new_board = pentago.rotate_board(temp1,
                                      quadrant=1,
                                      direction=-1,
                                      inplace=False)
     np.testing.assert_array_equal(np.reshape(new_board, (6, 6)),
                                   expected_board)
     np.testing.assert_array_equal(temp1, temp2[:, np.newaxis])
Esempio n. 3
0
 def test_q4_dr(self):
     expected_board = self.board.copy()
     expected_board[3:6, 3:6] = self.right + 21
     pentago.rotate_board(self.board, quadrant=4, direction=1)
     np.testing.assert_array_equal(self.board, expected_board)
Esempio n. 4
0
 def test_q3_dl(self):
     expected_board = self.board.copy()
     expected_board[3:6, 0:3] = self.left + 18
     pentago.rotate_board(self.board, quadrant=3, direction=-1)
     np.testing.assert_array_equal(self.board, expected_board)
Esempio n. 5
0
 def test_q2_dl(self):
     expected_board = self.board.copy()
     expected_board[0:3, 3:6] = self.left + 3
     pentago.rotate_board(self.board, quadrant=2, direction=-1)
     np.testing.assert_array_equal(self.board, expected_board)
Esempio n. 6
0
 def test_q1_dr(self):
     expected_board = self.board.copy()
     expected_board[0:3, 0:3] = self.right
     pentago.rotate_board(self.board, quadrant=1, direction=1)
     np.testing.assert_array_equal(self.board, expected_board)
Esempio n. 7
0
 def test_bad_not_inplace(self):
     with self.assertRaises(AssertionError):
         pentago.rotate_board(self.board,
                              quadrant=1,
                              direction=-1,
                              inplace=False)