diff --git a/README.md b/README.md index f206f24..d3d3fbc 100644 --- a/README.md +++ b/README.md @@ -52,4 +52,31 @@ switch to UCI mode. You can use `commands::UCI` to make sure the command text yo Next, you'll need to create a copy of `Engine` by calling `Engine::new`. Once this is setup, you can call `Engine::identify` to send identification information to the GUI. +Once identification is done, you need to send your configuration options. This is dependent on your engine. Refer to +the UCI standard for the available options. You must configure this before calling `Engine::new` so this guide assumes +you've done that already. + +To send your configuration options simply call `Engine::send_available_options`. Once this finishes `uciok` will +also be sent, indicating to the GUI your engine is ready to roll. At this point you need to set up two threads, one +to calculate with your engine, and one to read STDIN. + +``` +EXAMPLE HERE WITH LOOPS IN THREADS AND BLOCKING AND WHATEVER +``` + +Notice how in our STDIN thread we are calling `Engine::parse` and the handling the output using a match statement +depending on what kind of token it was. You are responsible for obeying the commands from this thread, the UCI library +just makes it convenient to work with. + +**TODO: MORE STUFF WITH EXAMPLES** +**THINGS LIKE SENDINB BEST MOVE AFTER CALCULATING, ETC** + + +### Other Options + +**TODO: Talk about the additional helpers available in the UCI library and what-not**. + +* Copy protection checking +* Registration checking + diff --git a/src/lib.rs b/src/lib.rs index 46621cf..860ae16 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -61,4 +61,19 @@ where write!(&mut self.writer, "{}", name_id).expect("failed to send name identification to writer"); write!(&mut self.writer, "{}", author_id).expect("failed to send author identification to writer"); } + + /// Sends all available options in the options configuration and a final UCIOK meaning we are reading to go. + pub fn send_available_options(&mut self) { + // NOTE: Options can be represented as a hashmap with keys that are constant strings in the options.rs + // file and values are the associated options. + // This function will construct the proper string from the objects. + // How can you make this as easy as possible for the user...give it some thought. The value has to be + // some sort of object that can store various optiobns that change on the option. + // Since options are fixed it would be nice to type check the key values. Maybe use a trait or something + // that is actually a wrapped string, but typecheckable so not just any string can be put in. + // TODO: This needs to be tested majorly + + // Again this command must complete before we can say the engine is connected, so panicking at this stage is ok + write!(&mut self.writer, "{}", commands::UCIOK).expect("failed to send `uciok` command"); + } } diff --git a/src/options.rs b/src/options.rs new file mode 100644 index 0000000..8a974fc --- /dev/null +++ b/src/options.rs @@ -0,0 +1 @@ +//! Options contains constant strings representing the options that are possible in an UCI engin.