From 5ee312e452c483b95c8ca8fa5f2fb64adb4a2598 Mon Sep 17 00:00:00 2001 From: Natalie Date: Fri, 26 Jun 2026 18:07:58 -0400 Subject: [PATCH] =?UTF-8?q?refactor(@projects/@magic-civilization):=20?= =?UTF-8?q?=F0=9F=94=97=20break=20the=20mc-turn=E2=86=94mc-ecology=20depen?= =?UTF-8?q?dency=20cycle=20at=20its=20root=20(DIP)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mc-ecology depended on the entire mc-mapgen crate solely to reach `mc_mapgen::seed::*` — which is itself just a 13-line re-export of `mc_core::seed`. So a low-level ecology crate pulled in the high-level map generator to use a foundational RNG utility that already lives in mc-core (the WORLDGEN_RNG PCG64/SeedDomain/derive contract). Repoint fauna_select.rs + flora_select.rs to `mc_core::seed` directly and drop the mc-mapgen dependency. This cuts the mc-ecology → mc-mapgen edge, breaking the mc-turn → mc-ecology → mc-mapgen → mc-turn cycle that forced the ecology tick out of mc-turn::step into mc-player-api::apply_end_turn. Proven: `cargo check -p mc-turn` with an mc-ecology dep added now compiles (no cyclic error); reverted the probe pending the TurnPhase-registry step that will move ecology back into the unified phase list. mc-ecology 338/0 — determinism intact (seed code is byte-identical, was already mc-core via the re-export). Co-Authored-By: Claude Opus 4.8 (1M context) --- src/simulator/crates/mc-ecology/Cargo.toml | 1 - src/simulator/crates/mc-ecology/src/fauna_select.rs | 6 +++--- src/simulator/crates/mc-ecology/src/flora_select.rs | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/simulator/crates/mc-ecology/Cargo.toml b/src/simulator/crates/mc-ecology/Cargo.toml index 0d7921a7..34dfaeaf 100644 --- a/src/simulator/crates/mc-ecology/Cargo.toml +++ b/src/simulator/crates/mc-ecology/Cargo.toml @@ -10,7 +10,6 @@ gpu = ["dep:mc-compute"] mc-core = { path = "../mc-core" } mc-climate = { path = "../mc-climate" } mc-flora = { path = "../mc-flora" } -mc-mapgen = { path = "../mc-mapgen" } mc-profiling = { path = "../mc-profiling" } mc-compute = { path = "../mc-compute", optional = true, features = ["gpu"] } serde.workspace = true diff --git a/src/simulator/crates/mc-ecology/src/fauna_select.rs b/src/simulator/crates/mc-ecology/src/fauna_select.rs index 99767513..4533c0b8 100644 --- a/src/simulator/crates/mc-ecology/src/fauna_select.rs +++ b/src/simulator/crates/mc-ecology/src/fauna_select.rs @@ -9,7 +9,7 @@ use std::collections::{HashMap, HashSet}; use serde::Deserialize; -use mc_mapgen::seed::{SeedDomain, tile_rng}; +use mc_core::seed::{SeedDomain, tile_rng}; // ── Constants ───────────────────────────────────────────────────────────────── @@ -250,7 +250,7 @@ pub fn pick_fauna_for_tile( let normalised: Vec = weights.iter().map(|w| w / total).collect(); - let domain_seed = mc_mapgen::seed::derive(map_seed, SeedDomain::FaunaSelect); + let domain_seed = mc_core::seed::derive(map_seed, SeedDomain::FaunaSelect); let mut rng = tile_rng(domain_seed, col, row); // Draw candidates @@ -272,7 +272,7 @@ fn weighted_sample_fauna( eligible: &[&String], normalised: &[f32], max_count: usize, - rng: &mut mc_mapgen::seed::Pcg64, + rng: &mut mc_core::seed::Pcg64, specs: &HashMap, ) -> Vec { let n = eligible.len().min(max_count); diff --git a/src/simulator/crates/mc-ecology/src/flora_select.rs b/src/simulator/crates/mc-ecology/src/flora_select.rs index 0b94c8af..7b192bdf 100644 --- a/src/simulator/crates/mc-ecology/src/flora_select.rs +++ b/src/simulator/crates/mc-ecology/src/flora_select.rs @@ -12,7 +12,7 @@ use std::collections::HashMap; use serde::Deserialize; -use mc_mapgen::seed::{SeedDomain, tile_rng}; +use mc_core::seed::{SeedDomain, tile_rng}; // ── Aquatic / riparian species set ──────────────────────────────────────────── @@ -448,7 +448,7 @@ pub fn pick_flora_for_tile_stress( // Normalise by sum (never clip) let normalised: Vec = weights.iter().map(|w| w / total).collect(); - let domain_seed = mc_mapgen::seed::derive(map_seed, SeedDomain::FloraSelect); + let domain_seed = mc_core::seed::derive(map_seed, SeedDomain::FloraSelect); let mut rng = tile_rng(domain_seed, col, row); weighted_sample_without_replacement( @@ -465,7 +465,7 @@ fn weighted_sample_without_replacement( candidates: &[String], normalised: &[f32], max_count: usize, - rng: &mut mc_mapgen::seed::Pcg64, + rng: &mut mc_core::seed::Pcg64, specs: &HashMap, ) -> Vec { let n = candidates.len().min(max_count);