def king_castling_check_test(): print("========================================") print("Performing the king castling check test") print("========================================") board = Board() piece = King(Colour.WHITE) current_location = Location('e', 1) board.__add_piece__(piece, current_location) board.__add_piece__(Rook(Colour.WHITE), Location('a', 1)) board.__add_piece__(Rook(Colour.WHITE), Location('h', 1)) board.__add_piece__(Rook(Colour.BLACK), Location('e', 2)) print(board) allowed_moves = piece.allowed_moves(current_location, board) print("For a {} {} starting at position {} the moves are:".format( piece.colour, piece.name, current_location)) print(allowed_moves) new_location = allowed_moves[0] board.move_piece(piece, current_location, new_location) current_location = new_location print("Moved the {} to position {}".format(piece.name, new_location)) print(board) print("For a {} {} at position {} the moves are:".format( piece.colour, piece.name, current_location)) print(piece.allowed_moves(current_location, board))
def basic_king_test(): print("========================================") print("Performing the basic king movement test") print("========================================") board = Board() piece = King(Colour.WHITE) current_location = Location('d', 5) board.__add_piece__(piece, current_location) print(board) allowed_moves = piece.allowed_moves(current_location, board) print("For a {} {} starting at position {} the moves are:".format( piece.colour, piece.name, current_location)) print(allowed_moves) new_location = allowed_moves[0] board.move_piece(piece, current_location, new_location) current_location = new_location print("Moved the {} to position {}".format(piece.name, new_location)) print(board) print("For a {} {} at position {} the moves are:".format( piece.colour, piece.name, current_location)) print(piece.allowed_moves(current_location, board))