From f663267dd78b99322e70aba6417955221564d733 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sat, 10 Aug 2019 18:16:13 +0200 Subject: New binary for exploring config values --- src/bin/explore-config.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/bin/explore-config.rs diff --git a/src/bin/explore-config.rs b/src/bin/explore-config.rs new file mode 100644 index 0000000..2d880d9 --- /dev/null +++ b/src/bin/explore-config.rs @@ -0,0 +1,42 @@ +use std::path::Path; + +use time::PreciseTime; + +use steam_powered_wyrm::game; +use steam_powered_wyrm::json; +use steam_powered_wyrm::strategy::{choose_move_with_normalized_perf, ScoreConfig}; + +fn main() { + let initial_state = game::GameBoard::new( + json::read_state_from_json_file(&Path::new(&format!("./tests/example-state.json"))) + .unwrap(), + ); + let depth = 100; + + { + // TODO: Player 0 seems to be winning here consistently. I + // probably have a bug. Also, I expected this to give the same + // result each time and it doesn't. + + let start_time = PreciseTime::now(); + let config1 = ScoreConfig::default(); + let config2 = ScoreConfig::default(); + let mut state = initial_state.clone(); + + while state.outcome == game::SimulationOutcome::Continue { + let commands = [ + choose_move_with_normalized_perf(&state, &config1, 0, depth), + choose_move_with_normalized_perf(&state, &config2, 1, depth), + ]; + state.simulate(commands); + } + + println!("{:?}", state.outcome); + println!( + "Runtime: {}ms", + start_time.to(PreciseTime::now()).num_milliseconds() + ); + println!("{}", state.players[0].health()); + println!("{}", state.players[1].health()); + } +} -- cgit v1.2.3