Split to library. Reimplemented sample strategy in new state.
[entelect-challenge-tower-defence.git] / src / main.rs
index 4e18c48..22f698d 100644 (file)
@@ -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);
         }
     }