This parser also supports an optional 7th field that stores the current turn's dice pool:
rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1 pnb
The 7th field is a string of piece letters (e.g. "PNB" for White or "pnb" for Black = dice pool [1, 2, 3]), never longer than GameFlags.DiceSlots because a turn rolls three dice. It is absent ("-") or omitted when no dice have been rolled yet. serialize appends it automatically when the pool is non-empty.
Both parse and serialize are inverses of each other for any valid FEN string.
Validates the number of fields, the board layout (exactly 8 ranks, 8 files each), and each piece character. The half-move clock and full-move number default to 0 and 1 respectively when absent (short FEN).
Every field is also checked against what dicechess.engine.domain.GameState can actually hold, so a Right never carries a value that differs from what was parsed: at most seven fields, at most GameFlags.DiceSlots dice, a half-move clock within GameFlags.MaxHalfMoveClock, and numeric fields that fit an Int. Input past any of those bounds is a Left rather than a silently truncated state (#551).
Value parameters
fen
a FEN string with 4 to 7 space-separated fields
Attributes
Returns
Right(state) on success, or Left(errorMessage) describing the first parse failure
Produces all six standard FEN fields, plus an optional 7th field if the dice pool is non-empty. Piece placement is written rank-8-first (as required by the standard). This method is the inverse of parse: parse(serialize(s)) always yields Right(s) for a valid state.