Browse Source

headway on options

ag-yep
Taylor Bockman 7 years ago
parent
commit
bee54e617c
  1. 27
      README.md
  2. 15
      src/lib.rs
  3. 1
      src/options.rs

27
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 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. `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

15
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, "{}", name_id).expect("failed to send name identification to writer");
write!(&mut self.writer, "{}", author_id).expect("failed to send author 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");
}
} }

1
src/options.rs

@ -0,0 +1 @@
//! Options contains constant strings representing the options that are possible in an UCI engin.
Loading…
Cancel
Save