feat(simulator): Implement carrying capacity migration logic for ecology simulation engine

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
autocommit 2026-06-06 16:03:16 -07:00
parent a8aa0847ad
commit 77316f105d

View file

@ -325,6 +325,24 @@ impl EcologyEngine {
// 3. Habitat-gradient dispersal between tiles
self.run_dispersal(grid);
// 3b. Carrying-capacity migration: species over a tile's carrying
// capacity push surplus population into the best eligible neighbour.
// Computed from the current populations, then applied in-place.
// Deterministic — `compute_migrations` is a pure function of the
// populations, registry, grid, and `seed`; `offset_neighbors`
// walks neighbours in a fixed order.
{
let (w, h) = (grid.width, grid.height);
let migrations = crate::generation::compute_migrations(
&self.tile_populations,
&self.species_registry,
grid,
seed,
|col, row| mc_core::algorithms::hex::offset_neighbors(col, row, w, h),
);
crate::generation::apply_migrations(&mut self.tile_populations, &migrations);
}
// 4. Tier advancement
self.run_tier_advancement(grid);