Beispiel #1
0
def test_king_moves_corner():
    board = Board()
    king = King(board, (0, 0), 'white')
    King(board, (7, 7), 'black')

    pseudo_legal_moves = [move for move in king.generate_pseudo_legal_moves()]
    moves = [move for move in king.generate_moves()]

    assert len(pseudo_legal_moves) == 3
    assert len(moves) == 3
Beispiel #2
0
def test_castling_black_long():
    board = Board()
    King(board, (0, 4), 'white')
    Rook(board, (7, 7), 'black')
    king = King(board, (7, 4), 'black')

    pseudo_legal_moves = [move for move in king.generate_pseudo_legal_moves()]
    moves = [move for move in king.generate_moves()]

    assert len(pseudo_legal_moves) == 6
    assert len(moves) == 6
Beispiel #3
0
def test_castling_white_check_on_path():
    board = Board()
    king = King(board, (0, 4), 'white')
    Rook(board, (0, 0), 'white')
    Bishop(board, (4, 2), 'black')
    King(board, (7, 7), 'black')

    pseudo_legal_moves = [move for move in king.generate_pseudo_legal_moves()]
    moves = [move for move in king.generate_moves()]

    assert len(pseudo_legal_moves) == 6
    assert len(moves) == 5
Beispiel #4
0
def test_castling_white_long_with_check():
    board = Board()
    king = King(board, (0, 4), 'white')
    Rook(board, (0, 0), 'white')
    Queen(board, (6, 4), 'black')
    King(board, (7, 7), 'black')

    pseudo_legal_moves = [move for move in king.generate_pseudo_legal_moves()]
    moves = [move for move in king.generate_moves()]

    assert len(pseudo_legal_moves) == 6
    assert len(moves) == 4
Beispiel #5
0
def test_castling_white_long_with_piece_between():
    board = Board()
    king = King(board, (0, 4), 'white')
    Rook(board, (0, 0), 'white')
    Knight(board, (0, 1), 'white')
    King(board, (7, 7), 'black')

    pseudo_legal_moves = [move for move in king.generate_pseudo_legal_moves()]
    moves = [move for move in king.generate_moves()]

    assert len(pseudo_legal_moves) == 5
    assert len(moves) == 5
Beispiel #6
0
def test_king_and_queen_moves_with_check():
    board = Board()
    king = King(board, (0, 0), 'white')
    queen_black = Queen(board, (0, 7), 'black')
    King(board, (7, 7), 'black')

    pseudo_legal_moves_king = [
        move for move in king.generate_pseudo_legal_moves()
    ]
    moves_king = [move for move in king.generate_moves()]

    assert len(pseudo_legal_moves_king) == 3
    assert len(moves_king) == 2

    pseudo_legal_moves_queen = [
        move for move in queen_black.generate_pseudo_legal_moves()
    ]
    moves_queen = [move for move in queen_black.generate_moves()]

    assert len(pseudo_legal_moves_queen) == 20
    assert len(moves_queen) == 20