From 8adf0daa3610807fbefb411c1c4af878b07230c6 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sat, 8 Sep 2018 10:24:53 +0200 Subject: Added minimum to weighted victory / defeat score --- src/strategy/monte_carlo.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/strategy') 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 { -- cgit v1.2.3