Esempio n. 1
0
    def test_simple(self):
        """Verifies that a knight's returned movelist has the correct
        number of moves and that the boundaries of it's movelist is correct."""
        board, white = Board(), Player(Color.W)
        knight_white = Knight(white, [3, 4])  # d4
        board.add_to_board(knight_white)
        # c6, e6, f5, f3, e2, c2, b3, b5
        correct_move_list = [[2, 2], [4, 2], [5, 3], [5, 5],
                             [4, 6], [2, 6], [1, 5], [1, 3]]

        returned_moves = knight_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 8)
        for move in correct_move_list:
            self.assertTrue(move in returned_moves)
Esempio n. 2
0
    def test_capture(self):
        """Verifies that a knights's returned movelist correctly includes
        a capture opportunity."""
        board, white, black = create_board_and_players()
        knight_white = Knight(white, [3, 4])  # d4
        board.add_to_board(knight_white)

        pawn_black = Pawn(black, [2, 2])  # c6
        board.add_to_board(pawn_black)

        correct_move1 = [2, 2]  # c6

        returned_moves = knight_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 8)
        self.assertTrue(correct_move1 in returned_moves)