summaryrefslogtreecommitdiff
path: root/2019-worms/src/bin/benchmark.rs
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2022-04-19 21:29:18 +0200
committerJustin Wernick <justin@worthe-it.co.za>2022-04-19 21:29:18 +0200
commit4d1edc899a86791ec57c0d3b2b3d7427f138463f (patch)
treeed1c7031c54d8f3a3897081c4a1040ace9d8f4ae /2019-worms/src/bin/benchmark.rs
parent01a849c6b26afd076989f645c6153d8ce1422281 (diff)
parent3f5492b2bb67326be43cd7c5ba02ccf0ba1ae0e3 (diff)
Merge branch 'worms-main'
Diffstat (limited to '2019-worms/src/bin/benchmark.rs')
-rw-r--r--2019-worms/src/bin/benchmark.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/2019-worms/src/bin/benchmark.rs b/2019-worms/src/bin/benchmark.rs
new file mode 100644
index 0000000..84e869e
--- /dev/null
+++ b/2019-worms/src/bin/benchmark.rs
@@ -0,0 +1,22 @@
+use std::path::Path;
+
+use time::{Duration, PreciseTime};
+
+use steam_powered_wyrm::game;
+use steam_powered_wyrm::json;
+use steam_powered_wyrm::strategy::{choose_move, ScoreConfig};
+
+fn main() {
+ let max_time = Duration::milliseconds(19950);
+ let start_time = PreciseTime::now();
+
+ match json::read_state_from_json_file(&Path::new(&format!("./tests/example-state.json"))) {
+ Ok(json_state) => {
+ let new_board = game::GameBoard::new(json_state);
+ let _ = choose_move(&new_board, &ScoreConfig::default(), start_time, max_time);
+ }
+ Err(e) => {
+ eprintln!("WARN: State file could not be parsed: {}", e);
+ }
+ };
+}