Cellular rules 8: pools and bubbles fed by contact (ADR-0136 step A)
Foundation / checks (checks) (push) Successful in 47m40s
Foundation / checks (client) (push) Successful in 17m27s
Foundation / checks (deploy) (push) Successful in 4m17s
Foundation / checks (ecs) (push) Successful in 4m31s
Foundation / checks (network) (push) Successful in 22m1s
Foundation / checks (tsan) (push) Successful in 13m10s
Foundation / checks (postgres) (push) Successful in 20m54s
Foundation / image (push) Successful in 4m15s
Foundation / postgres-tools (push) Successful in 5m32s
Foundation / server-image (push) Successful in 7m15s

Square patches invited camping and left the space between them empty. Rules 8 run on a
format-2 habitat of deposits:
- pools and single-nutrient bubbles at free micrometre centres, each with a stable id
  and a contact radius; the cellular-v7 opening scatters bubbles reproducibly from the
  genesis commit (three in ten in loose clumps) and lists pools with --pool;
- every cell drains what it touches, up to its intake rate per tick, with no target; a
  pool gives at most a quarter of that rate; an emptied deposit disappears;
- a dead cell's detritus breaks into one bubble per non-empty channel;
- wildlife swims to the nearest non-empty deposit and feeds by touch.

Bundle v9 (habitat 2) and schema v43 admit it. Session v11 carries the owner's 512
nearest deposits (id, centre, radius, shape, a drained flag and 16-bit amount codes)
instead of patches; every other cellular message is v10's. The client asks for v11,
draws bubbles (nutrient-coloured, pulsing while drained, popping when gone) and pools as
puddles, slows near food and sends no feed target; the HUD summarises food in range.
Earlier rules, regions and v10 clients are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-17 00:38:21 -04:00
co-authored by Claude Opus 5.5
parent 1d9af1d28e
commit be69cae652
35 changed files with 1311 additions and 112 deletions
+90
View File
@@ -1121,6 +1121,95 @@ void twin_roll_follows_reproduction() {
CHECK(founder > 800 && founder < 1'200); // About 1,000 of 4,000.
CHECK(full > 1'800 && full < 2'200 && full > founder);
}
// ADR-0136 step A (rules 8): a deposit habitat is scattered reproducibly; a cell feeds by
// touching bubbles and pools with no target (a pool at most at a quarter rate), an emptied
// bubble disappears, a starved cell breaks into new bubbles, and totals never change.
void rules_eight_cells_forage_by_contact() {
using namespace evo::biology;
CellularHabitatConfig base{98, 1, 7, 6'000, 6'000, {}};
// A pool far from the founder's site, and a line of small energy bubbles east of it.
CellularPatch pool{};
pool.address = {5'000, 5'000};
pool.radius_um = 400;
pool.source = 31;
pool.stock = {{10'000'000'000}, {{{100'000'000}, {100'000'000}, {100'000'000}, {100'000'000}}}};
const CellularMoteField field{40, 32, {{2'000'000}, {{{50'000}, {0}, {0}, {0}}}}, 0x5EED};
const auto scattered = scatter_deposits(base, std::array{pool}, field);
CHECK(scattered && scattered->format == cellular_habitat_deposit_format &&
scattered->patches.size() == 41 && scattered->next_deposit == 42);
CHECK(scatter_deposits(base, std::array{pool}, field) == scattered); // Reproducible.
auto other_seed = field;
other_seed.seed = 0x5EEE;
CHECK(scatter_deposits(base, std::array{pool}, other_seed) != scattered);
auto config = *scattered;
// A row of bubbles right in front of the founder: centres 120 um apart from x = 300.
for (std::uint32_t i = 0; i < 6; ++i) {
CellularPatch bubble{};
bubble.address = {300 + 120 * i, 5}; // On the founder's path along y = 0.
bubble.radius_um = cellular_mote_radius_um;
bubble.kind = CellularDepositKind::mote;
bubble.source = 33;
bubble.stock.energy.value = 2'000; // Less than a tick of intake: one pass empties it.
bubble.id = config.next_deposit++;
config.patches.push_back(bubble);
}
std::ranges::sort(config.patches, {}, &CellularPatch::address);
auto habitat = CellularHabitat::create(config);
CHECK(habitat);
const auto restored = CellularHabitat::restore((*habitat)->snapshot(), 98, 1, 7);
CHECK(restored && (*restored)->config() == (*habitat)->config());
auto primitive =
PrimitiveLives::create({98, 1, 7, 17, founder_price(2), {{0, 0}, {3'000, 3'000}}});
CHECK(primitive);
// A rules-8 opening needs a deposit habitat, and the reverse.
auto square = CellularHabitat::create({98, 1, 7, 6'000, 6'000, {}});
CHECK(square);
CHECK(CellularLives::create(**primitive, std::move(*square), {{6'000, 6'000}, 0, 293'150},
CellularLivesProfile::foraging)
.error() == CellularLivesError::habitat);
auto created =
CellularLives::create(**primitive, std::move(*habitat), {{6'000, 6'000}, 0, 293'150},
CellularLivesProfile::foraging);
CHECK(created);
auto owner = std::move(*created);
CHECK(owner->rules_version() == cellular_lives_foraging_rules);
const std::span<const CellularLifeIntent> no_lives{};
CHECK(owner->advance_tick(no_lives));
LifeRequest request{};
request.account.back() = 11;
request.action = 1;
auto born = owner->birth_candidate(request, {801, 801, 801, 801, {owner->tick()}});
CHECK(born);
owner = std::move(*born);
CHECK(owner->lives().front().position == (CellularPosition{0, 0}));
const auto bubbles_before = owner->habitat().patches().size();
// Swim east along the row: no intake target, yet the reserve gains energy and bubbles go.
CellularStepIntent east{};
east.movement = {1'000, 0};
bool fed = false;
for (int tick = 0; tick < 120; ++tick) {
CHECK(owner->advance_tick(std::array{CellularLifeIntent{801, east}}));
fed = fed || owner->last_tick_feedback().front().intake == CellularIntakeStatus::acquired;
CHECK(owner->current_total() == owner->opening_total());
}
CHECK(fed);
CHECK(owner->habitat().patches().size() < bubbles_before); // Emptied bubbles are gone.
const auto saved = owner->snapshot();
const auto again = CellularLives::restore(saved, 98, 1, 7, owner->tick());
CHECK(again && (*again)->snapshot() == saved);
// Starve: stand still where nothing lies. The corpse breaks into new bubbles with new ids.
const auto next_id = owner->habitat().config().next_deposit;
for (int tick = 0; tick < 20'000 && !owner->lives().empty(); ++tick)
CHECK(owner->advance_tick(std::array{CellularLifeIntent{801, CellularStepIntent{}}}));
CHECK(owner->lives().empty());
CHECK(owner->habitat().config().next_deposit > next_id);
CHECK(std::ranges::any_of(owner->habitat().patches(), [&](const CellularPatch& patch) {
return patch.id >= next_id && patch.kind == CellularDepositKind::mote;
}));
CHECK(owner->current_total() == owner->opening_total());
}
} // namespace
int main() {
@@ -1137,6 +1226,7 @@ int main() {
wildlife_steering_stays_within_the_intent_limit();
rules_seven_bud_twins_and_wildlife_hunts();
twin_roll_follows_reproduction();
rules_eight_cells_forage_by_contact();
std::puts(
"PASS cellular lives: feeding, tick ownership, terminal closure, rules 3, budding");
} catch (const std::exception& error) {