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:
@@ -40,6 +40,20 @@ steer_cellular(const CellularControls& controls, client::Intention intention,
|
||||
static_cast<double>(own->voxel.y) * 1'000'000 + static_cast<double>(own->y.value);
|
||||
const double extent = static_cast<double>(own->phenotype.extent);
|
||||
bool target_has_energy = false;
|
||||
// ADR-0136 (v11): deposits feed on contact, so no target; slow near any that
|
||||
// holds something (within 1 mm of its disc).
|
||||
for (const auto& d : perception->deposits) {
|
||||
if (std::ranges::all_of(d.amount_codes, [](auto code) { return code == 0; }))
|
||||
continue;
|
||||
const double cx = static_cast<double>(d.x_um), cy = static_cast<double>(d.y_um);
|
||||
const double gx = std::max({x - cx, cx - x - extent, 0.0});
|
||||
const double gy = std::max({y - cy, cy - y - extent, 0.0});
|
||||
if (controls.slow_near_food &&
|
||||
std::hypot(gx, gy) <= 1000.0 + static_cast<double>(d.radius_um) &&
|
||||
own->phenotype.movement_speed > 0)
|
||||
scale =
|
||||
std::min(scale, 500.0 / static_cast<double>(own->phenotype.movement_speed));
|
||||
}
|
||||
for (const auto& p : perception->patches) {
|
||||
if (p.energy_pj == 0 &&
|
||||
std::ranges::all_of(p.matter_fg, [](auto v) { return v == 0; }))
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <cstdio>
|
||||
#include <exception>
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
@@ -469,6 +470,20 @@ int main(int argc, char** argv) try {
|
||||
int drawn_organisms = -1;
|
||||
evo::client_app::CellularScene scene; // Rebuilt each frame in cellular play.
|
||||
evo::client_app::CellHeadings headings; // Where each drawn cell last moved.
|
||||
// ADR-0136: deposits seen in the last view (to notice a bubble that ran out) and the
|
||||
// pops still fading, in world coordinates with their start time.
|
||||
struct SeenDeposit {
|
||||
double x_mm{}, y_mm{};
|
||||
std::uint32_t radius_um{};
|
||||
int channel{};
|
||||
};
|
||||
struct LivePop {
|
||||
SeenDeposit at;
|
||||
std::chrono::steady_clock::time_point start;
|
||||
};
|
||||
std::map<std::uint32_t, SeenDeposit> seen_deposits;
|
||||
std::uint64_t seen_deposit_tick{};
|
||||
std::vector<LivePop> live_pops;
|
||||
bool scene_active = false;
|
||||
evo::client_app::PanelActions actions;
|
||||
(*app)->set_overlay([&] {
|
||||
@@ -726,6 +741,8 @@ int main(int argc, char** argv) try {
|
||||
// 2026-10-16 microscope view: in cellular play, patches and cells are a scene the
|
||||
// panels draw as granules and living cells; elsewhere organisms stay rectangles.
|
||||
scene.patches.clear();
|
||||
scene.deposits.clear();
|
||||
scene.pops.clear();
|
||||
scene.cells.clear();
|
||||
scene_active = false;
|
||||
const auto* cellular_remote = host.session();
|
||||
@@ -755,6 +772,66 @@ int main(int argc, char** argv) try {
|
||||
p.seed = (static_cast<std::uint64_t>(patch.x_um) << 32U) ^ patch.y_um;
|
||||
scene.patches.push_back(p);
|
||||
}
|
||||
// ADR-0136 (v11): pools and bubbles, centred; a vanished bubble pops.
|
||||
if (const auto* perception = cellular_remote->cellular_perception()) {
|
||||
const auto now_pop = std::chrono::steady_clock::now();
|
||||
std::map<std::uint32_t, SeenDeposit> current;
|
||||
for (const auto& d : perception->deposits) {
|
||||
std::array<std::uint64_t, 5> stock{};
|
||||
for (std::size_t c = 0; c < stock.size(); ++c)
|
||||
stock.at(c) = evo::network::deposit_amount_value(d.amount_codes.at(c));
|
||||
int channel = 0;
|
||||
for (std::size_t c = 1; c < stock.size(); ++c)
|
||||
if (stock.at(c) > stock.at(static_cast<std::size_t>(channel)))
|
||||
channel = static_cast<int>(c);
|
||||
const SeenDeposit seen{static_cast<double>(d.x_um) / 1000,
|
||||
static_cast<double>(d.y_um) / 1000, d.radius_um,
|
||||
channel};
|
||||
current[d.id] = seen;
|
||||
const auto centre = camera->world_to_screen({seen.x_mm, seen.y_mm});
|
||||
const auto edge = camera->world_to_screen(
|
||||
{seen.x_mm + static_cast<double>(d.radius_um) / 1000, seen.y_mm});
|
||||
if (!centre || !edge)
|
||||
continue;
|
||||
evo::client_app::SceneDeposit drawn;
|
||||
drawn.x = static_cast<float>(centre->x);
|
||||
drawn.y = static_cast<float>(centre->y);
|
||||
drawn.radius = static_cast<float>(std::abs(edge->x - centre->x));
|
||||
drawn.stock = stock;
|
||||
drawn.pool = d.shape == evo::network::CellularDepositShape::pool;
|
||||
drawn.drained = d.drained;
|
||||
drawn.stale = !fresh;
|
||||
drawn.seed = d.id;
|
||||
scene.deposits.push_back(drawn);
|
||||
}
|
||||
// A bubble absent from a newer view while its old spot is still in
|
||||
// sight ran out (or left the sensor's edge, which a pop also suits).
|
||||
if (perception->tick != seen_deposit_tick) {
|
||||
for (const auto& [id, old] : seen_deposits)
|
||||
if (!current.contains(id) && live_pops.size() < 256)
|
||||
live_pops.push_back({old, now_pop});
|
||||
seen_deposits = std::move(current);
|
||||
seen_deposit_tick = perception->tick;
|
||||
}
|
||||
constexpr auto pop_life = std::chrono::milliseconds{350};
|
||||
std::erase_if(live_pops, [&](const LivePop& pop) {
|
||||
return now_pop - pop.start > pop_life;
|
||||
});
|
||||
for (const auto& pop : live_pops) {
|
||||
const auto centre = camera->world_to_screen({pop.at.x_mm, pop.at.y_mm});
|
||||
const auto edge = camera->world_to_screen(
|
||||
{pop.at.x_mm + static_cast<double>(pop.at.radius_um) / 1000,
|
||||
pop.at.y_mm});
|
||||
if (!centre || !edge)
|
||||
continue;
|
||||
const auto age = std::chrono::duration<float>(now_pop - pop.start).count() /
|
||||
std::chrono::duration<float>(pop_life).count();
|
||||
scene.pops.push_back({static_cast<float>(centre->x),
|
||||
static_cast<float>(centre->y),
|
||||
static_cast<float>(std::abs(edge->x - centre->x)),
|
||||
age, pop.at.channel});
|
||||
}
|
||||
}
|
||||
const auto own = cellular_remote->cellular_play().life();
|
||||
if (orgs)
|
||||
for (const auto& cell : orgs->cells()) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -42,8 +42,22 @@ struct ScenePatch {
|
||||
bool target{}, stale{};
|
||||
std::uint64_t seed{};
|
||||
};
|
||||
// ADR-0136 (v11): a pool (a puddle) or a bubble, centred, with its contact radius in pixels.
|
||||
struct SceneDeposit {
|
||||
float x{}, y{}, radius{};
|
||||
std::array<std::uint64_t, 5> stock{}; // Approximate (v11 amount codes), same channels.
|
||||
bool pool{}, drained{}, stale{};
|
||||
std::uint64_t seed{};
|
||||
};
|
||||
// A bubble that just ran out: an expanding, fading ring for a moment.
|
||||
struct ScenePop {
|
||||
float x{}, y{}, radius{}, age{}; // Age 0..1 over the pop's life.
|
||||
int channel{};
|
||||
};
|
||||
struct CellularScene {
|
||||
std::vector<ScenePatch> patches;
|
||||
std::vector<SceneDeposit> deposits;
|
||||
std::vector<ScenePop> pops;
|
||||
std::vector<SceneCell> cells;
|
||||
};
|
||||
// Notice layout (logical pixels); the window name is the prefix plus the notice id.
|
||||
|
||||
@@ -499,7 +499,7 @@ class RemoteSession {
|
||||
return false;
|
||||
client::RegionSessionClientConfig config;
|
||||
if (cellular_trial_)
|
||||
config.protocol_version = network::session_protocol_v10;
|
||||
config.protocol_version = network::session_protocol_v11; // ADR-0136 deposits.
|
||||
const auto route = routes_.find(target_region_);
|
||||
config.transport = route != routes_.end() ? route->second : transport_;
|
||||
if (ticket_) { // A handoff: the ticket replaces a grant, once.
|
||||
|
||||
Reference in New Issue
Block a user