示例#1
0
 def test_place_to_win(self):
     self.board[2, 0:3] = w
     self.board[1, 3] = w
     self.white_moves.append(pentago.Move(0, 3, 2, -1, 5))
     (white_moves, black_moves) = pentago.find_moves(self.board)
     np.testing.assert_array_equal(white_moves, self.white_moves)
     np.testing.assert_array_equal(black_moves, self.black_moves)
示例#2
0
 def test_place_to_win_x6(self):
     self.board[0, 0] = w
     self.board[1, 1] = w
     self.board[3, 3] = w
     self.board[4, 4] = w
     self.board[5, 5] = w
     self.board[0, 2] = b
     self.board[2, 0] = b
     self.white_moves.append(pentago.Move(2, 2, 2, -1, 5))
     self.white_moves.append(pentago.Move(2, 2, 2, 1, 5))
     self.white_moves.append(pentago.Move(2, 2, 3, -1, 5))
     self.white_moves.append(pentago.Move(2, 2, 3, 1, 5))
     (white_moves, black_moves) = pentago.find_moves(self.board)
     np.testing.assert_array_equal(white_moves, self.white_moves)
     np.testing.assert_array_equal(black_moves, self.black_moves)
示例#3
0
 def test_rotate_to_win(self):
     self.board[3, 1] = w
     self.board[4, 1] = w
     self.board[4, 3:6] = w
     for i in range(6):
         for j in range(6):
             if self.board[i, j] == pentago.PLAYER['none']:
                 self.white_moves.append(pentago.Move(i, j, 3, 1, 5))
     self.white_moves.append(pentago.Move(4, 2, 1, -1, 5))
     self.white_moves.append(pentago.Move(4, 2, 1, 1, 5))
     self.white_moves.append(pentago.Move(4, 2, 2, -1, 5))
     self.white_moves.append(pentago.Move(4, 2, 2, 1, 5))
     #self.white_moves.append(pentago.Move(3, 1, 3, 1, 5)) # covered in for loop
     self.white_moves.append(pentago.Move(5, 1, 3, -1, 5))
     #self.white_moves.append(pentago.Move(5, 1, 3, 1, 5)) # covered in for loop
     (white_moves, black_moves) = pentago.find_moves(self.board)
     np.testing.assert_array_equal(white_moves, sorted(self.white_moves))
     np.testing.assert_array_equal(black_moves, self.black_moves)
示例#4
0
 def test_already_won(self):
     self.board[2, 0:5] = w
     with self.assertRaises(ValueError):
         (white_moves, black_moves) = pentago.find_moves(self.board)
示例#5
0
 def test_no_wins(self):
     (white_moves, black_moves) = pentago.find_moves(self.board)
     np.testing.assert_array_equal(white_moves, self.white_moves)
     np.testing.assert_array_equal(black_moves, self.black_moves)