Ejemplo n.º 1
0
    def test_capture(self):
        """Verifies that a bishop's returned move list correctly includes
        a capture opportunity."""
        board, white, black = create_board_and_players()
        bishop_white = Bishop(white, [3, 4])  # d4
        board.add_to_board(bishop_white)

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

        correct_move1 = [2, 5]  # c3

        returned_moves = bishop_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 11)
        self.assertTrue(correct_move1 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)
        bishop_white = Bishop(white, [3, 4])  # d4
        board.add_to_board(bishop_white)

        pawn_white = Pawn(white, [2, 5])  # c3
        board.add_to_board(pawn_white)

        incorrect_move1 = [2, 4]  # c3

        returned_moves = bishop_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 10)
        self.assertTrue(incorrect_move1 not in returned_moves)
Ejemplo n.º 3
0
    def test_simple(self):
        """Verifies that a bishops'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)
        bishop_white = Bishop(white, [3, 4])  # d4
        board.add_to_board(bishop_white)

        correct_move1 = [7, 0]  # h8
        correct_move2 = [6, 7]  # g1
        correct_move3 = [0, 1]  # a7
        correct_move4 = [0, 7]  # a1

        returned_moves = bishop_white.get_legal_moves(board, True)
        self.assertTrue(len(returned_moves) == 13)
        self.assertTrue(correct_move1 in returned_moves)
        self.assertTrue(correct_move2 in returned_moves)
        self.assertTrue(correct_move3 in returned_moves)
        self.assertTrue(correct_move4 in returned_moves)