Ejemplo n.º 1
0
    def test_simple(self):
        """Verifies that a queen'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)
        queen_white = Queen(white, [3, 4])  # d4
        board.add_to_board(queen_white)

        correct_move_list = [[7, 0]]  # h8
        correct_move_list += [6, 7],  # g1
        correct_move_list += [0, 1],  # a7
        correct_move_list += [0, 7],  # a1
        correct_move_list += [0, 4],  # a4
        correct_move_list += [7, 4],  # h4
        correct_move_list += [3, 0],  # d8
        correct_move_list += [3, 7],  # d1

        returned_moves = queen_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 27)
        for move in correct_move_list:
            self.assertTrue(move in returned_moves)
Ejemplo n.º 2
0
    def test_path_impeded(self):
        """Verifies that a bishop's returned moves stops when encountering
        another of the bishop's owner's pieces."""
        board, white = Board(), Player(Color.W)
        queen_white = Queen(white, [3, 4])  # d4
        board.add_to_board(queen_white)

        pawn_white1 = Pawn(white, [2, 3])  # c5
        board.add_to_board(pawn_white1)

        incorrect_move1 = [2, 3]  # c6

        pawn_white2 = Pawn(white, [2, 4])  # c4
        board.add_to_board(pawn_white2)

        incorrect_move2 = [2, 4]  # c4

        returned_moves = queen_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 21)
        self.assertTrue(incorrect_move1 not in returned_moves)
        self.assertTrue(incorrect_move2 not in returned_moves)
Ejemplo n.º 3
0
    def test_capture(self):
        """Verifies that a queen's returned movelist correctly includes
        a capture opportunity."""
        board, white, black = create_board_and_players()
        queen_white = Queen(white, [3, 4])  # d4
        board.add_to_board(queen_white)

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

        correct_move1 = [2, 5]  # c6

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

        correct_move2 = [2, 4]  # c4

        returned_moves = queen_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 23)
        self.assertTrue(correct_move1 in returned_moves)
        self.assertTrue(correct_move2 in returned_moves)