Calibrated energy cutoff and turned it on by default
authorJustin Worthe <justin@worthe-it.co.za>
Sat, 9 Jun 2018 11:23:32 +0000 (13:23 +0200)
committerJustin Worthe <justin@worthe-it.co.za>
Sat, 9 Jun 2018 11:23:32 +0000 (13:23 +0200)
Cargo.toml
src/engine/mod.rs
src/main.rs

index b215a34..926ab10 100644 (file)
@@ -17,3 +17,6 @@ benchmarking = []
 single-threaded = []
 energy-cutoff = []
 reduced-time = []
+extended-time = []
+
+default = ["energy-cutoff", "benchmarking"]
index 28583a1..739dd85 100644 (file)
@@ -8,8 +8,8 @@ use self::settings::{GameSettings, BuildingSettings};
 
 use std::ops::FnMut;
 
-#[cfg(feature = "energy-cutoff")] pub const ENERGY_PRODUCTION_CUTOFF: f32 = 2.;
-#[cfg(feature = "energy-cutoff")] pub const ENERGY_STORAGE_CUTOFF: u16 = 10;
+#[cfg(feature = "energy-cutoff")] pub const ENERGY_PRODUCTION_CUTOFF: f32 = 1.2;
+#[cfg(feature = "energy-cutoff")] pub const ENERGY_STORAGE_CUTOFF: f32 = 1.5;
 
 #[derive(Debug, Clone, PartialEq)]
 pub struct GameState {
@@ -293,8 +293,8 @@ impl Player {
     #[cfg(feature = "energy-cutoff")]
     pub fn sensible_buildings(&self, settings: &GameSettings) -> Vec<BuildingType> {
         let mut result = Vec::with_capacity(3);
-        let needs_energy = self.energy_generated as f32 >= ENERGY_PRODUCTION_CUTOFF * settings.max_building_price as f32 &&
-            self.energy >= ENERGY_STORAGE_CUTOFF * settings.max_building_price;
+        let needs_energy = self.energy_generated as f32 <= ENERGY_PRODUCTION_CUTOFF * settings.max_building_price as f32 &&
+            self.energy as f32 <= ENERGY_STORAGE_CUTOFF * settings.max_building_price as f32;
             
         for b in BuildingType::all().iter() {
             let building_setting = settings.building_settings(*b);
index 6434c9d..251b980 100644 (file)
@@ -16,8 +16,15 @@ use std::io::prelude::*;
 use std::process;
 
 fn choose_move(settings: &engine::settings::GameSettings, state: &engine::GameState, start_time: &PreciseTime) -> Command {
-    #[cfg(not(feature = "reduced-time"))] let max_time = Duration::milliseconds(1950);
-    #[cfg(feature = "reduced-time")] let max_time = Duration::milliseconds(950);
+    #[cfg(not(feature = "reduced-time"))]
+    #[cfg(not(feature = "extended-time"))]
+    let max_time = Duration::milliseconds(1950);
+    
+    #[cfg(feature = "reduced-time")]
+    let max_time = Duration::milliseconds(950);
+
+    #[cfg(feature = "extended-time")]
+    let max_time = Duration::milliseconds(19950);
     
     strategy::monte_carlo::choose_move(settings, state, start_time, max_time)
 }