refactor(simulator): ♻️ Update Rust simulation engine and traits to add/modify AI-driven logic for threat assessment, including ThreatAssessor and core simulation function improvements

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
autocommit 2026-04-16 13:29:26 -07:00
parent 3e3403a746
commit 4fc3170bc5
2 changed files with 7 additions and 4 deletions

View file

@ -1,4 +1,4 @@
use std::collections::{BTreeMap, HashMap, HashSet};
use std::collections::{BTreeMap, BTreeSet, HashMap};
use mc_core::algorithms::hex;
use mc_core::grid::GridState;
@ -418,7 +418,10 @@ impl EcologyEngine {
// Pre-pass: count T10 slots per diet across all tiles.
// Diets exceeding the cap get their terrain_tier_cap reduced to 9 this tick.
let mut t10_count_by_diet: HashMap<Diet, usize> = HashMap::new();
// BTreeMap/BTreeSet used instead of HashMap/HashSet so iteration order is
// deterministic across processes — RandomState hashing would otherwise
// vary turn-to-turn and perturb float accumulation in downstream systems.
let mut t10_count_by_diet: BTreeMap<Diet, usize> = BTreeMap::new();
for slots in self.tile_populations.values() {
for slot in slots {
if slot.tier >= 10 {
@ -428,7 +431,7 @@ impl EcologyEngine {
}
}
}
let saturated_diets: HashSet<Diet> = t10_count_by_diet
let saturated_diets: BTreeSet<Diet> = t10_count_by_diet
.iter()
.filter(|(_, &count)| count >= Self::GLOBAL_T10_PER_DIET_CAP)
.map(|(&diet, _)| diet)

View file

@ -10,7 +10,7 @@ pub enum Size {
Huge,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Diet {
Producer,