From 4755702ef08d70961b5248cb706a592a406d0556 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Thu, 10 May 2018 23:01:22 +0200 Subject: Split to library. Reimplemented sample strategy in new state. --- src/main.rs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'src/main.rs') 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 > { 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); } } -- cgit v1.2.3