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
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:
@@ -535,7 +535,11 @@ CellularLives::create(const PrimitiveLives& opening,
|
||||
const auto world = nursery_config.world;
|
||||
const auto region = nursery_config.region;
|
||||
const auto frame = nursery_config.frame;
|
||||
const bool reproduction = profile == CellularLivesProfile::reproduction; // Rules 7.
|
||||
const bool foraging = profile == CellularLivesProfile::foraging; // Rules 8.
|
||||
// A rules-8 opening needs a deposit habitat, and only it may have one.
|
||||
if (foraging != (habitat->config().format == biology::cellular_habitat_deposit_format))
|
||||
return std::unexpected{CellularLivesError::habitat};
|
||||
const bool reproduction = profile == CellularLivesProfile::reproduction || foraging;
|
||||
const bool balance = profile == CellularLivesProfile::balance || reproduction; // Rules 6+.
|
||||
const bool presence = profile == CellularLivesProfile::presence || balance;
|
||||
const bool budding = profile == CellularLivesProfile::budding || presence;
|
||||
@@ -550,12 +554,13 @@ CellularLives::create(const PrimitiveLives& opening,
|
||||
: budding ? cellular_lives_bud_format
|
||||
: engulf ? cellular_lives_engulf_format
|
||||
: cellular_lives_format,
|
||||
reproduction ? cellular_lives_reproduction_rules
|
||||
: balance ? cellular_lives_balance_rules
|
||||
: presence ? cellular_lives_presence_rules
|
||||
: budding ? cellular_lives_bud_rules
|
||||
: engulf ? cellular_lives_engulf_rules
|
||||
: cellular_lives_rules);
|
||||
foraging ? cellular_lives_foraging_rules
|
||||
: reproduction ? cellular_lives_reproduction_rules
|
||||
: balance ? cellular_lives_balance_rules
|
||||
: presence ? cellular_lives_presence_rules
|
||||
: budding ? cellular_lives_bud_rules
|
||||
: engulf ? cellular_lives_engulf_rules
|
||||
: cellular_lives_rules);
|
||||
return std::unique_ptr<CellularLives>{new CellularLives{std::move(state)}};
|
||||
}
|
||||
|
||||
@@ -984,7 +989,8 @@ CellularLives::restore(std::span<const std::uint8_t> bytes, std::uint64_t world,
|
||||
format_version == cellular_lives_presence_format &&
|
||||
(rules_version == cellular_lives_presence_rules ||
|
||||
rules_version == cellular_lives_balance_rules ||
|
||||
rules_version == cellular_lives_reproduction_rules);
|
||||
rules_version == cellular_lives_reproduction_rules ||
|
||||
rules_version == cellular_lives_foraging_rules);
|
||||
// Formats 5 and 6 carry the bud sequence and parent lives (rules 4 and 5).
|
||||
const bool bud_version = presence_version || (magic == cellular_lives_v5_magic &&
|
||||
format_version == cellular_lives_bud_format &&
|
||||
@@ -1169,6 +1175,10 @@ CellularLives::restore(std::span<const std::uint8_t> bytes, std::uint64_t world,
|
||||
return std::unexpected{CellularLivesError::checksum};
|
||||
return std::unexpected{CellularLivesError::habitat};
|
||||
}
|
||||
// Rules 8 run on a deposit habitat, and nothing else does (ADR-0136).
|
||||
if ((rules_version >= cellular_lives_foraging_rules) !=
|
||||
((*habitat)->config().format == biology::cellular_habitat_deposit_format))
|
||||
return std::unexpected{CellularLivesError::habitat};
|
||||
auto archive = biology::LineageArchive::decode(archive_payload);
|
||||
if (!archive) {
|
||||
if (archive.error() == biology::ArchiveCodecError::version)
|
||||
@@ -1248,6 +1258,7 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
|
||||
return std::unexpected{CellularLivesError::version};
|
||||
// Rules 4 keep rules 3 (engulfment, detritus) and add budding (ADR-0125).
|
||||
const bool engulf_rules = state_->rules_version >= cellular_lives_engulf_rules;
|
||||
const bool contact_rules = state_->rules_version >= cellular_lives_foraging_rules;
|
||||
const bool bud_rules = state_->rules_version >= cellular_lives_bud_rules;
|
||||
const bool presence_rules = state_->rules_version >= cellular_lives_presence_rules;
|
||||
for (std::size_t i = 0; i < ordered.size(); ++i) {
|
||||
@@ -1319,8 +1330,9 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
|
||||
*membrane,
|
||||
life.source});
|
||||
}
|
||||
auto proposal = biology::propose_cellular_region_step(state_->config.tick, state_->config.area,
|
||||
inputs, *state_->habitat, {engulf_rules});
|
||||
auto proposal =
|
||||
biology::propose_cellular_region_step(state_->config.tick, state_->config.area, inputs,
|
||||
*state_->habitat, {engulf_rules, contact_rules});
|
||||
if (!proposal)
|
||||
return std::unexpected{CellularLivesError::region_step};
|
||||
|
||||
@@ -1606,13 +1618,25 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
|
||||
found->stock = update.stock;
|
||||
}
|
||||
// Rules 3 detritus at empty cells becomes new patches; create() revalidates the map.
|
||||
for (const auto& made : proposal->new_patches) {
|
||||
// Format 2 (ADR-0136): new bubbles take the next deposit ids, and a deposit emptied this
|
||||
// tick is gone.
|
||||
const bool deposits = habitat_config.format == biology::cellular_habitat_deposit_format;
|
||||
for (auto made : proposal->new_patches) {
|
||||
const auto at = std::ranges::lower_bound(habitat_config.patches, made.address, {},
|
||||
[](const auto& patch) { return patch.address; });
|
||||
if (at != habitat_config.patches.end() && at->address == made.address)
|
||||
return std::unexpected{CellularLivesError::habitat};
|
||||
if (deposits) {
|
||||
if (habitat_config.next_deposit == std::numeric_limits<std::uint32_t>::max())
|
||||
return std::unexpected{CellularLivesError::overflow};
|
||||
made.id = habitat_config.next_deposit++;
|
||||
}
|
||||
habitat_config.patches.insert(at, made);
|
||||
}
|
||||
if (deposits)
|
||||
std::erase_if(habitat_config.patches, [](const biology::CellularPatch& patch) {
|
||||
return patch.stock == accounting::Inventory{};
|
||||
});
|
||||
auto next_habitat = biology::CellularHabitat::create(std::move(habitat_config));
|
||||
if (!next_habitat)
|
||||
return std::unexpected{CellularLivesError::habitat};
|
||||
|
||||
Reference in New Issue
Block a user