feat(simulator): ✨ Implement carrying capacity migration logic for ecology simulation engine
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
a8aa0847ad
commit
77316f105d
1 changed files with 18 additions and 0 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue