Module shakmaty::uci [] [src]

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()));

Converting from Move to Uci:

use std::convert::From;

let m = Move::Normal {
    role: Role::Queen,
    from: Square::A1,
    to: Square::H8,
    capture: Some(Role::Rook),
    promotion: None,
};

let uci: Uci = m.into();
assert_eq!(uci.to_string(), "a1h8");

Structs

InvalidUci

Error when parsing an invalid UCI.

Enums

Uci

A move as represented in the UCI protocol.