diff options
author | Justin Wernick <justin@worthe-it.co.za> | 2022-04-19 21:29:18 +0200 |
---|---|---|
committer | Justin Wernick <justin@worthe-it.co.za> | 2022-04-19 21:29:18 +0200 |
commit | 4d1edc899a86791ec57c0d3b2b3d7427f138463f (patch) | |
tree | ed1c7031c54d8f3a3897081c4a1040ace9d8f4ae /2019-worms/tests/strategy.rs | |
parent | 01a849c6b26afd076989f645c6153d8ce1422281 (diff) | |
parent | 3f5492b2bb67326be43cd7c5ba02ccf0ba1ae0e3 (diff) |
Merge branch 'worms-main'
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); +} |