diff --git a/deploy/kubernetes/region/dev-session-route/listener.yaml b/deploy/kubernetes/region/dev-session-route/listener.yaml index 6e33b8f..b36c859 100644 --- a/deploy/kubernetes/region/dev-session-route/listener.yaml +++ b/deploy/kubernetes/region/dev-session-route/listener.yaml @@ -12,7 +12,7 @@ spec: env: - {name: REGION_SESSION, value: "dev"} - {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"} - - {name: REGION_SESSION_WINDOW, value: "dev-20261017T145627-23067:1792259787"} + - {name: REGION_SESSION_WINDOW, value: "dev-20261017T183218-47482:1792272738"} - {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"} ports: # QUIC (ADR-0090): UDP only; nothing listens on TCP 7400. diff --git a/src/server/lifecycle/wildlife_controller.cpp b/src/server/lifecycle/wildlife_controller.cpp index f6bae10..5a6fb94 100644 --- a/src/server/lifecycle/wildlife_controller.cpp +++ b/src/server/lifecycle/wildlife_controller.cpp @@ -68,6 +68,37 @@ wildlife_intents(const CellularLives& state, std::uint64_t tick) { {707, -707}}}; const auto temperature = state.ambient_temperature_millikelvin(); std::vector intents; + // Rules 7 prey facts for every cell in the world, derived once per tick: a per-hunter + // derivation made the step quadratic in metabolic budgets. + struct Prey { + std::uint64_t life{}; + biology::CellularPosition position; + std::uint32_t extent{}, membrane{}; + std::uint64_t mass{}; + }; + std::vector prey_facts; + const bool hunting = state.rules_version() >= cellular_lives_reproduction_rules && + std::ranges::any_of(state.lives(), [](const CellularOwnedLife& life) { + return life.account == LifeAccount{}; + }); + if (hunting) { + prey_facts.reserve(state.lives().size()); + for (const auto& other : state.lives()) { + if (other.presence == CellularPresence::suspended) + continue; + const auto other_genome = state.archive().find(other.identity.genome); + if (!other_genome) + return std::unexpected{CellularLivesError::archive}; + const auto other_budget = + biology::metabolic_budget(*other_genome, other.growth, {temperature, {}}); + const auto membrane = other_genome->parameter(biology::Capability::membrane); + if (!other_budget || !membrane) + return std::unexpected{CellularLivesError::biology}; + prey_facts.push_back({other.identity.life, other.position, + other_budget->phenotype.extent, *membrane, + other_budget->phenotype.total_mass}); + } + } for (const auto& life : state.lives()) { if (life.account != LifeAccount{}) continue; @@ -88,25 +119,14 @@ wildlife_intents(const CellularLives& state, std::uint64_t tick) { // Rules 7 (ADR-0137): engulf a touching cell the region step would let it take // (ADR-0124: mass at least 1.5 x the prey's per micrometre of prey membrane), // players' cells included; otherwise feed. - if (state.rules_version() >= cellular_lives_reproduction_rules) { + if (hunting) { bool prey = false; - for (const auto& other : state.lives()) { - if (other.identity.life == life.identity.life || - other.presence == CellularPresence::suspended) + for (const auto& other : prey_facts) { + if (other.life == life.identity.life || + !biology::cellular_footprints_contact(life.position, extent, other.position, + other.extent)) continue; - const auto other_genome = state.archive().find(other.identity.genome); - if (!other_genome) - return std::unexpected{CellularLivesError::archive}; - const auto other_budget = - biology::metabolic_budget(*other_genome, other.growth, {temperature, {}}); - const auto membrane = other_genome->parameter(biology::Capability::membrane); - if (!other_budget || !membrane) - return std::unexpected{CellularLivesError::biology}; - if (!biology::cellular_footprints_contact(life.position, extent, other.position, - other_budget->phenotype.extent)) - continue; - if (can_engulf(budget->phenotype.total_mass, other_budget->phenotype.total_mass, - *membrane)) { + if (can_engulf(budget->phenotype.total_mass, other.mass, other.membrane)) { prey = true; break; }