summaryrefslogtreecommitdiff
path: root/2019-worms/tests/strategy.rs
diff options
context:
space:
mode:
Diffstat (limited to '2019-worms/tests/strategy.rs')
-rw-r--r--2019-worms/tests/strategy.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/2019-worms/tests/strategy.rs b/2019-worms/tests/strategy.rs
new file mode 100644
index 0000000..7088099
--- /dev/null
+++ b/2019-worms/tests/strategy.rs
@@ -0,0 +1,27 @@
+use std::path::Path;
+
+use steam_powered_wyrm::game;
+use steam_powered_wyrm::json;
+use steam_powered_wyrm::strategy::{choose_move_with_normalized_perf, ScoreConfig};
+
+#[test]
+fn strategy_is_implemented_symetrically() {
+ let state = game::GameBoard::new(
+ json::read_state_from_json_file(&Path::new(&format!("./tests/example-state.json")))
+ .unwrap(),
+ );
+ let depth = 100;
+
+ let config = ScoreConfig::default();
+ let flipped_state = {
+ let mut flipped_state = state.clone();
+ flipped_state.players[0] = state.players[1].clone();
+ flipped_state.players[1] = state.players[0].clone();
+ flipped_state
+ };
+
+ let position_one_move = choose_move_with_normalized_perf(&state, &config, 0, depth);
+ let position_two_move = choose_move_with_normalized_perf(&flipped_state, &config, 1, depth);
+
+ assert_eq!(position_one_move, position_two_move);
+}