diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2018-05-10 23:01:22 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2018-05-10 23:01:22 +0200 |
commit | 4755702ef08d70961b5248cb706a592a406d0556 (patch) | |
tree | bfe8ff9e016338a58b6d0d9314d1b67b17cafea9 /src/main.rs | |
parent | 11c791a59ac60241f253cdfb4e8765039d15edff (diff) |
Split to library. Reimplemented sample strategy in new state.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/main.rs b/src/main.rs index 4e18c48..22f698d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,6 @@ -extern crate serde; -extern crate serde_json; - -#[macro_use] -extern crate serde_derive; +extern crate zombot; +use zombot::*; +use zombot::engine::command::Command; use std::error::Error; @@ -14,20 +12,14 @@ use std::fs::File; use std::io::prelude::*; use std::process; -mod json; -mod engine; -use engine::command::Command; - fn choose_move(settings: &engine::settings::GameSettings, state: &engine::GameState) -> Command { - state.simulate(&settings, Command::Nothing, Command::Nothing); - Command::Nothing + strategy::sample::choose_move(settings, state) } fn write_command(filename: &str, command: Command) -> Result<(), Box<Error> > { let mut file = File::create(filename)?; write!(file, "{}", command)?; - Ok(()) } @@ -36,7 +28,6 @@ fn main() { let (settings, state) = match json::read_state_from_file(STATE_PATH) { Ok(ok) => ok, Err(error) => { - eprintln!("Failed to read the {} file. {}", STATE_PATH, error); process::exit(1); } }; @@ -45,7 +36,6 @@ fn main() { match write_command(COMMAND_PATH, command) { Ok(()) => {} Err(error) => { - eprintln!("Failed to write the {} file. {}", COMMAND_PATH, error); process::exit(1); } } |