summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2018-09-08 10:36:09 +0200
committerJustin Worthe <justin@worthe-it.co.za>2018-09-08 10:36:09 +0200
commit32e1dedc420c1011f63aaa90ed96fa19d2590a77 (patch)
treee275b238fc529bf8a9ea6be3036495322a3d4cf2 /src
parent0da5a09df776ba7f08550641d990707392c24e4c (diff)
Feature-flaggified weighting win ratios
Diffstat (limited to 'src')
-rw-r--r--src/strategy/monte_carlo.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/strategy/monte_carlo.rs b/src/strategy/monte_carlo.rs
index 039c861..978f8f1 100644
--- a/src/strategy/monte_carlo.rs
+++ b/src/strategy/monte_carlo.rs
@@ -398,10 +398,16 @@ impl CommandScore {
self.next_seed = next_seed;
}
+ #[cfg(feature = "weighted-win-ratio")]
fn win_ratio(&self) -> i32 {
(self.victory_score - self.defeat_score) * 10000 / (self.attempts as i32)
}
+ #[cfg(not(feature = "weighted-win-ratio"))]
+ fn win_ratio(&self) -> i32 {
+ (self.victories as i32 - self.defeats as i32) * 10000 / (self.attempts as i32)
+ }
+
fn init_command_scores(state: &BitwiseGameState) -> Vec<CommandScore> {
let unoccupied_cells_count = state.player.unoccupied_cell_count();
let unoccupied_cells = (0..unoccupied_cells_count)