Ejemplo n.º 1
0
def test_blocked_pawn_2():
    board = Board()
    King(board, (0, 0), 'white')
    pawn = Pawn(board, (1, 0), 'white')
    King(board, (2, 0), 'black')

    moves = [move for move in pawn.generate_moves()]

    assert len(moves) == 0
Ejemplo n.º 2
0
def test_pawn_promotion():
    board = Board()
    King(board, (0, 0), 'white')
    pawn = Pawn(board, (6, 0), 'white')
    King(board, (7, 7), 'black')

    moves = [move for move in pawn.generate_moves()]

    assert len(moves) == 1
    assert isinstance(moves[0].get_piece_by_position((7, 0)), Queen)
Ejemplo n.º 3
0
def test_pawn_attack_2():
    board = Board()
    King(board, (0, 0), 'white')
    pawn = Pawn(board, (5, 5), 'black')
    Bishop(board, (4, 4), 'white')
    King(board, (7, 6), 'black')

    moves = [move for move in pawn.generate_moves()]

    assert len(moves) == 2
Ejemplo n.º 4
0
def test_pawn_attack_1():
    board = Board()
    King(board, (0, 0), 'white')
    pawn = Pawn(board, (1, 0), 'white')
    Bishop(board, (2, 1), 'black')
    King(board, (7, 7), 'black')

    moves = [move for move in pawn.generate_moves()]

    assert len(moves) == 3
Ejemplo n.º 5
0
def test_en_passant():
    board = Board()
    King(board, (0, 0), 'white')
    Pawn(board, (1, 0), 'white')
    Pawn(board, (3, 1), 'black')
    King(board, (7, 7), 'black')

    move = Move((1, 0), (3, 0), special_move='pawn_double')
    new_board = board.copy_and_execute_move(move)

    assert new_board.en_passant['black'][0]

    black_pawn = new_board.get_piece_by_position((3, 1))
    moves = [move for move in black_pawn.generate_moves()]

    assert len(moves) == 2

    move = Move((3, 1), (2, 0), special_move='en_passant')
    newest_board = new_board.copy_and_execute_move(move)

    assert len([piece for piece in newest_board.pieces]) == 3