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
+100 -5
View File
@@ -10,7 +10,7 @@
// evo-world-clone check-store --world W --region R --pg-* ... --objects DIR
// [--reserve-mib N]
// evo-world-clone provision --world W --region R --opening
// development-v1|primitive-v1|cellular-v1 to cellular-v6
// development-v1|primitive-v1|cellular-v1 to cellular-v7
// --pg-* ... --objects DIR --build HEX [--commit HEX32] [--retain-build]
// primitive-v1 also requires --frame N --source-id N, every --funding-*-* channel,
// and one or more ordered --site X,Y values.
@@ -21,6 +21,10 @@
// cellular-v4 on rules 5 (ADR-0128: offline freeze and resume).
// cellular-v5 on rules 6 (2026-10-15 balance: finer mutations, cheaper construction).
// cellular-v6 on rules 7 (ADR-0137: percentage mutations, skilled budding, twins).
// cellular-v7 on rules 8 (ADR-0136 step A: pools and bubbles fed by contact) takes no
// --patch: one or more --pool X,Y,RADIUS,SOURCE,ENERGY,C,N,P,O (centres, any micrometre)
// and/or --motes COUNT,SOURCE,ENERGY,C,N,P,O (bubbles per channel amount, scattered
// from the --commit bytes, so a genesis is reproducible).
// primitive-v1 and cellular-v1/v2/v3 accept --life-allocator-start N
// (ADR-0123): the world's life-identity allocator is created once at the operator-audited
// start N; a later run leaves it untouched and refuses one that is below N.
@@ -111,6 +115,8 @@ struct Options {
std::vector<server::SpawnSite> primitive_sites;
std::optional<std::uint32_t> cellular_width_um, cellular_height_um, cellular_temperature_mk;
std::vector<biology::CellularPatch> cellular_patches;
std::vector<biology::CellularPatch> cellular_pools; // cellular-v7
std::optional<biology::CellularMoteField> cellular_motes; // cellular-v7
std::optional<std::uint64_t> life_allocator_start;
std::optional<persistence::Sha256Digest> build;
bool retain_build{};
@@ -167,6 +173,55 @@ std::optional<biology::CellularPatch> cellular_patch(std::string_view text) {
result.stock.matter[i].value = fields[4 + i];
return result;
}
// Comma-separated unsigned fields, exactly N of them.
template <std::size_t N>
std::optional<std::array<std::uint64_t, N>> fields_of(std::string_view text) {
std::array<std::uint64_t, N> fields{};
for (std::size_t i = 0; i < N; ++i) {
const auto comma = text.find(',');
const auto field = i + 1 == N ? text : text.substr(0, comma);
if (field.empty() || (i + 1 != N && comma == std::string_view::npos))
return std::nullopt;
const auto [end, error] =
std::from_chars(field.data(), field.data() + field.size(), fields.at(i));
if (error != std::errc{} || end != field.data() + field.size())
return std::nullopt;
if (i + 1 != N)
text.remove_prefix(comma + 1);
else if (comma != std::string_view::npos)
return std::nullopt;
}
return fields;
}
// --pool X,Y,RADIUS,SOURCE,ENERGY,C,N,P,O
std::optional<biology::CellularPatch> cellular_pool(std::string_view text) {
const auto f = fields_of<9>(text);
if (!f || (*f)[0] > std::numeric_limits<std::uint32_t>::max() ||
(*f)[1] > std::numeric_limits<std::uint32_t>::max() ||
(*f)[2] > biology::max_cellular_deposit_radius_um)
return std::nullopt;
biology::CellularPatch pool{};
pool.address = {static_cast<std::uint32_t>((*f)[0]), static_cast<std::uint32_t>((*f)[1])};
pool.radius_um = static_cast<std::uint32_t>((*f)[2]);
pool.source = (*f)[3];
pool.stock.energy.value = (*f)[4];
for (std::size_t i = 0; i < pool.stock.matter.size(); ++i)
pool.stock.matter.at(i).value = (*f)[5 + i];
return pool;
}
// --motes COUNT,SOURCE,ENERGY,C,N,P,O
std::optional<biology::CellularMoteField> cellular_motes(std::string_view text) {
const auto f = fields_of<7>(text);
if (!f || (*f)[0] > biology::max_cellular_patches)
return std::nullopt;
biology::CellularMoteField field{};
field.count = static_cast<std::uint32_t>((*f)[0]);
field.source = (*f)[1];
field.amount.energy.value = (*f)[2];
for (std::size_t i = 0; i < field.amount.matter.size(); ++i)
field.amount.matter.at(i).value = (*f)[3 + i];
return field;
}
template <std::size_t N> std::optional<std::array<std::uint8_t, N>> hex(std::string_view text) {
if (text.size() != N * 2)
return std::nullopt;
@@ -278,7 +333,7 @@ std::optional<Options> parse(int argc, char** argv) {
else if (o.command == "provision" && flag == "--opening" &&
(value == "development-v1" || value == "primitive-v1" || value == "cellular-v1" ||
value == "cellular-v2" || value == "cellular-v3" || value == "cellular-v4" ||
value == "cellular-v5" || value == "cellular-v6"))
value == "cellular-v5" || value == "cellular-v6" || value == "cellular-v7"))
o.opening = value;
else if (o.command == "provision" && flag == "--frame" && n)
o.primitive_frame = n;
@@ -313,6 +368,16 @@ std::optional<Options> parse(int argc, char** argv) {
if (!parsed || o.cellular_patches.size() == biology::max_cellular_patches)
return std::nullopt;
o.cellular_patches.push_back(*parsed);
} else if (o.command == "provision" && flag == "--pool") {
const auto parsed = cellular_pool(value);
if (!parsed || o.cellular_pools.size() == biology::max_cellular_patches)
return std::nullopt;
o.cellular_pools.push_back(*parsed);
} else if (o.command == "provision" && flag == "--motes") {
const auto parsed = cellular_motes(value);
if (!parsed || o.cellular_motes)
return std::nullopt;
o.cellular_motes = parsed;
} else if (o.command == "provision" && flag == "--life-allocator-start" && n && *n > 0 &&
*n < std::numeric_limits<std::uint64_t>::max())
o.life_allocator_start = n;
@@ -343,7 +408,8 @@ std::optional<Options> parse(int argc, char** argv) {
std::ranges::any_of(o.primitive_funding, [](const auto& v) { return v.has_value(); }) ||
!o.primitive_sites.empty();
const bool cellular_options = o.cellular_width_um || o.cellular_height_um ||
o.cellular_temperature_mk || !o.cellular_patches.empty();
o.cellular_temperature_mk || !o.cellular_patches.empty() ||
!o.cellular_pools.empty() || o.cellular_motes;
if (o.opening == "primitive-v1") {
if (!o.primitive_frame || *o.primitive_frame == 0 || !o.primitive_source ||
*o.primitive_source == 0 || o.primitive_sites.empty() ||
@@ -352,9 +418,22 @@ std::optional<Options> parse(int argc, char** argv) {
return std::nullopt;
if (cellular_options)
return std::nullopt;
} else if (o.opening == "cellular-v7") {
// Pools and bubbles only: square patches belong to the earlier openings.
if (!o.primitive_frame || *o.primitive_frame == 0 || !o.primitive_source ||
*o.primitive_source == 0 || o.primitive_sites.empty() ||
!std::ranges::all_of(o.primitive_funding,
[](const auto& v) { return v.has_value(); }) ||
!o.cellular_width_um || !o.cellular_height_um || !o.cellular_temperature_mk ||
!o.cellular_patches.empty() ||
(o.cellular_pools.empty() && (!o.cellular_motes || o.cellular_motes->count == 0)) ||
!o.commit)
return std::nullopt;
} else if (o.opening == "cellular-v1" || o.opening == "cellular-v2" ||
o.opening == "cellular-v3" || o.opening == "cellular-v4" ||
o.opening == "cellular-v5" || o.opening == "cellular-v6") {
if (!o.cellular_pools.empty() || o.cellular_motes)
return std::nullopt;
const bool has_stock = std::ranges::any_of(o.cellular_patches, [](const auto& patch) {
return patch.stock.energy.value != 0 ||
std::ranges::any_of(patch.stock.matter,
@@ -465,7 +544,8 @@ int provision(const Options& o) {
const bool primitive = o.opening == "primitive-v1";
const bool cellular = o.opening == "cellular-v1" || o.opening == "cellular-v2" ||
o.opening == "cellular-v3" || o.opening == "cellular-v4" ||
o.opening == "cellular-v5" || o.opening == "cellular-v6";
o.opening == "cellular-v5" || o.opening == "cellular-v6" ||
o.opening == "cellular-v7";
const auto primitive_frame = o.primitive_frame.value_or(0);
if ((primitive || cellular) && primitive_frame == 0)
return 2;
@@ -560,6 +640,20 @@ int provision(const Options& o) {
habitat_config.width_um = cellular_width_um;
habitat_config.height_um = cellular_height_um;
habitat_config.patches = o.cellular_patches;
if (o.opening == "cellular-v7") {
// ADR-0136 step A: pools and bubbles scattered from the genesis commit's bytes.
auto field = o.cellular_motes.value_or(biology::CellularMoteField{0, 1, {}, 0});
const auto commit = o.commit.value_or(persistence::Uuid{});
for (std::size_t i = 0; i < 8; ++i)
field.seed = (field.seed << 8U) | commit.at(i);
auto scattered = biology::scatter_deposits(habitat_config, o.cellular_pools, field);
if (!scattered) {
std::printf("cellular habitat refused %u\n",
static_cast<unsigned>(scattered.error()));
return 4;
}
habitat_config = std::move(*scattered);
}
auto habitat = biology::CellularHabitat::create(std::move(habitat_config));
if (!habitat) {
std::printf("cellular habitat refused %u\n", static_cast<unsigned>(habitat.error()));
@@ -568,7 +662,8 @@ int provision(const Options& o) {
auto opening = server::CellularLives::create(
*primitive_opening, std::move(*habitat),
{{cellular_width_um, cellular_height_um}, 0, cellular_temperature_mk},
o.opening == "cellular-v6" ? server::CellularLivesProfile::reproduction
o.opening == "cellular-v7" ? server::CellularLivesProfile::foraging
: o.opening == "cellular-v6" ? server::CellularLivesProfile::reproduction
: o.opening == "cellular-v5" ? server::CellularLivesProfile::balance
: o.opening == "cellular-v4" ? server::CellularLivesProfile::presence
: o.opening == "cellular-v3" ? server::CellularLivesProfile::budding