diff options
author | Justin Wernick <justin@worthe-it.co.za> | 2022-04-19 21:27:56 +0200 |
---|---|---|
committer | Justin Wernick <justin@worthe-it.co.za> | 2022-04-19 21:27:56 +0200 |
commit | 3f5492b2bb67326be43cd7c5ba02ccf0ba1ae0e3 (patch) | |
tree | 96963ba885a9393106b4a88ffc4266203e87582e /2019-worms/tests/strategy.rs | |
parent | 4ceec65b088f05d4ad03f9ac70b1d63452fd8197 (diff) |
Refile for merging repos
Diffstat (limited to '2019-worms/tests/strategy.rs')
-rw-r--r-- | 2019-worms/tests/strategy.rs | 27 |
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); +} |