Derive wildlife prey facts once per tick
Foundation / checks (ecs) (push) Successful in 2m20s
Foundation / checks (deploy) (push) Successful in 3m57s
Foundation / checks (tsan) (push) Failing after 16m50s
Foundation / checks (network) (push) Successful in 20m31s
Foundation / checks (client) (push) Successful in 21m44s
Foundation / checks (postgres) (push) Failing after 41m8s
Foundation / checks (checks) (push) Failing after 41m12s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped

The rules-7 engulf check derived every other cell's metabolic budget for each wildlife
cell, quadratic in budget derivations as buds multiply. The controller now derives each
cell's mass, extent and membrane once per call and compares those. Decisions are
unchanged; lifecycle and population tests pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-17 14:32:18 -04:00
co-authored by Claude Opus 5.5
parent aff35863ce
commit d5d10a0cc7
2 changed files with 38 additions and 18 deletions
@@ -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.
+37 -17
View File
@@ -68,6 +68,37 @@ wildlife_intents(const CellularLives& state, std::uint64_t tick) {
{707, -707}}};
const auto temperature = state.ambient_temperature_millikelvin();
std::vector<CellularLifeIntent> 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> 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;
}