feat(cellular): playtest fixes - edge, cell count, mixed bubbles, still pools
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m29s
Foundation / postgres-tools (push) Successful in 29s
Foundation / server-image (push) Successful in 4m24s
Foundation / image (push) Successful in 4m58s
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m29s
Foundation / postgres-tools (push) Successful in 29s
Foundation / server-image (push) Successful in 4m24s
Foundation / image (push) Successful in 4m58s
From the first rules-13 playtest: - An earned offer waits until a single cell can split (keeping its count), so choices are no longer refused one after another. - The client draws the region's walls (dimming outside), names the edge when the cell is against it, shows the region's cell count, and says when upkeep is burning kept matter because no energy is left. - Mixed bubbles hold every nutrient at once (--mixed-motes; none leaves the scatter stream unchanged) and are drawn as small pools of their nutrients. With intake split by the body's recipe, single-nutrient phosphorus bubbles fed slowly; mixed ones carry it with everything else. - Liquid openings move each pool out of the currents to the nearest still water (cellular_still_centre). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -183,6 +183,18 @@ choice's operator, the action input's new bits, and mutation results 0-6.
|
||||
- Opening `cellular-v10` in a new DEV region; promote the images; full Argo sync.
|
||||
- Playtest.
|
||||
|
||||
## Playtest feedback (2026-10-26)
|
||||
|
||||
- Choices stalled after one split: a split needs a grown cell. The view now carries growth and
|
||||
a split-ready flag; the client gates Stay / Become; an offer waits until a single cell can
|
||||
split; DEV splits once half grown (region 13).
|
||||
- The region edge is drawn and named when the cell is against it; the region's cell count is
|
||||
shown; the client says when upkeep is burning kept matter.
|
||||
- Mixed bubbles (every nutrient, recipe proportions) via `--mixed-motes`, drawn as small pools;
|
||||
liquid openings move pools out of the currents into still water.
|
||||
- Phosphorus: intake per channel follows the body's recipe, so single-nutrient phosphorus
|
||||
bubbles fed slowly while growth used it at once; mixed bubbles carry it with everything else.
|
||||
|
||||
## Open items
|
||||
|
||||
| Item | Phase |
|
||||
|
||||
@@ -754,6 +754,8 @@ int main(int argc, char** argv) try {
|
||||
scene.deposits.clear();
|
||||
scene.pops.clear();
|
||||
scene.cells.clear();
|
||||
scene.region = scene.at_edge = false;
|
||||
scene.region_cells = 0;
|
||||
scene_active = false;
|
||||
const auto* cellular_remote = host.session();
|
||||
const bool microscope = cellular_remote && mode() == Mode::remote && cellular_trial;
|
||||
@@ -914,6 +916,43 @@ int main(int argc, char** argv) try {
|
||||
}
|
||||
}
|
||||
const auto own = cellular_remote->cellular_play().life();
|
||||
// The region's walls, from the perceived current configuration (mm).
|
||||
double region_w_mm = 0, region_h_mm = 0;
|
||||
if (const auto* perception = cellular_remote->cellular_perception();
|
||||
perception && perception->currents) {
|
||||
region_w_mm = static_cast<double>(perception->currents->width_um) / 1000;
|
||||
region_h_mm = static_cast<double>(perception->currents->height_um) / 1000;
|
||||
const auto low = camera->world_to_screen({0, 0});
|
||||
const auto high = camera->world_to_screen({region_w_mm, region_h_mm});
|
||||
if (low && high) {
|
||||
scene.region = true;
|
||||
scene.region_left = static_cast<float>(std::min(low->x, high->x));
|
||||
scene.region_right = static_cast<float>(std::max(low->x, high->x));
|
||||
scene.region_top = static_cast<float>(std::min(low->y, high->y));
|
||||
scene.region_bottom = static_cast<float>(std::max(low->y, high->y));
|
||||
}
|
||||
}
|
||||
if (orgs) {
|
||||
scene.region_cells = static_cast<std::size_t>(
|
||||
std::ranges::count_if(orgs->cells(), [](const auto& cell) {
|
||||
return cell.state != evo::client::OrganismState::dead;
|
||||
}));
|
||||
// Against a wall: within 50 um of it (positions are the lower-left corner).
|
||||
for (const auto& cell : orgs->cells()) {
|
||||
if (own == 0 || cell.id != own || region_w_mm == 0)
|
||||
continue;
|
||||
constexpr auto pitch = static_cast<double>(evo::world::cell_pitch_mm);
|
||||
const double x = static_cast<double>(cell.voxel.x) * pitch +
|
||||
static_cast<double>(cell.x.value) / 1000;
|
||||
const double y = static_cast<double>(cell.voxel.y) * pitch +
|
||||
static_cast<double>(cell.y.value) / 1000;
|
||||
const double extent = static_cast<double>(cell.phenotype.extent) / 1000;
|
||||
constexpr double near = 0.05;
|
||||
scene.at_edge = x <= near || y <= near ||
|
||||
x + extent >= region_w_mm - near ||
|
||||
y + extent >= region_h_mm - near;
|
||||
}
|
||||
}
|
||||
// ADR-0176: the owner's view lists the producers it can see, by organism.
|
||||
const auto* seen = cellular_remote->cellular_perception();
|
||||
const auto photosynthesis = [&](std::uint64_t organism) -> std::uint32_t {
|
||||
|
||||
@@ -885,7 +885,24 @@ std::size_t dominant_channel(const std::array<std::uint64_t, 5>& stock) {
|
||||
// ADR-0136: a bubble is a translucent circle in its nutrient's colour, sized by what it
|
||||
// holds (never below its contact disc). While something eats it, a soft glow of its own
|
||||
// colour fades in and out around it; the bubble itself keeps its size.
|
||||
void draw_pool(ImDrawList& list, const SceneDeposit& d, float time);
|
||||
void draw_bubble(ImDrawList& list, const SceneDeposit& d, float time) {
|
||||
// A bubble holding more than one nutrient looks like a little pool of all of them.
|
||||
if (std::ranges::count_if(d.stock, [](std::uint64_t amount) { return amount != 0; }) > 1) {
|
||||
std::uint64_t total{};
|
||||
for (const auto amount : d.stock)
|
||||
total += amount;
|
||||
auto small = d;
|
||||
small.radius = std::max(
|
||||
d.radius *
|
||||
std::clamp(0.7F + 0.12F * static_cast<float>(std::log10(static_cast<double>(
|
||||
std::max<std::uint64_t>(1, total)))),
|
||||
0.8F, 2.2F) *
|
||||
0.6F,
|
||||
6.0F);
|
||||
draw_pool(list, small, time);
|
||||
return;
|
||||
}
|
||||
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 =
|
||||
@@ -1038,6 +1055,17 @@ void draw_scene(const PanelView& v) {
|
||||
const auto time = v.cellular_scene->stale ? 0.0F : static_cast<float>(ImGui::GetTime());
|
||||
draw_liquid(list, ImGui::GetIO().DisplaySize, time);
|
||||
draw_flows(list, v.cellular_scene->flows, time);
|
||||
if (const auto& s = *v.cellular_scene; s.region) {
|
||||
const auto size = ImGui::GetIO().DisplaySize;
|
||||
const auto outside = IM_COL32(4, 3, 6, 200);
|
||||
list.AddRectFilled({0, 0}, {size.x, s.region_top}, outside);
|
||||
list.AddRectFilled({0, s.region_bottom}, {size.x, size.y}, outside);
|
||||
list.AddRectFilled({0, s.region_top}, {s.region_left, s.region_bottom}, outside);
|
||||
list.AddRectFilled({s.region_right, s.region_top}, {size.x, s.region_bottom}, outside);
|
||||
list.AddRect({s.region_left, s.region_top}, {s.region_right, s.region_bottom},
|
||||
s.at_edge ? IM_COL32(243, 176, 77, 230) : IM_COL32(166, 220, 199, 140), 0, 0,
|
||||
s.at_edge ? 3.0F : 1.5F);
|
||||
}
|
||||
for (const auto& patch : v.cellular_scene->patches)
|
||||
draw_patch(list, patch);
|
||||
const auto visible = [&](const SceneDeposit& d) {
|
||||
@@ -1318,6 +1346,9 @@ void hud_dock(const PanelView& v, FormBuffers& form, PanelActions& a, bool compa
|
||||
ImGui::TextColored(amber, "Bud: short on %s", missing.c_str());
|
||||
}
|
||||
}
|
||||
if (const auto* s = v.cellular_scene; s && s->at_edge && play && play->life() != 0)
|
||||
ImGui::TextColored(amber, "At the region edge: nothing lies beyond. Swim back in; "
|
||||
"pushing on the wall still costs energy.");
|
||||
if (play) {
|
||||
if (const auto& f = play->engulf_feedback(); f && *engulf_text(f->second) != '\0')
|
||||
ImGui::TextWrapped("%s", engulf_text(f->second));
|
||||
@@ -1421,6 +1452,9 @@ void hud_notes(const PanelView& v, FormBuffers& form, PanelActions& a, bool comp
|
||||
: form.cellular_controls.exclude & ~bit);
|
||||
}
|
||||
ImGui::TextDisabled("Can pay %s now", energy_text(d->payable_energy_pj).c_str());
|
||||
if (form.cellular_controls.exclude != 0 && d->has_tick_effects &&
|
||||
d->reserve_energy_pj < d->maintenance_cost_pj)
|
||||
ImGui::TextColored(amber, "No energy left: upkeep is burning kept matter.");
|
||||
disabled_wrapped("Matter you keep is never burned for movement or mutations; upkeep "
|
||||
"still burns it when nothing else can pay.");
|
||||
}
|
||||
@@ -1792,6 +1826,8 @@ void hud_map(const PanelView& v, FormBuffers& form, bool compact) {
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
if (const auto* s = v.cellular_scene; s && s->region_cells != 0)
|
||||
ImGui::TextDisabled("%zu cells in this region", s->region_cells);
|
||||
auto at = ImGui::GetCursorScreenPos();
|
||||
const float available = ImGui::GetContentRegionAvail().x;
|
||||
const float side = std::min(available, px(compact ? 96.0F : 178.0F));
|
||||
|
||||
@@ -71,6 +71,12 @@ struct CellularScene {
|
||||
// Camera mapping for the local observation map; no undiscovered world state.
|
||||
client::WorldPoint camera_centre{};
|
||||
bool stale{};
|
||||
// The region's walls on screen (liquid regions, from the perceived current configuration),
|
||||
// whether the owner's cell is against one, and how many cells the region holds.
|
||||
bool region{};
|
||||
float region_left{}, region_top{}, region_right{}, region_bottom{};
|
||||
bool at_edge{};
|
||||
std::size_t region_cells{};
|
||||
};
|
||||
// Notice layout (logical pixels); the window name is the prefix plus the notice id.
|
||||
inline constexpr float notice_width = 320, notice_close_width = 22;
|
||||
|
||||
@@ -127,6 +127,7 @@ struct Options {
|
||||
std::vector<biology::CellularPatch> cellular_patches;
|
||||
std::vector<biology::CellularPatch> cellular_pools; // cellular-v7
|
||||
std::optional<biology::CellularMoteField> cellular_motes; // cellular-v7 and v8
|
||||
std::optional<biology::CellularMoteField> cellular_mixed; // Mixed bubbles (v7 and later)
|
||||
std::optional<std::uint64_t> light_pj; // cellular-v8/v9: pJ per square um per tick
|
||||
std::optional<std::string> tuning_path; // cellular-v9: the Git tuning file
|
||||
std::optional<std::uint64_t> current_seed;
|
||||
@@ -360,6 +361,8 @@ std::optional<Options> parse(int argc, char** argv) {
|
||||
value == "cellular-v5" || value == "cellular-v6" || value == "cellular-v7" ||
|
||||
value == "cellular-v8" || value == "cellular-v9" || value == "cellular-v10"))
|
||||
o.opening = value;
|
||||
else if (o.command == "provision" && flag == "--mixed-motes" && cellular_motes(value))
|
||||
o.cellular_mixed = cellular_motes(value);
|
||||
else if (o.command == "provision" && flag == "--revamp-tuning" && !value.empty())
|
||||
o.revamp_tuning_path = std::string{value};
|
||||
else if (o.command == "provision" && flag == "--light-pj" && n && *n > 0)
|
||||
@@ -858,10 +861,38 @@ int provision(const Options& o) {
|
||||
if (o.opening == "cellular-v7" || lit_opening(o.opening)) {
|
||||
// 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});
|
||||
if (const auto& mixed = o.cellular_mixed) {
|
||||
// Mixed bubbles hold every nutrient of the --mixed-motes amounts at once.
|
||||
if (!o.cellular_motes)
|
||||
field.source = mixed->source;
|
||||
field.mixed_count = mixed->count;
|
||||
field.mixed = mixed->amount;
|
||||
}
|
||||
// Liquid openings: a pool rests in still water, never in a current.
|
||||
auto pools = o.cellular_pools;
|
||||
if (const auto liquid = liquid_rules(o)) {
|
||||
const auto& c = liquid->currents;
|
||||
const auto flow = biology::CellularFlowField::generate(
|
||||
{c.seed, c.width_um, c.height_um, c.pitch_um, c.min_count, c.max_count,
|
||||
c.min_route_width_um, c.max_route_width_um, c.min_speed_um_per_s,
|
||||
c.max_speed_um_per_s});
|
||||
if (!flow) {
|
||||
std::puts("cellular currents refused");
|
||||
return 4;
|
||||
}
|
||||
for (auto& pool : pools) {
|
||||
const auto moved =
|
||||
biology::cellular_still_centre(*flow, pool.address, pool.radius_um);
|
||||
if (moved != pool.address)
|
||||
std::printf("pool %u,%u moved out of a current to %u,%u\n",
|
||||
pool.address.x_um, pool.address.y_um, moved.x_um, moved.y_um);
|
||||
pool.address = moved;
|
||||
}
|
||||
}
|
||||
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);
|
||||
auto scattered = biology::scatter_deposits(habitat_config, pools, field);
|
||||
if (!scattered) {
|
||||
std::printf("cellular habitat refused %u\n",
|
||||
static_cast<unsigned>(scattered.error()));
|
||||
|
||||
@@ -12,7 +12,7 @@ spec:
|
||||
env:
|
||||
- {name: REGION_SESSION, value: "dev"}
|
||||
- {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"}
|
||||
- {name: REGION_SESSION_WINDOW, value: "dev-20261026T122846-560e1ebf:1793032126"}
|
||||
- {name: REGION_SESSION_WINDOW, value: "dev-20261026T125532-a03b5cc6:1793033732"}
|
||||
- {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"}
|
||||
ports:
|
||||
# QUIC (ADR-0090): UDP only; nothing listens on TCP 7400.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "evo/biology/cellular_habitat.hpp"
|
||||
#include "evo/biology/cellular_kinematics.hpp"
|
||||
|
||||
#include <compare>
|
||||
@@ -80,4 +81,10 @@ class CellularFlowField {
|
||||
std::vector<CellularFlowSample> nodes_;
|
||||
std::size_t columns_{}, rows_{};
|
||||
};
|
||||
// A pool (a fixed deposit) cannot sit in a current. The nearest centre to the pool's within the
|
||||
// region whose whole disc is in still water (no current at its centre, rim or half-rim), or
|
||||
// the pool's own centre when it already is or none is found within 30 mm.
|
||||
[[nodiscard]] CellularPatchAddress cellular_still_centre(const CellularFlowField& field,
|
||||
CellularPatchAddress centre,
|
||||
std::uint32_t radius_um) noexcept;
|
||||
} // namespace evo::biology
|
||||
|
||||
@@ -113,6 +113,10 @@ struct CellularMoteField {
|
||||
std::uint64_t source{};
|
||||
accounting::Inventory amount{}; // Per bubble, per channel.
|
||||
std::uint64_t seed{};
|
||||
// Mixed bubbles, each holding all of `mixed` (every nutrient at once), scattered after the
|
||||
// single-nutrient ones from the same stream. None leaves the stream unchanged.
|
||||
std::uint32_t mixed_count{};
|
||||
accounting::Inventory mixed{};
|
||||
};
|
||||
// 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.
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "evo/core/random.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <mutex>
|
||||
#include <utility>
|
||||
@@ -254,4 +255,44 @@ std::uint64_t CellularFlowField::digest() const noexcept {
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
CellularPatchAddress cellular_still_centre(const CellularFlowField& field,
|
||||
CellularPatchAddress centre,
|
||||
std::uint32_t radius_um) noexcept {
|
||||
const auto& c = field.config();
|
||||
const std::int64_t r = radius_um;
|
||||
const auto still = [&](std::int64_t x, std::int64_t y) {
|
||||
if (x - r < 0 || y - r < 0 || x + r > std::int64_t{c.width_um} ||
|
||||
y + r > std::int64_t{c.height_um})
|
||||
return false;
|
||||
// The centre and 16 points on the rim and half-rim.
|
||||
if (field.sample(x, y) != CellularFlowSample{})
|
||||
return false;
|
||||
for (int k = 0; k < 8; ++k) {
|
||||
const double angle = k * 0.785398163397448;
|
||||
for (const double reach : {0.5, 1.0}) {
|
||||
const auto px = x + std::llround(std::cos(angle) * reach * static_cast<double>(r));
|
||||
const auto py = y + std::llround(std::sin(angle) * reach * static_cast<double>(r));
|
||||
if (field.sample(px, py) != CellularFlowSample{})
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
const std::int64_t x0 = centre.x_um, y0 = centre.y_um;
|
||||
if (still(x0, y0))
|
||||
return centre;
|
||||
// Rings of growing radius, 250 um apart, each walked at about 250 um steps.
|
||||
for (std::int64_t ring = 250; ring <= 30'000; ring += 250) {
|
||||
const auto steps = std::max<std::int64_t>(8, ring * 2 * 314 / 100 / 250);
|
||||
for (std::int64_t k = 0; k < steps; ++k) {
|
||||
const double angle =
|
||||
6.283185307179586 * static_cast<double>(k) / static_cast<double>(steps);
|
||||
const auto x = x0 + std::llround(std::cos(angle) * static_cast<double>(ring));
|
||||
const auto y = y0 + std::llround(std::sin(angle) * static_cast<double>(ring));
|
||||
if (still(x, y))
|
||||
return {static_cast<std::uint32_t>(x), static_cast<std::uint32_t>(y)};
|
||||
}
|
||||
}
|
||||
return centre;
|
||||
}
|
||||
} // namespace evo::biology
|
||||
|
||||
@@ -373,7 +373,8 @@ std::expected<CellularHabitatConfig, CellularHabitatError>
|
||||
scatter_deposits(CellularHabitatConfig base, std::span<const CellularPatch> pools,
|
||||
const CellularMoteField& field) {
|
||||
if (base.width_um == 0 || base.height_um == 0 || field.source == 0 ||
|
||||
pools.size() + field.count > max_cellular_patches)
|
||||
pools.size() + field.count + field.mixed_count > max_cellular_patches ||
|
||||
(field.mixed_count != 0 && field.mixed == accounting::Inventory{}))
|
||||
return std::unexpected{CellularHabitatError::invalid_config};
|
||||
std::vector<std::size_t> channels; // 0 energy, 1-4 matter
|
||||
if (field.amount.energy.value != 0)
|
||||
@@ -383,6 +384,8 @@ scatter_deposits(CellularHabitatConfig base, std::span<const CellularPatch> pool
|
||||
channels.push_back(c + 1);
|
||||
if (field.count != 0 && channels.empty())
|
||||
return std::unexpected{CellularHabitatError::invalid_config};
|
||||
if (channels.empty())
|
||||
channels.push_back(0); // Only mixed bubbles: the single-nutrient rota is unused.
|
||||
// splitmix64: a fixed, portable stream.
|
||||
std::uint64_t state = field.seed;
|
||||
const auto next = [&state] {
|
||||
@@ -406,7 +409,7 @@ scatter_deposits(CellularHabitatConfig base, std::span<const CellularPatch> pool
|
||||
centres.push_back({static_cast<std::uint32_t>(below(base.width_um)),
|
||||
static_cast<std::uint32_t>(below(base.height_um))});
|
||||
constexpr std::int64_t spread = 600; // Clump half-width (tunable).
|
||||
for (std::uint32_t i = 0; i < field.count; ++i) {
|
||||
for (std::uint32_t i = 0; i < field.count + field.mixed_count; ++i) {
|
||||
std::int64_t x{}, y{};
|
||||
if (below(10) < 3) {
|
||||
const auto& centre = centres[below(centres.size())];
|
||||
@@ -426,6 +429,11 @@ scatter_deposits(CellularHabitatConfig base, std::span<const CellularPatch> pool
|
||||
mote.source = field.source;
|
||||
mote.radius_um = cellular_mote_radius_um;
|
||||
mote.kind = CellularDepositKind::mote;
|
||||
if (i >= field.count) {
|
||||
mote.stock = field.mixed;
|
||||
deposits.push_back(mote);
|
||||
continue;
|
||||
}
|
||||
const auto channel = channels[i % channels.size()];
|
||||
if (channel == 0)
|
||||
mote.stock.energy = field.amount.energy;
|
||||
|
||||
@@ -3383,8 +3383,15 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
|
||||
biology::cellular_affinity_tick(
|
||||
life.revamp.affinity, a, state_->revamp.mutations,
|
||||
{state_->revamp.offers.score_min, state_->revamp.offers.score_max});
|
||||
if (life.revamp.offer.count != 0 ||
|
||||
++life.revamp.active_ticks < state_->revamp.offer_interval_ticks)
|
||||
if (life.revamp.offer.count != 0)
|
||||
continue;
|
||||
if (life.revamp.active_ticks < state_->revamp.offer_interval_ticks)
|
||||
++life.revamp.active_ticks;
|
||||
// A single cell's choice splits it, so an earned offer waits (keeping its count)
|
||||
// until the cell has grown enough to split.
|
||||
if (life.revamp.active_ticks < state_->revamp.offer_interval_ticks ||
|
||||
(life.revamp.members == 1 &&
|
||||
life.growth.realized_per_thousand < state_->revamp.split_min_growth))
|
||||
continue;
|
||||
life.revamp.active_ticks = 0;
|
||||
const auto plan = next_archive.find(cellular_offspring_genome(life));
|
||||
|
||||
@@ -152,10 +152,40 @@ void invalid_configurations() {
|
||||
const auto still = generate(none);
|
||||
CHECK(still.routes().empty() && still.sample(30'000, 30'000) == CellularFlowSample{});
|
||||
}
|
||||
// A pool in a current moves to the nearest centre whose whole disc is still; one in still
|
||||
// water stays.
|
||||
void pools_rest_in_still_water() {
|
||||
const auto field = generate(v0(7));
|
||||
const auto disc_still = [&](CellularPatchAddress at, std::int64_t r) {
|
||||
for (std::int64_t dx = -r; dx <= r; dx += r / 2)
|
||||
for (std::int64_t dy = -r; dy <= r; dy += r / 2)
|
||||
if (dx * dx + dy * dy <= r * r &&
|
||||
field.sample(at.x_um + dx, at.y_um + dy) != CellularFlowSample{})
|
||||
return false;
|
||||
return true;
|
||||
};
|
||||
std::size_t moved{};
|
||||
for (std::uint32_t x = 5'000; x <= 55'000; x += 5'000)
|
||||
for (std::uint32_t y = 5'000; y <= 55'000; y += 5'000) {
|
||||
const CellularPatchAddress at{x, y};
|
||||
const auto rested = cellular_still_centre(field, at, 500);
|
||||
if (field.sample(x, y) != CellularFlowSample{}) {
|
||||
CHECK(rested != at && disc_still(rested, 500));
|
||||
CHECK(rested.x_um >= 500 && rested.y_um >= 500 && rested.x_um <= 59'500 &&
|
||||
rested.y_um <= 59'500);
|
||||
++moved;
|
||||
} else {
|
||||
// Still at its centre: it stays, or moves only to clear a current at its rim.
|
||||
CHECK(disc_still(rested, 500));
|
||||
}
|
||||
}
|
||||
CHECK(moved != 0);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main() {
|
||||
try {
|
||||
pools_rest_in_still_water();
|
||||
routes_within_configuration();
|
||||
bounded_with_quiet_water_and_still_walls();
|
||||
route_centreline_runs_at_route_speed();
|
||||
|
||||
@@ -222,8 +222,29 @@ void refusals() {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// Mixed bubbles hold every nutrient at once and follow the single-nutrient ones from the same
|
||||
// stream: without them the scatter is unchanged.
|
||||
void mixed_bubbles_hold_every_nutrient() {
|
||||
CellularHabitatConfig base{100, 1, 9, 60'000, 60'000, {}, cellular_habitat_deposit_format, 1};
|
||||
const auto plain = scatter_deposits(base, {}, {300, 7, energy(70), 99});
|
||||
CHECK(plain);
|
||||
Inventory mixed{{1'000}, {{{500}, {150}, {50}, {300}}}};
|
||||
CellularMoteField field{300, 7, energy(70), 99, 200, mixed};
|
||||
const auto both = scatter_deposits(base, {}, field);
|
||||
CHECK(both && both->patches.size() == 500);
|
||||
CHECK(std::ranges::count(both->patches, mixed, &CellularPatch::stock) == 200);
|
||||
field.mixed_count = 0;
|
||||
const auto none = scatter_deposits(base, {}, field);
|
||||
CHECK(none && none->patches == plain->patches);
|
||||
// Mixed bubbles alone, and a mixed count without an amount.
|
||||
const auto only = scatter_deposits(base, {}, {0, 7, {}, 99, 50, mixed});
|
||||
CHECK(only && only->patches.size() == 50);
|
||||
CHECK(!scatter_deposits(base, {}, {0, 7, {}, 99, 50, {}}));
|
||||
}
|
||||
|
||||
int main() {
|
||||
try {
|
||||
mixed_bubbles_hold_every_nutrient();
|
||||
format_three_round_trip();
|
||||
liquid_deposits_are_perceived();
|
||||
still_water_keeps_bubbles();
|
||||
|
||||
@@ -334,19 +334,14 @@ void a_choice_splits_the_cell(bool become) {
|
||||
"control did not follow the choice");
|
||||
require(state->habitat().patches().size() >= deposits + 1, "the paid cost was not reclaimed");
|
||||
closed(*state);
|
||||
// A half-grown founder cannot split again: the choice is refused and the offer kept.
|
||||
// A half-grown founder cannot split again, so its next offer waits until it has regrown.
|
||||
if (!become) {
|
||||
for (int tick = 0; tick < 40; ++tick)
|
||||
checked(state->advance_tick(swim(*state, {1'000, 0})), "swim tick");
|
||||
const auto offer = life_of(*state, 101).revamp.offer;
|
||||
require(offer.count == 3, "no second offer");
|
||||
const auto refused =
|
||||
checked(state->advance_tick_with_mutations(swim(*state, {}),
|
||||
choose(*state, 101, offer.ids.at(1), 9'010)),
|
||||
"refused split tick");
|
||||
require(refused.mutations.front().result == CellularMutationResult::split_refused &&
|
||||
life_of(*state, 101).revamp.offer == offer && !state->archive().find(9'010),
|
||||
"a split below full growth was not refused with the offer kept");
|
||||
const auto& founder_now = life_of(*state, 101);
|
||||
require(founder_now.growth.realized_per_thousand < 1'000 &&
|
||||
founder_now.revamp.offer.count == 0,
|
||||
"a half-grown founder was offered a split");
|
||||
closed(*state);
|
||||
}
|
||||
// Rules 13 wildlife (the founder after become): its controller's intents are always
|
||||
|
||||
Reference in New Issue
Block a user