         self.castlingRights = .all
         self.mode = mode
         self.variant = variant
+        self.attackersToKing = 0
     }
 
     /// Returns the captured pieces for a color, or for all if color is `nil`.

    public func executeMove(move: Move, promotion: (() -> Piece)? =  nil) throws {
        guard isValidMove(move) else { throw MoveExecutionError.IllegalMove }
        try _executeMove(move, promotion: promotion)
    }

    /// Executes the move or throws on error.

            board[rook][old] = true
            board[rook][new] = false
        }
        _undoHistory.append((move, promotion, attackers))
        if let capture = capture {
            board[capture][captureSquare] = true
        }
        board[piece][move.end] = false
        board[piece][move.start] = true
        playerTurn.invert()
        attackersToKing = attackers
        return move
    }

    /// Redoes the previous undone move and returns it, if any.
    public func redoMove() -> Move? {
        guard let (move, promotion, attackers) = _undoHistory.popLast() else {
            return nil
        }
        try! _executeMove(move, promotion: promotion.map { p in { p } })
        attackersToKing = attackers
        return move
    }

