From 1875853925dccd92c325371ef2422226db9b150e Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Sat, 9 Dec 2017 21:31:19 -0800 Subject: [PATCH] enumerate basic commands --- .travis.yml | 7 +++++ src/commands.rs | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 13 +++++---- 3 files changed, 97 insertions(+), 7 deletions(-) create mode 100644 .travis.yml create mode 100644 src/commands.rs diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..314d0b8 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: rust +rust: + - stable + - nightly +matrix: + allow_failures: + - rust: stable diff --git a/src/commands.rs b/src/commands.rs new file mode 100644 index 0000000..0728577 --- /dev/null +++ b/src/commands.rs @@ -0,0 +1,84 @@ +//! Commands contains the command constants expected during the UCI lifecycle +//! It is useful to note many of these commands do not end with '\n'. This is because they expect arguments. + +///////// GUI to Engine ///////// + +/// Tell engine to use the UCI (Universal Chess Interface) +pub const UCI: &'static str = "uci\n"; + +/// DEBUG toggles the debug mode of the engine on or off +pub const DEBUG: &'static str = "debug"; +pub const DEBUGON: &'static str = "on"; +pub const DEBUGOFF: &'static str = "off"; + +/// ISREADY synchronizes the engine with the GUI +pub const ISREADY: &'static str = "isready\n"; + +/// SETOPTION is sent to the engine when the user wants to change an internal parameter +pub const SETOPTION: &'static str = "setoption"; + +/// REGISTER is the command used to try to register an engine or tell the engine that registration will be done +/// later +pub const REGISTER: &'static str = "register"; + +/// UCINEWGAME is sent to the engine when the next search (started with "position" and "go") will be from a different +/// game +pub const UCINEWGAME: &'static str = "ucinewgame\n"; + +/// POSITION is sent to set up the position described in fenstring on the internal board and play the moves on the +/// internal chess board +pub const POSITION: &'static str = "position"; + +/// GO signals to start calculating on the current position set up with the "position" command +pub const GO: &'static str = "go\n"; + +/// STOP signals to stop calculating as soon as possible +pub const STOP: &'static str = "stop\n"; + +/// PONDERHIT will be sent if the engine was told to ponder on the same move the user has played +pub const PONDERHIT: &'static str = "ponderhit\n"; + +/// QUIT signals to quit the program as soon as possible +pub const QUIT: &'static str = "quit\n"; + + +///////// Engine to GUI ///////// + + +/// ID is used to signal the engine name and author to the GUI +pub const ID: &'static str = "id"; + +/// UCIOK is sent after the ID and optional options to tell the GUI that the engine has sent all infos and is ready +/// in UCI mode +pub const UCIOK: &'static str = "uciok\n"; + +/// READYOK is sent when the engine has received an "isready" command and has processed all input and is ready to +/// accept new commands now +pub const READYOK: &'static str = "readyok\n"; + +/// BESTMOVE is sent when the engine has stopped searching and found the move best in this position +pub const BESTMOVE: &'static str = "bestmove"; + +/// COPYPROTECTIONCHECKING tells the GUI that the engine is checking the copy protection +pub const COPYPROTECTIONCHECKING: &'static str = "copyprotection checking\n"; + +/// COPYPROTECTIONOK tells the GUI that the engine has verified the copy protection +pub const COPYPROTECTIONOK: &'static str = "copyprotection ok\n"; + +/// COPYPROTECTIONERROR tells the GUI that the engine has rejected the copy protection +pub const COPYPROTECTIONERROR: &'static str = "copyprotection error\n"; + +/// REGISTRATIONCHECKING tells the GUI that the engine is checking the registration +pub const REGISTRATIONCHECKING: &'static str = "registration checking\n"; + +/// REGISTRATIONOK tells the GUI that the engine the registration has been verified +pub const REGISTRATIONOK: &'static str = "registration ok\n"; + +/// REGISTRATIONERROR tells the GUI that the engine has rejected the registration +pub const COPYPROTECTIONCHECKING: &'static str = "registration error\n"; + +/// INFO tells the GUI the engine wants to sent infos to the GUI. This should be done whenever the info has changed +pub const INFO &'static str = "info"; + +/// OPTION tells the GUI which parameters can be changed in the engine +pub const OPTION &'static str = "option"; diff --git a/src/lib.rs b/src/lib.rs index 31e1bb2..cb71d6d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,6 @@ -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); - } -} +//! UCI is a simple library to allow people to ignore the lower-level protocol needed to create chess engines. + +mod commands; + + +