screwdriver = screwdriver or {}
local function index_to_xy(idx)
+ if not idx then
+ return nil
+ end
idx = idx - 1
local x = idx % 8
local y = (idx - x) / 8
board[from_index] = ""
local black_king_idx, white_king_idx = locate_kings(board)
+ if not black_king_idx or not white_king_idx then
+ return 0
+ end
local blackAttacked = attacked("black", black_king_idx, board)
local whiteAttacked = attacked("white", white_king_idx, board)