feat(cellular): rules 13 feeding, matter as energy, spent pool and predation
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 4s
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 4s
Foundation / checks (deploy) (push) Successful in 4m29s
Foundation / postgres-tools (push) Successful in 31s
Foundation / server-image (push) Successful in 4m24s
Foundation / image (push) Successful in 5m3s
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 4s
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 4s
Foundation / checks (deploy) (push) Successful in 4m29s
Foundation / postgres-tools (push) Successful in 31s
Foundation / server-image (push) Successful in 4m24s
Foundation / image (push) Successful in 5m3s
Phase 2 of the cellular revamp build plan (ADR-0179), server half. - Matter as energy: when an energy cost exceeds the reserve's energy, reserve matter stands in for the rest at each channel's burn rate (pJ per 1,000 fg, scaled by the genome's burn efficiency), largest channel first. Upkeep may burn any channel; thrust only channels the player has not excluded. Burned matter adds no heat; it goes to the region's spent pool. A cell dies only when nothing can pay its upkeep. - Collection: per-channel limits scaled by the genome's collection indices, a shared limit on all matter, a tunable cost per membrane point, and only the genome's kept share (energy conversion) of bubble energy reaching the reserve. - Predation: engulf mass carries a tunable share of reserve matter, the predator's engulf capacity scales its side and the prey's membrane (now in nanometres) its own; kill absorption scales the predator's intake; the kill's remainder is split between bubbles at the prey and the spent pool, and a full habitat sends overflow to the pool. - The spent pool is owner format 11 state, counted in conservation, and drips back as seeded random bubbles every interval tick. - Reserve matter is carried as load: slower thrust and turning, costlier thrust. - Channel exclusions are a 4-bit step intent field, trace byte 14; only owned lives under rules 13 may send them. All values come from the revamp tuning file. Rules up to 12 are unchanged. Tests cover payments and their conservation over 400 seeds, the rules-13 region step (collection, membrane, kept energy, burning, engulfment and kill splits with closure), the drip, load, exclusions, a 700-tick run with closure and exact restore, and trace replay with exclusions. Session v14 and the client follow the server phases (build plan). Refreshes the DEV session window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -97,11 +97,10 @@ propose_cellular_step(std::uint64_t begin_tick, CellularArea area, CellularPosit
|
||||
return candidate;
|
||||
}
|
||||
|
||||
std::expected<CellularStepCandidate, CellularStepError>
|
||||
propose_liquid_cellular_step(std::uint64_t begin_tick, CellularArea area, CellularPosition position,
|
||||
std::uint32_t extent_um, CellularIntent movement,
|
||||
const CellularLiquidInput& liquid, accounting::Inventory reserve,
|
||||
accounting::Inventory heat, const MetabolicBudget& budget) noexcept {
|
||||
std::expected<CellularStepCandidate, CellularStepError> propose_liquid_cellular_step(
|
||||
std::uint64_t begin_tick, CellularArea area, CellularPosition position, std::uint32_t extent_um,
|
||||
CellularIntent movement, const CellularLiquidInput& liquid, accounting::Inventory reserve,
|
||||
accounting::Inventory heat, const MetabolicBudget& budget, const CellularBurn* burn) noexcept {
|
||||
if (begin_tick == std::numeric_limits<std::uint64_t>::max())
|
||||
return std::unexpected{CellularStepError::invalid_tick};
|
||||
if (budget.rate_microseconds != rate_period_microseconds)
|
||||
@@ -110,20 +109,35 @@ propose_liquid_cellular_step(std::uint64_t begin_tick, CellularArea area, Cellul
|
||||
budget.maintenance.value, cellular_motion_tick_microseconds, accounting::Rounding::up);
|
||||
if (!maintenance)
|
||||
return std::unexpected{CellularStepError::overflow};
|
||||
if (reserve.energy.value < *maintenance)
|
||||
accounting::Inventory spent{};
|
||||
// Energy goes to heat; matter standing in for it goes to the spent pool (rules 13).
|
||||
const auto pay = [&](std::uint64_t cost, bool upkeep) {
|
||||
if (burn == nullptr) {
|
||||
if (reserve.energy.value < cost)
|
||||
return false;
|
||||
reserve.energy.value -= cost;
|
||||
return credit_heat(heat, cost);
|
||||
}
|
||||
const auto paid = cellular_pay(reserve, cost, *burn, upkeep);
|
||||
if (!paid)
|
||||
return false;
|
||||
for (std::size_t c = 0; c < spent.matter.size(); ++c)
|
||||
spent.matter[c].value += paid->spent.matter[c].value;
|
||||
return credit_heat(heat, paid->energy);
|
||||
};
|
||||
if (!pay(*maintenance, true))
|
||||
return std::unexpected{CellularStepError::insufficient_maintenance};
|
||||
if (!credit_heat(heat, *maintenance))
|
||||
return std::unexpected{CellularStepError::overflow};
|
||||
reserve.energy.value -= *maintenance;
|
||||
|
||||
// Thrust may draw on unexcluded matter too, but never on excluded matter.
|
||||
const accounting::Picojoules offered{
|
||||
burn == nullptr ? reserve.energy.value : cellular_payable_energy(reserve, *burn, false)};
|
||||
const auto motion =
|
||||
step_cellular_kinematics(area, position, extent_um, liquid.motion, {movement, liquid.brake},
|
||||
liquid.handling, liquid.flow, reserve.energy);
|
||||
liquid.handling, liquid.flow, offered);
|
||||
if (!motion)
|
||||
return std::unexpected{CellularStepError::motion};
|
||||
if (!credit_heat(heat, motion->cost.value))
|
||||
if (!pay(motion->cost.value, false))
|
||||
return std::unexpected{CellularStepError::overflow};
|
||||
reserve.energy.value -= motion->cost.value;
|
||||
|
||||
CellularStepCandidate candidate{};
|
||||
candidate.begin_tick = begin_tick;
|
||||
@@ -135,6 +149,7 @@ propose_liquid_cellular_step(std::uint64_t begin_tick, CellularArea area, Cellul
|
||||
candidate.movement_cost = motion->cost;
|
||||
candidate.motion = motion->state;
|
||||
candidate.path_um = motion->path_um;
|
||||
candidate.spent = spent;
|
||||
switch (motion->thrust) {
|
||||
case CellularThrustStatus::idle:
|
||||
candidate.movement_status = CellularMovementStatus::not_requested;
|
||||
|
||||
Reference in New Issue
Block a user