summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2018-09-08 10:24:53 +0200
committerJustin Worthe <justin@worthe-it.co.za>2018-09-08 10:24:53 +0200
commit8adf0daa3610807fbefb411c1c4af878b07230c6 (patch)
tree076aa024c1458efbd745ca8d539ce1dd887ebb51
parentd3f78b98ad67920d799fa15421115d0bf4b7ee45 (diff)
Added minimum to weighted victory / defeat score
-rw-r--r--src/strategy/monte_carlo.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/strategy/monte_carlo.rs b/src/strategy/monte_carlo.rs
index 56701f5..a513a63 100644
--- a/src/strategy/monte_carlo.rs
+++ b/src/strategy/monte_carlo.rs
@@ -371,14 +371,16 @@ impl CommandScore {
}
fn add_victory(&mut self, weight: i32, next_seed: [u8; 16]) {
- self.victory_score += weight;
+ use std::cmp;
+ self.victory_score += cmp::max(weight, 1);
self.victories += 1;
self.attempts += 1;
self.next_seed = next_seed;
}
fn add_defeat(&mut self, weight: i32, next_seed: [u8; 16]) {
- self.defeat_score += weight;
+ use std::cmp;
+ self.defeat_score += cmp::max(weight, 1);
self.defeats += 1;
self.attempts += 1;
self.next_seed = next_seed;
@@ -445,7 +447,7 @@ impl fmt::Display for CommandScore {
}
}
-#[cfg(not(feature = "energy-cutoff"))]
+#[cfg(all(not(feature = "heuristic-random"), not(feature = "energy-cutoff")))]
fn sensible_buildings(player: &Player, open_building_spot: bool) -> ArrayVec<[BuildingType; NUMBER_OF_BUILDING_TYPES]> {
let mut result = ArrayVec::new();
if !open_building_spot {
@@ -468,7 +470,7 @@ fn sensible_buildings(player: &Player, open_building_spot: bool) -> ArrayVec<[Bu
result
}
-#[cfg(feature = "energy-cutoff")]
+#[cfg(all(not(feature = "heuristic-random"), feature = "energy-cutoff")]
fn sensible_buildings(player: &Player, open_building_spot: bool) -> ArrayVec<[BuildingType; NUMBER_OF_BUILDING_TYPES]> {
let mut result = ArrayVec::new();
if !open_building_spot {