summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2019-08-10 18:16:13 +0200
committerJustin Worthe <justin@worthe-it.co.za>2019-08-10 18:16:13 +0200
commitf663267dd78b99322e70aba6417955221564d733 (patch)
treea9ee915dc66cd09f57acd879940c24ab0dff9106
parentec14a947f4c74f48cfedcd4d903fc14c0958aa98 (diff)
New binary for exploring config values
-rw-r--r--src/bin/explore-config.rs42
1 files changed, 42 insertions, 0 deletions
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());
+ }
+}