summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2019-05-12 00:58:14 +0200
committerJustin Worthe <justin@worthe-it.co.za>2019-05-12 00:58:14 +0200
commit3d1676842e20c90bb5599daa2caefdea2bbf9fe8 (patch)
treec5c45ef35064fad01ed690be8555273224765e67 /src/main.rs
parentebe7d5cd5cc42d8f3f02ca926f4b920ada03765f (diff)
Outline of MCTS
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index d6d9a4c..c24565a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,14 +2,19 @@ use std::io::prelude::*;
use std::io::stdin;
use std::path::Path;
+use time::{Duration, PreciseTime};
+
use steam_powered_wyrm::command::Command;
use steam_powered_wyrm::strategy::choose_move;
use steam_powered_wyrm::json;
use steam_powered_wyrm::game;
fn main() {
+ let max_time = Duration::milliseconds(950);
let mut game_board = None;
for line in stdin().lock().lines() {
+ let start_time = PreciseTime::now();
+
let round_number = line.expect("Failed to read line from stdin: {}");
let command =
@@ -18,13 +23,13 @@ fn main() {
match &mut game_board {
None => {
let new_board = game::GameBoard::new(json_state);
- let command = choose_move(&new_board);
+ let command = choose_move(&new_board, &start_time, max_time);
game_board = Some(new_board);
command
},
Some(game_board) => {
game_board.update(json_state);
- choose_move(&game_board)
+ choose_move(&game_board, &start_time, max_time)
}
}
},