feat(biology): liquid motion in the shared region tick
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m28s
Foundation / postgres-tools (push) Successful in 25s
Foundation / server-image (push) Successful in 4m3s
Foundation / image (push) Successful in 4m28s

Rules 12 lives carry a liquid input (motion state, handling, brake and the local
flow sample) and step through propose_liquid_cellular_step: maintenance first,
then one kinematic tick funded from what is left, so unfundable thrust coasts with
the current. A format-3 habitat requires liquid input on every life and older
habitats refuse it. Contact feeding sweeps each liquid cell's whole path so a fast
cell cannot pass over food; frozen cells keep their motion; corpse bubbles in a
format-3 habitat count one merged bubble and use the larger deposit limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-21 16:56:37 -04:00
co-authored by Claude Opus 5.5
parent 40dc2b12ad
commit 190a66ad5e
8 changed files with 319 additions and 9 deletions
+57
View File
@@ -96,4 +96,61 @@ propose_cellular_step(std::uint64_t begin_tick, CellularArea area, CellularPosit
candidate.intake = *intake;
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 {
if (begin_tick == std::numeric_limits<std::uint64_t>::max())
return std::unexpected{CellularStepError::invalid_tick};
if (budget.rate_microseconds != rate_period_microseconds)
return std::unexpected{CellularStepError::unsupported_rate_period};
const auto maintenance = accounting::per_tick(
budget.maintenance.value, cellular_motion_tick_microseconds, accounting::Rounding::up);
if (!maintenance)
return std::unexpected{CellularStepError::overflow};
if (reserve.energy.value < *maintenance)
return std::unexpected{CellularStepError::insufficient_maintenance};
if (!credit_heat(heat, *maintenance))
return std::unexpected{CellularStepError::overflow};
reserve.energy.value -= *maintenance;
const auto motion =
step_cellular_kinematics(area, position, extent_um, liquid.motion, {movement, liquid.brake},
liquid.handling, liquid.flow, reserve.energy);
if (!motion)
return std::unexpected{CellularStepError::motion};
if (!credit_heat(heat, motion->cost.value))
return std::unexpected{CellularStepError::overflow};
reserve.energy.value -= motion->cost.value;
CellularStepCandidate candidate{};
candidate.begin_tick = begin_tick;
candidate.end_tick = begin_tick + 1;
candidate.position = motion->position;
candidate.reserve_after = reserve;
candidate.heat_after = heat;
candidate.maintenance_cost = {*maintenance};
candidate.movement_cost = motion->cost;
candidate.motion = motion->state;
candidate.path_um = motion->path_um;
switch (motion->thrust) {
case CellularThrustStatus::idle:
candidate.movement_status = CellularMovementStatus::not_requested;
break;
case CellularThrustStatus::unfunded:
candidate.movement_status = CellularMovementStatus::insufficient_reserve;
break;
case CellularThrustStatus::applied:
// Blocked only when an edge stopped it; a sub-micrometre start is still moving.
candidate.movement_status = motion->position == position &&
motion->state.velocity_x_q10 == 0 &&
motion->state.velocity_y_q10 == 0
? CellularMovementStatus::blocked
: CellularMovementStatus::moved;
break;
}
return candidate;
}
} // namespace evo::biology