summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2018-05-12 22:37:48 +0200
committerJustin Worthe <justin@worthe-it.co.za>2018-05-12 22:37:48 +0200
commit02256124fbd57d88effd02c046093ecaf73b77e3 (patch)
tree9b4b33a6119e92b40c808677771d2e95e9971933 /src/main.rs
parentd14ec12e30852f8a93f310f5c53fce6ab6f1c6c5 (diff)
Limited bot to run within the 2 second window
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index e5dc3aa..3d3d980 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,7 @@
extern crate zombot;
+extern crate time;
+use time::PreciseTime;
+
use zombot::*;
use zombot::engine::command::Command;
@@ -12,8 +15,8 @@ use std::fs::File;
use std::io::prelude::*;
use std::process;
-fn choose_move(settings: &engine::settings::GameSettings, state: &engine::GameState) -> Command {
- strategy::monte_carlo::choose_move(settings, state)
+fn choose_move(settings: &engine::settings::GameSettings, state: &engine::GameState, start_time: &PreciseTime) -> Command {
+ strategy::monte_carlo::choose_move(settings, state, start_time)
}
@@ -25,6 +28,8 @@ fn write_command(filename: &str, command: Command) -> Result<(), Box<Error> > {
fn main() {
+ let start_time = PreciseTime::now();
+
println!("Reading in state.json file");
let (settings, state) = match json::read_state_from_file(STATE_PATH) {
Ok(ok) => ok,
@@ -33,7 +38,7 @@ fn main() {
process::exit(1);
}
};
- let command = choose_move(&settings, &state);
+ let command = choose_move(&settings, &state, &start_time);
match write_command(COMMAND_PATH, command) {
Ok(()) => {}
@@ -42,4 +47,6 @@ fn main() {
process::exit(1);
}
}
+
+ println!("Elapsed time: {}", start_time.to(PreciseTime::now()));
}