diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2019-05-22 20:38:47 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2019-05-22 20:38:47 +0200 |
commit | e9a514409565c17a4a86e8c6402be8d7a4f399ae (patch) | |
tree | 839dc6e223014ef519fe4d2d020aea996b562e44 /src/main.rs | |
parent | 63da94f7f1b25eddeb9ffd379f37c1a32e750fdb (diff) |
Added a strategy cache for reusing previous round data
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index c24565a..b898fb5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,7 @@ use steam_powered_wyrm::game; fn main() { let max_time = Duration::milliseconds(950); let mut game_board = None; + let mut strategy_cache = None; for line in stdin().lock().lines() { let start_time = PreciseTime::now(); @@ -23,13 +24,16 @@ fn main() { match &mut game_board { None => { let new_board = game::GameBoard::new(json_state); - let command = choose_move(&new_board, &start_time, max_time); + let (command, cache) = choose_move(&new_board, strategy_cache, &start_time, max_time); + strategy_cache = Some(cache); game_board = Some(new_board); command }, Some(game_board) => { game_board.update(json_state); - choose_move(&game_board, &start_time, max_time) + let (command, cache) = choose_move(&game_board, strategy_cache, &start_time, max_time); + strategy_cache = Some(cache); + command } } }, |