Expand description
Parse and write Forsyth-Edwards-Notation.
En passant only if fully legal
This implementation intentionally deviates from the specification in
a backwards compatible way: Setup::ep_square()
implemented for each Position
omits en passant
squares, unless there is a fully legal en passant capture.
Examples
fen::fen()
and fen::epd()
can produce a
FEN for any Setup
.
use shakmaty::{fen, Chess};
let pos = Chess::default();
assert_eq!(fen::epd(&pos),
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -");
Fen
and Board
also implement Display
:
use shakmaty::fen::Fen;
let empty_fen = Fen::empty();
assert_eq!(empty_fen.to_string(), "8/8/8/8/8/8/8/8 w - - 0 1");
Parsing FENs:
use shakmaty::{CastlingMode, Position};
let input = "r1bqkbnr/ppp2Qpp/2np4/4p3/2B1P3/8/PPPP1PPP/RNB1K1NR b KQkq - 0 4";
let setup: Fen = input.parse()?;
let position: Chess = setup.position(CastlingMode::Standard)?;
assert!(position.is_checkmate());
Structs
Enums
Errors that can occur when parsing a FEN.