1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//! Types representing commands defined in USI protocol.
//!
//! USI protocol defines commands sent from either GUIs or engines.
//! Detail about USI protocol is found at http://www.geocities.jp/shogidokoro/usi.html.
//!
//! # Examples
//!
//! ```
//! use std::time::Duration;
//! use usi::{GuiCommand, ThinkParams, EngineCommand, BestMoveParams};
//!
//! // GuiCommand can be converted into the USI compliant string.
//! let params = ThinkParams::new().btime(Duration::from_secs(1)).wtime(Duration::from_secs(2));
//! let cmd = GuiCommand::Go(params);
//! assert_eq!("go btime 1000 wtime 2000", cmd.to_string());
//!
//! // EngineCommand can be parsed from the command string sent from the USI engine.
//! let cmd = EngineCommand::parse("bestmove 7g7f ponder 8c8d").unwrap();
//! match cmd {
//!     EngineCommand::BestMove(BestMoveParams::MakeMove(ref m, Some(ref pm))) => {
//!         assert_eq!("7g7f", *m);
//!         assert_eq!("8c8d", *pm);
//!     },
//!     _ => unreachable!(),
//! }
//! ```

extern crate itertools;

mod engine;
mod error;
mod gui;

pub use self::error::*;
pub use self::engine::*;
pub use self::gui::*;