feat(cellular): random founder spawns, tunable thrust cost, commit timing
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 1m6s
Foundation / checks (deploy) (push) Successful in 5m41s
Foundation / postgres-tools (push) Successful in 1m33s
Foundation / image (push) Successful in 4m42s
Foundation / server-image (push) Successful in 4m55s

Playtest feedback on region 10.

Rules-12 founders now start at a seeded random spot anywhere in the region (1 mm
clear of the edges, clear of other cells; seeded by world, region and the life's
identity so replay is exact). The provisioned sites remain the fallback.

Thrust energy is tunable: founder.thrust_cost_per_mille scales the metabolic
full-speed movement cost for thrust and braking (trial 250, a quarter of today's
cost). It is part of the liquid rules declared when a region opens, persisted in
the format-10 block's reserved slot (zero stands for the original 1,000), so
existing regions keep their meaning.

The server logs every cellular commit slower than 50 ms (and one in 60) with its
tick count and duration, to find what stalls the loop once a second.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-22 06:40:12 -04:00
co-authored by Claude Opus 5.5
parent c94eca7d4e
commit af32af36ee
12 changed files with 108 additions and 12 deletions
+31 -5
View File
@@ -1,6 +1,8 @@
#include "evo/server/lifecycle/cellular_lives.hpp"
#include "evo/biology/budding.hpp"
#include "evo/biology/founder.hpp"
#include "evo/core/random.hpp"
#include <algorithm>
#include <array>
@@ -1115,7 +1117,9 @@ std::vector<std::uint8_t> CellularLives::snapshot() const {
out.put(d.drift_decay_ppm, 4);
out.put(d.merged_cap, 4);
out.put(d.bubble_radius_um, 4);
out.put(0, 4);
// Thrust cost share; zero stands for the original 1,000 per mille.
const auto cost = state_->liquid.thrust_cost_per_mille;
out.put(cost == 1'000 ? 0 : cost, 4);
}
for (const auto site : state_->nursery_config.sites)
out.site(site);
@@ -1338,12 +1342,32 @@ CellularLives::birth_candidate(LifeRequest request, LifeAllocation allocation) c
if (!budget || budget->body != endowed->body)
return std::unexpected{CellularLivesError::biology};
std::optional<biology::CellularPosition> position;
// Rules 12: a new founder starts at a seeded random spot anywhere in the region (1 mm
// clear of its edges), so starts spread out; the provisioned sites remain the fallback.
// Seeded by world, region and the life's identity, so replay places it identically.
std::vector<biology::CellularPosition> candidates;
if (state_->rules_version >= cellular_lives_liquid_rules) {
constexpr std::uint64_t margin = 1'000;
const auto& area = state_->config.area;
if (area.width_um > 2 * margin + budget->phenotype.extent &&
area.height_um > 2 * margin + budget->phenotype.extent) {
Random random{
mutation_seed(state_->world, state_->region, allocation.life, 0x5350574EU)};
const auto span_x = area.width_um - 2 * margin - budget->phenotype.extent;
const auto span_y = area.height_um - 2 * margin - budget->phenotype.extent;
for (int attempt = 0; attempt < 16; ++attempt)
candidates.push_back(
{margin + random.next() % span_x, margin + random.next() % span_y});
}
}
for (const auto site : state_->nursery_config.sites) {
if (site.x_um < 0 || site.y_um < 0)
return std::unexpected{CellularLivesError::invalid_config};
const biology::CellularPosition candidate{static_cast<std::uint64_t>(site.x_um),
static_cast<std::uint64_t>(site.y_um)};
candidates.push_back(
{static_cast<std::uint64_t>(site.x_um), static_cast<std::uint64_t>(site.y_um)});
}
std::optional<biology::CellularPosition> position;
for (const auto candidate : candidates) {
bool occupied = false;
for (const auto& living : state_->lives) {
if (living.presence == CellularPresence::suspended)
@@ -1582,7 +1606,9 @@ CellularLives::restore(std::span<const std::uint8_t> bytes, std::uint64_t world,
const auto cap = u32();
d.merged_cap = static_cast<std::uint16_t>(cap);
d.bubble_radius_um = u32();
if (in.get(4) != 0 || turn > 0xFFFFU || cap > 0xFFFFU ||
const auto cost = u32();
liquid.thrust_cost_per_mille = cost == 0 ? 1'000 : cost;
if (cost == 1'000 || turn > 0xFFFFU || cap > 0xFFFFU ||
!cellular_liquid_valid(liquid, config.area))
return std::unexpected{CellularLivesError::format};
auto generated = biology::CellularFlowField::shared(liquid.currents);