usi-rs
A library to handle type-safe communication with USI-compatible shogi engines. USI protocol defines commands sent from either GUIs or engines. Detail about USI protocol can be found at http://www.geocities.jp/shogidokoro/usi.html.
Usage
Data types representing commands defined in USI protocol
GuiCommand and EngineCommand represents input/output commands defined in the protocol.
Examples
use Duration;
use ;
// GuiCommand can be converted into the USI compliant string.
let params = new.btime.wtime;
let cmd = Go;
assert_eq!;
// EngineCommand can be parsed from the command string sent from the USI engine.
let cmd = parse.unwrap;
match cmd
Working with a USI engine process
UsiEngineHandler can be used to spawn the USI engine process. You can send GuiCommands and receive EngineCommand.
Examples
use ;
let mut handler = spawn.unwrap;
// Get the USI engine information.
let info = handler.get_info.unwrap;
assert_eq!;
// Set options.
handler.send_command.unwrap;
handler.prepare.unwrap;
handler.send_command.unwrap;
// Start listening to the engine output.
// You can pass the closure which will be called
// everytime new command is received from the engine.
handler.listen.unwrap;
handler.send_command.unwrap;
License
usi-rs is licensed under the MIT license. Please read the LICENSE file in this repository for more information.