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
+37 -1
View File
@@ -18,25 +18,41 @@ inline constexpr std::uint32_t cellular_patch_pitch_um = 1'000;
inline constexpr std::uint32_t cellular_trial_perception_radius_um = 5'000;
inline constexpr std::size_t max_cellular_patches = 4'096;
inline constexpr std::uint32_t cellular_habitat_format = 1;
// ADR-0136 step A: format 2 holds deposits (pools and bubbles) at free micrometre centres,
// each with a stable id, a radius and a kind, and the next id to give a new deposit.
inline constexpr std::uint32_t cellular_habitat_deposit_format = 2;
inline constexpr std::size_t cellular_habitat_header_bytes = 72;
inline constexpr std::size_t cellular_patch_record_bytes = 56;
inline constexpr std::size_t cellular_deposit_record_bytes = 64;
inline constexpr std::size_t max_cellular_habitat_bytes =
cellular_habitat_header_bytes + cellular_patch_record_bytes * max_cellular_patches + 8;
cellular_habitat_header_bytes + cellular_deposit_record_bytes * max_cellular_patches + 8;
// A bubble's contact radius (tunable); pools carry their own.
inline constexpr std::uint32_t cellular_mote_radius_um = 30;
inline constexpr std::uint32_t max_cellular_deposit_radius_um = 5'000;
// A pool yields at most this share (per thousand) of a cell's intake rate per tick.
inline constexpr std::uint64_t cellular_pool_yield_per_thousand = 250;
enum class CellularDepositKind : std::uint8_t { patch, pool, mote };
struct CellularPatchAddress {
std::uint32_t x_um{}, y_um{};
auto operator<=>(const CellularPatchAddress&) const = default;
};
// Format 1: a 1 mm square patch at a pitch-aligned corner. Format 2: a deposit centred at
// `address`, a disc of `radius_um`; `id` is stable and only labels it for clients.
struct CellularPatch {
CellularPatchAddress address;
std::uint64_t source{}; // Explicit region-opening provenance.
accounting::Inventory stock{};
std::uint32_t id{}, radius_um{};
CellularDepositKind kind{};
auto operator<=>(const CellularPatch&) const = default;
};
struct CellularHabitatConfig {
std::uint64_t world{}, region{}, frame{};
std::uint32_t width_um{}, height_um{};
std::vector<CellularPatch> patches; // Strictly ordered by (x_um, y_um).
std::uint32_t format{cellular_habitat_format};
std::uint32_t next_deposit{}; // Format 2: above every deposit id.
auto operator<=>(const CellularHabitatConfig&) const = default;
};
struct CellularPatchUptakeProposal {
@@ -48,8 +64,13 @@ struct CellularPatchUptakeProposal {
struct CellularPatchPerception {
CellularPatchAddress address;
accounting::Inventory available;
std::uint32_t id{}, radius_um{}; // Format 2 deposits; zero for format 1 patches.
CellularDepositKind kind{};
auto operator<=>(const CellularPatchPerception&) const = default;
};
// Whether a cell's square footprint touches a patch (format 1 square) or a deposit's disc.
[[nodiscard]] bool cellular_patch_contact(CellularPosition position, std::uint32_t extent_um,
const CellularPatch& patch) noexcept;
enum class CellularHabitatError : std::uint8_t {
invalid_config,
invalid_patch,
@@ -65,6 +86,21 @@ enum class CellularHabitatError : std::uint8_t {
identity
};
// ADR-0136 step A opening: bubbles scattered over the whole area. Each holds `amount` on
// one channel (cycling through the channels `amount` stocks), three in ten of them in
// loose clumps; positions follow `seed` only, so a genesis is reproducible.
struct CellularMoteField {
std::uint32_t count{};
std::uint64_t source{};
accounting::Inventory amount{}; // Per bubble, per channel.
std::uint64_t seed{};
};
// A format-2 habitat of the given pools (centre, radius, source and stock; their ids and kind
// are assigned) and the scattered bubbles, sorted by address with ids 1..n.
[[nodiscard]] std::expected<CellularHabitatConfig, CellularHabitatError>
scatter_deposits(CellularHabitatConfig base, std::span<const CellularPatch> pools,
const CellularMoteField& field);
// Region-local finite food stock for the cellular trial. Empty/unlisted patches
// contain no stock. This is a read/proposal owner; the caller commits its patch
// and organism candidate together through the durable cellular state owner.
@@ -21,6 +21,10 @@ struct CellularRegionRules {
// Rules 2 (false) is the original trial: engulf intents are ignored and starvation
// corpses keep their inventory.
bool engulf_and_detritus{};
// ADR-0136 step A (format 2 habitats): every cell drains the deposits it touches, up to
// its intake rate, with no intake target; pools yield at most a quarter of that rate.
// A dead life's detritus becomes one bubble per non-empty channel.
bool contact_feeding{};
auto operator<=>(const CellularRegionRules&) const = default;
};
+41
View File
@@ -35,7 +35,15 @@ inline constexpr std::uint16_t session_protocol_v9 = 9;
// v10 adds a reliable owner choice for a previously earned cellular mutation offer.
// Its durable effect is committed on the next cellular tick.
inline constexpr std::uint16_t session_protocol_v10 = 10;
// v11 (ADR-0136 step A) is v10 with the owner's view of pools and bubbles (deposits)
// instead of square patches; every other message is v10's.
inline constexpr std::uint16_t session_protocol_v11 = 11;
// v10 and v11 share every cellular message but the perception's food list.
[[nodiscard]] constexpr bool cellular_v10_family(std::uint16_t version) noexcept {
return version == session_protocol_v10 || version == session_protocol_v11;
}
inline constexpr std::size_t max_cellular_perceived_patches = 256;
inline constexpr std::size_t max_cellular_perceived_deposits = 512;
inline constexpr std::size_t session_address_bytes = 64; // Endpoint or server name field.
inline constexpr std::size_t session_datagram_bytes = 1200; // Whole message, ADR-0089.
inline constexpr std::size_t session_header_bytes = 8;
@@ -238,6 +246,37 @@ struct CellularPerceivedPatch {
std::array<std::uint64_t, 4> matter_fg{};
friend bool operator==(const CellularPerceivedPatch&, const CellularPerceivedPatch&) = default;
};
// v11 (ADR-0136): one pool or bubble in range. Amounts travel as 16-bit log codes (about
// 0.2 % precision: enough to size, colour and fade them); the HUD's exact numbers stay in
// the diagnostics. `drained` is set when some cell took from it on this tick.
enum class CellularDepositShape : std::uint8_t { pool = 1, bubble = 2 };
struct CellularPerceivedDeposit {
std::uint32_t id{}, x_um{}, y_um{}; // Centre.
std::uint16_t radius_um{};
CellularDepositShape shape{CellularDepositShape::bubble};
bool drained{};
std::array<std::uint16_t, 5> amount_codes{}; // Energy, then C, N, P, other.
friend bool operator==(const CellularPerceivedDeposit&,
const CellularPerceivedDeposit&) = default;
};
// 0 for 0; otherwise 1 + 512 * floor(log2 v) + the next 9 bits of v.
[[nodiscard]] constexpr std::uint16_t deposit_amount_code(std::uint64_t value) noexcept {
if (value == 0)
return 0;
unsigned bit = 63;
while ((value >> bit) == 0)
--bit;
const auto fraction = bit >= 9 ? (value >> (bit - 9)) & 511U : (value << (9 - bit)) & 511U;
return static_cast<std::uint16_t>(1 + 512 * bit + fraction);
}
// The smallest amount with that code.
[[nodiscard]] constexpr std::uint64_t deposit_amount_value(std::uint16_t code) noexcept {
if (code == 0)
return 0;
const unsigned bit = (code - 1U) / 512U;
const std::uint64_t mantissa = 512U + (code - 1U) % 512U;
return bit >= 9 ? mantissa << (bit - 9) : mantissa >> (9 - bit);
}
enum class CellularMovementResult : std::uint8_t {
not_reported,
no_movement,
@@ -294,6 +333,8 @@ struct CellularPerception {
// Present only on v9 for an active life. The values are authoritative observations,
// not client claims or additional simulation state.
std::optional<CellularLifeDiagnostics> diagnostics;
// v11 only (then `patches` is empty): pools and bubbles in range, by ascending id.
std::vector<CellularPerceivedDeposit> deposits{};
friend bool operator==(const CellularPerception&, const CellularPerception&) = default;
};
struct IntentionReceipt {
@@ -63,10 +63,13 @@ inline constexpr CellularVersionBundle cellular_v6_versions{5, 6, 1, 1, 1, 2, 1,
inline constexpr CellularVersionBundle cellular_v7_versions{6, 6, 1, 1, 1, 3, 2, 2, 1};
// ADR-0137: rules 7 on owner envelope 6, with development 4 and founder 3.
inline constexpr CellularVersionBundle cellular_v8_versions{7, 6, 1, 1, 1, 4, 3, 2, 1};
// ADR-0136 step A: rules 8 on owner envelope 6 with habitat 2 (pools and bubbles).
inline constexpr CellularVersionBundle cellular_v9_versions{8, 6, 2, 1, 1, 4, 3, 2, 1};
// Bundles with genome revisions: the revision history profile and format-3 traces.
[[nodiscard]] constexpr bool cellular_revision_bundle(const CellularVersionBundle& b) noexcept {
return b == cellular_v3_versions || b == cellular_v4_versions || b == cellular_v5_versions ||
b == cellular_v6_versions || b == cellular_v7_versions || b == cellular_v8_versions;
b == cellular_v6_versions || b == cellular_v7_versions || b == cellular_v8_versions ||
b == cellular_v9_versions;
}
// Batch evidence bound by manifest v2 (ADR-0063); all zero at genesis.
@@ -38,6 +38,10 @@ inline constexpr std::uint32_t cellular_lives_balance_rules = 6;
// steps; development 4: reproduction cheapens buds), twin buds, and wildlife that engulfs.
// No new state, so they keep owner format 6.
inline constexpr std::uint32_t cellular_lives_reproduction_rules = 7;
// ADR-0136 step A: rules 8 are rules 7 on a format-2 habitat of pools and bubbles, fed by
// contact; detritus becomes bubbles and emptied deposits disappear. The habitat envelope
// carries the new state, so they keep owner format 6.
inline constexpr std::uint32_t cellular_lives_foraging_rules = 8;
// The founder a region of these rules creates.
[[nodiscard]] constexpr biology::FounderVersion
cellular_founder_version(std::uint32_t rules) noexcept {
@@ -174,7 +178,8 @@ enum class CellularLivesProfile : std::uint8_t {
budding,
presence,
balance,
reproduction
reproduction,
foraging
};
struct CellularLivesConfig {
biology::CellularArea area{};