diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2019-08-11 12:28:38 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2019-08-11 12:28:38 +0200 |
commit | b3d48c9924a2502ba7e93bafb0a8afcd096bec76 (patch) | |
tree | e2237839759e3e44788c8aa482eff27b375cf6cd /tests | |
parent | f663267dd78b99322e70aba6417955221564d733 (diff) |
Replaced hashmaps with deterministic hashmaps
I'm not worried about ddos attacks here, and this also has better perf
for small keys.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/strategy.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/strategy.rs b/tests/strategy.rs new file mode 100644 index 0000000..7088099 --- /dev/null +++ b/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); +} |