Expand description
Parse and write moves in Universal Chess Interface representation.
Examples
Parsing UCIs:
use shakmaty::{Square, uci::Uci};
let uci: Uci = "g1f3".parse()?;
assert_eq!(uci, Uci::Normal {
from: Square::G1,
to: Square::F3,
promotion: None,
});
Converting to a legal move in the context of a position:
use shakmaty::{Color::White, Chess, Setup, Position};
let mut pos = Chess::default();
let m = uci.to_move(&pos)?;
pos.play_unchecked(&m);
assert_eq!(pos.board().piece_at(Square::F3), Some(White.knight()));
let pos = Chess::default();
let m = Move::Normal {
role: Role::Knight,
from: Square::B1,
to: Square::C3,
capture: None,
promotion: None,
};
let uci = m.to_uci(pos.castles().mode());
assert_eq!(uci.to_string(), "b1c3");
let uci = Uci::from_standard(&m);
assert_eq!(uci.to_string(), "b1c3");
let uci = Uci::from_chess960(&m);
assert_eq!(uci.to_string(), "b1c3");
Structs
- Error when UCI is illegal.
- Error when parsing an invalid UCI.
Enums
- A move as represented in the UCI protocol.