Expand description
Parse and write Forsyth-Edwards-Notation.
§Parsing
The parser is relaxed:
- Supports X-FEN and Shredder-FEN for castling right notation.
- Ignores repeated castling rights.
- Allows castling rights in any order.
- Allows castling rights without matching rooks (treating
Q
andK
asA
andH
respectively).
- Supports
[q]
and/q
styles for Crazyhouse pockets. - Supports
3+3
and+0+0
for remaining checks in Three-Check. - Accepts missing FEN fields (except the board) and fills them with
default values of
8/8/8/8/8/8/8/8 w - - 0 1
. - Accepts multiple spaces and underscores (
_
) as separators between FEN fields. - Accepts
0
as fulllmove number and uses1
instead.
Fen
and Epd
implement FromStr
:
use shakmaty::{fen::Fen, CastlingMode, Chess, Position};
let fen: Fen = "r1bqkbnr/ppp2Qpp/2np4/4p3/2B1P3/8/PPPP1PPP/RNB1K1NR b KQkq - 0 4".parse()?;
let pos: Chess = fen.into_position(CastlingMode::Standard)?;
assert!(pos.is_checkmate());
§Writing
Writes X-FEN with [q]
style for Crazyhouse pockets and 3+3
style
for remainig checks in Three-Check.
Fen
and Epd
implement Display
:
use shakmaty::{fen::Epd, EnPassantMode, Chess, Position};
let pos = Chess::default();
assert_eq!(Epd::from_position(pos, EnPassantMode::Legal).to_string(),
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -");
Structs§
- Displays a board with notation like
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR
. - An EPD like
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -
. - A FEN like
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
.
Enums§
- Errors that can occur when parsing a FEN.