[−][src]Module shakmaty::uci
Parse and write moves in Universal Chess Interface representation.
Examples
Parsing UCIs:
use shakmaty::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::{Square, 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 = Uci::from_move(&pos, &m); assert_eq!(uci.to_string(), "b1c3"); let uci = Uci::from_chess960(&m); assert_eq!(uci.to_string(), "b1c3");
Structs
ParseUciError | Error when parsing an invalid UCI. |
Enums
Uci | A move as represented in the UCI protocol. |