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:
@@ -773,6 +773,79 @@ void draw_patch(ImDrawList& list, const ScenePatch& p) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// The channel a deposit mostly holds (by its share of the largest amount): its colour.
|
||||
std::size_t dominant_channel(const std::array<std::uint64_t, 5>& stock) {
|
||||
std::size_t best = 0;
|
||||
for (std::size_t c = 1; c < stock.size(); ++c)
|
||||
if (stock.at(c) > stock.at(best))
|
||||
best = c;
|
||||
return best;
|
||||
}
|
||||
// ADR-0136: a bubble is a translucent circle in its nutrient's colour, sized by what it
|
||||
// holds (never below its contact disc), and pulsing while something drains it.
|
||||
void draw_bubble(ImDrawList& list, const SceneDeposit& d, float time) {
|
||||
const auto channel = dominant_channel(d.stock);
|
||||
const auto total = static_cast<double>(std::max<std::uint64_t>(1, d.stock.at(channel)));
|
||||
const float scale =
|
||||
std::clamp(0.7F + 0.12F * static_cast<float>(std::log10(total)), 0.8F, 2.2F);
|
||||
float r = std::max(d.radius * scale * 0.5F, 2.5F);
|
||||
if (d.drained)
|
||||
r *=
|
||||
1.0F + 0.25F * (0.5F + 0.5F * std::sin(time * 18.0F + static_cast<float>(d.seed % 7U)));
|
||||
auto color = nutrient_colors.at(channel);
|
||||
const auto alpha = static_cast<unsigned>(d.stale ? 90 : (d.drained ? 255 : 200));
|
||||
color = (color & 0x00FFFFFFU) | (alpha << IM_COL32_A_SHIFT);
|
||||
list.AddCircleFilled({d.x, d.y}, r, (color & 0x00FFFFFFU) | ((alpha / 3) << IM_COL32_A_SHIFT));
|
||||
list.AddCircle({d.x, d.y}, r, color, 0, std::max(1.0F, r * 0.18F));
|
||||
list.AddCircleFilled({d.x - r * 0.35F, d.y - r * 0.35F}, std::max(0.8F, r * 0.22F),
|
||||
IM_COL32(255, 255, 255, d.stale ? 40 : 110));
|
||||
}
|
||||
// A pool is a puddle: a seeded, wobbling outline around its contact disc, granules inside
|
||||
// in its nutrients' colours, fewer as it drains.
|
||||
void draw_pool(ImDrawList& list, const SceneDeposit& d, float time) {
|
||||
const float r = std::max(d.radius, 8.0F);
|
||||
constexpr int points = 28;
|
||||
for (int i = 0; i < points; ++i) {
|
||||
const float a = 6.2832F * static_cast<float>(i) / points;
|
||||
const auto key = d.seed * 7919U + static_cast<std::uint64_t>(i);
|
||||
const float wobble = 0.82F + 0.3F * unit_of(key) + 0.04F * std::sin(time * 0.7F + a * 3);
|
||||
list.PathLineTo({d.x + std::cos(a) * r * wobble, d.y + std::sin(a) * r * wobble});
|
||||
}
|
||||
list.PathFillConvex(IM_COL32(52, 40, 58, d.stale ? 50 : 110));
|
||||
for (int i = 0; i < points; ++i) {
|
||||
const float a = 6.2832F * static_cast<float>(i) / points;
|
||||
const auto key = d.seed * 7919U + static_cast<std::uint64_t>(i);
|
||||
const float wobble = 0.82F + 0.3F * unit_of(key) + 0.04F * std::sin(time * 0.7F + a * 3);
|
||||
list.PathLineTo({d.x + std::cos(a) * r * wobble, d.y + std::sin(a) * r * wobble});
|
||||
}
|
||||
list.PathStroke(IM_COL32(120, 96, 130, d.drained ? 220 : 140), ImDrawFlags_Closed, 1.5F);
|
||||
const float grain = std::clamp(r * 0.05F, 1.5F, 5.0F);
|
||||
for (std::size_t channel = 0; channel < d.stock.size(); ++channel) {
|
||||
const auto amount = d.stock.at(channel);
|
||||
if (amount == 0)
|
||||
continue;
|
||||
const auto count = std::clamp(
|
||||
static_cast<int>(2.0 + 3.0 * std::log10(static_cast<double>(amount) / 1.0e5)), 1, 40);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
const auto key = d.seed * 131U + channel * 977U + static_cast<std::uint64_t>(i);
|
||||
const float a = unit_of(key) * 6.2832F, dist = std::sqrt(unit_of(key + 3U)) * r * 0.75F;
|
||||
auto color = nutrient_colors.at(channel);
|
||||
if (d.stale)
|
||||
color = (color & 0x00FFFFFFU) | (110U << IM_COL32_A_SHIFT);
|
||||
list.AddCircleFilled({d.x + std::cos(a) * dist, d.y + std::sin(a) * dist},
|
||||
grain * (0.7F + 0.6F * unit_of(key + 5U)), color);
|
||||
}
|
||||
}
|
||||
}
|
||||
void draw_pop(ImDrawList& list, const ScenePop& p) {
|
||||
const float t = std::clamp(p.age, 0.0F, 1.0F);
|
||||
const auto alpha = static_cast<unsigned>(220.0F * (1.0F - t));
|
||||
const auto color =
|
||||
(nutrient_colors.at(static_cast<std::size_t>(std::clamp(p.channel, 0, 4))) & 0x00FFFFFFU) |
|
||||
(alpha << IM_COL32_A_SHIFT);
|
||||
list.AddCircle({p.x, p.y}, std::max(p.radius, 3.0F) * (0.6F + 1.6F * t), color, 0,
|
||||
1.5F * (1.0F - t) + 0.5F);
|
||||
}
|
||||
// The eyepiece: everything outside a rounded viewport is masked (a thick rounded stroke
|
||||
// covers the corners) and a vignette darkens toward the rim. Zooming out of the cellular
|
||||
// plane will later shrink this frame.
|
||||
@@ -823,6 +896,14 @@ void draw_scene(const PanelView& v) {
|
||||
const auto time = static_cast<float>(ImGui::GetTime());
|
||||
for (const auto& patch : v.cellular_scene->patches)
|
||||
draw_patch(list, patch);
|
||||
for (const auto& deposit : v.cellular_scene->deposits)
|
||||
if (deposit.pool)
|
||||
draw_pool(list, deposit, time);
|
||||
for (const auto& deposit : v.cellular_scene->deposits)
|
||||
if (!deposit.pool)
|
||||
draw_bubble(list, deposit, time);
|
||||
for (const auto& pop : v.cellular_scene->pops)
|
||||
draw_pop(list, pop);
|
||||
for (const auto& cell : v.cellular_scene->cells)
|
||||
draw_cell(list, cell, time);
|
||||
draw_eyepiece(list, ImGui::GetIO().DisplaySize);
|
||||
@@ -1081,7 +1162,23 @@ void hud_notes(const PanelView& v, FormBuffers& form, PanelActions& a, bool comp
|
||||
ImGui::BeginDisabled(!active);
|
||||
if (v.cellular_feed_target && ImGui::Button("Stop feeding", {-1, 0}))
|
||||
a.stop_feeding = true;
|
||||
if (const auto* p = v.cellular_perception) {
|
||||
if (const auto* seen = v.cellular_perception; seen && !seen->deposits.empty()) {
|
||||
// ADR-0136: pools and bubbles feed on contact; a summary, not a target list.
|
||||
std::size_t pools = 0;
|
||||
std::array<std::uint64_t, 5> totals{};
|
||||
for (const auto& d : seen->deposits) {
|
||||
pools += d.shape == network::CellularDepositShape::pool ? 1 : 0;
|
||||
for (std::size_t c = 0; c < totals.size(); ++c)
|
||||
totals.at(c) += network::deposit_amount_value(d.amount_codes.at(c));
|
||||
}
|
||||
ImGui::Text("%zu bubbles, %zu pools in range", seen->deposits.size() - pools, pools);
|
||||
ImGui::TextColored(nutrient(0), "%s", energy_text(totals[0]).c_str());
|
||||
for (std::size_t c = 1; c < totals.size(); ++c) {
|
||||
ImGui::SameLine();
|
||||
ImGui::TextColored(nutrient(c), "%s", mass_text(totals.at(c)).c_str());
|
||||
}
|
||||
disabled_wrapped("Swim through bubbles to collect them; pools feed slowly.");
|
||||
} else if (const auto* p = v.cellular_perception) {
|
||||
if (p->patches.empty())
|
||||
disabled_wrapped("No food is visible within sensor range.");
|
||||
for (const auto& patch : p->patches) {
|
||||
|
||||
Reference in New Issue
Block a user