Browse Source

instantiating engine works fine

ag-yep
Taylor Bockman 7 years ago
parent
commit
a1d7ca7e64
  1. 8
      CONTRIBUTING.md
  2. 6
      src/commands.rs
  3. 20
      src/lib.rs
  4. 11
      tests/lib.rs

8
CONTRIBUTING.md

@ -0,0 +1,8 @@
# Contributing to UCI
TODO
# Styleguide
We try to make use of the styleguide found [here](https://github.com/rust-lang-nursery/fmt-rfcs/blob/master/guide/guide.md).

6
src/commands.rs

@ -75,10 +75,10 @@ pub const REGISTRATIONCHECKING: &'static str = "registration checking\n";
pub const REGISTRATIONOK: &'static str = "registration ok\n"; pub const REGISTRATIONOK: &'static str = "registration ok\n";
/// REGISTRATIONERROR tells the GUI that the engine has rejected the registration /// REGISTRATIONERROR tells the GUI that the engine has rejected the registration
pub const COPYPROTECTIONCHECKING: &'static str = "registration error\n"; pub const REGISTRATIONERROR: &'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 /// 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"; pub const INFO: &'static str = "info";
/// OPTION tells the GUI which parameters can be changed in the engine /// OPTION tells the GUI which parameters can be changed in the engine
pub const OPTION &'static str = "option"; pub const OPTION: &'static str = "option";

20
src/lib.rs

@ -3,4 +3,24 @@
mod commands; mod commands;
pub struct Engine<'a> {
pub name: &'a str,
pub author: &'a str,
}
/// Notes to delete later:
///
/// The user will have to provide code to run for the lifecycle. Moreover the user will have to overwrite a handful
/// of methods that need explicit contact with the underlying engine code to determine what to do before doing a
/// "run". There needs to be a "loop" that kicks off a thread to monitor stdin and also calculations, etc.
/// It will be worth taking the time to map out exactly how a user will be able to use this generic UCI interface
/// effectively without losing too much and/or making their lives hard.
impl<'a> Engine<'a> {
pub fn new(name: &'a str, author: &'a str) -> Engine<'a> {
Engine {
name: name,
author: author,
}
}
}

11
tests/lib.rs

@ -0,0 +1,11 @@
extern crate uci;
use uci::Engine;
#[test]
fn instantiate_new_engine() {
let e: Engine;
e = Engine::new("test_name", "test");
assert_eq!(e.name, "test_name");
assert_eq!(e.author, "test");
}
Loading…
Cancel
Save