def test_discovered_check_with_knight(): board = Board() king = King(board, (0, 0), 'white') knight = Knight(board, (0, 1), '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) == 2 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) == 19 assert len(moves_queen) == 19 pseudo_legal_moves_knight = [ move for move in knight.generate_pseudo_legal_moves() ] moves_knight = [move for move in knight.generate_moves()] assert len(pseudo_legal_moves_knight) == 3 assert len(moves_knight) == 0
def test_king_moves_with_check(): board = Board() king = King(board, (0, 1), 'white') King(board, (0, 3), '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) == 3
def test_king_moves_center(): board = Board() king = King(board, (1, 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) == 8 assert len(moves) == 8
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
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
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
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
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