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
+41
View File
@@ -2,6 +2,7 @@
#include "fixtures/cellular_ecology.hpp"
#include <algorithm>
#include <array>
#include <cstdio>
#include <vector>
@@ -166,6 +167,44 @@ void trace_replays_brakes() {
require(replayed->snapshot() == live->snapshot(), "replay diverged from the live run");
}
// Founders start at a seeded random spot, not a provisioned site, identically on replay.
void founders_spawn_at_random() {
const auto state = liquid_region();
const auto first = state->lives().front().position;
const auto sites = std::array{1'000ULL, 4'000ULL};
require(!(std::ranges::find(sites, first.x_um) != sites.end() &&
std::ranges::find(sites, first.y_um) != sites.end()),
"a rules-12 founder started on a provisioned site");
require(first.x_um >= 1'000 && first.y_um >= 1'000 && first.x_um < 47'000 &&
first.y_um < 47'000,
"a founder started too close to the region edge");
// The same identity starts at the same spot (the fixture funds one founder).
auto again = liquid_region();
require(again->lives().front().position == first, "spawning is not deterministic");
}
// The declared thrust cost share scales every thrust and braking cost.
void thrust_cost_is_tunable() {
const auto state = liquid_region();
const auto& life = state->lives().front();
const auto genome = state->archive().find(life.identity.genome);
require(genome.has_value(), "founder genome missing");
const auto budget = biology::metabolic_budget(*genome, life.growth, {293'150, {}});
require(budget.has_value(), "founder budget");
auto full = rules();
auto quarter = rules();
quarter.thrust_cost_per_mille = 250;
const auto a = checked(cellular_liquid_handling(*genome, *budget, full), "full cost");
const auto b = checked(cellular_liquid_handling(*genome, *budget, quarter), "quarter cost");
require(a.thrust_cost.value > 0 &&
b.thrust_cost.value == (a.thrust_cost.value * 250 + 999) / 1'000 &&
b.thrust_q10 == a.thrust_q10,
"thrust cost did not scale");
auto zero = rules();
zero.thrust_cost_per_mille = 0;
require(!cellular_liquid_valid(zero, area), "a zero thrust cost share was accepted");
}
void older_rules_refuse_brake() {
auto state = opening(7, true, 1);
require(!state->advance_tick(swim(*state, {}, true)), "rules 8 accepted a brake");
@@ -179,6 +218,8 @@ int main() {
food_moves_and_merges_without_loss();
restore_continues_exactly();
trace_replays_brakes();
founders_spawn_at_random();
thrust_cost_is_tunable();
older_rules_refuse_brake();
} catch (const std::exception& error) {
std::fprintf(stderr, "%s\n", error.what());
+2 -1
View File
@@ -29,6 +29,7 @@ CellularTuning v0() {
.founder_drag_ppm_per_tick = 95'163,
.founder_lateral_drag_ppm_per_tick = 95'163,
.founder_turn_heading_per_s = 65'536,
.founder_thrust_cost_per_mille = 250,
.currents_min_count = 2,
.currents_max_count = 4,
.currents_min_width_um = 3'000,
@@ -114,7 +115,7 @@ void refusals() {
CHECK(!parsed && parsed.error().kind == CellularTuningErrorKind::missing_key &&
parsed.error().key == "mutation.offer_options");
const auto line = parse_cellular_tuning(base + "\nbad\n");
CHECK(!line && line.error().line == 41);
CHECK(!line && line.error().line == 42);
CHECK(error_of(std::string(max_cellular_tuning_bytes + 1, '#')) ==
CellularTuningErrorKind::too_large);
}
+1
View File
@@ -769,6 +769,7 @@ void cellular_v9_provisioning_declares_liquid() {
"region.perception_radius_um = 5000\nfounder.thrust_um_per_s2 = 400\n"
"founder.reverse_thrust_um_per_s2 = 400\nfounder.drag_ppm_per_tick = 95163\n"
"founder.lateral_drag_ppm_per_tick = 95163\nfounder.turn_heading_per_s = 65536\n"
"founder.thrust_cost_per_mille = 250\n"
"currents.min_count = 2\ncurrents.max_count = 4\ncurrents.min_width_um = 3000\n"
"currents.max_width_um = 6000\ncurrents.min_speed_um_per_s = 60\n"
"currents.max_speed_um_per_s = 300\ncurrents.grid_pitch_um = 250\n"