Files
aevolution/src/server/lifecycle/cellular_liquid.cpp
T
dingoandClaude Opus 5.5 3f82795c18
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 4m23s
Foundation / postgres-tools (push) Successful in 29s
Foundation / server-image (push) Successful in 4m10s
Foundation / image (push) Successful in 4m31s
feat(lifecycle): rules 12 liquid owner on format 10 with brake traces
The cellular owner gains rules 12 on owner format 10: an explicit no-tick
format-9/rules-11 upgrade declares the region's liquid rules (current
configuration, founder handling and deposit motion, from the tuning file and a
seed when the region opens), converts the habitat to format 3 and starts lives at
rest. Founders born afterwards are founder 5 (genome schema 6).

Each tick derives every life's handling from its genome and the declared founder
handling, samples the current at its footprint and steps the shared liquid
motion; afterwards bubbles move with the current and the drift moving cells
induce, and touching bubbles merge. Format 10 persists the rules and each life's
motion state; restore regenerates the identical current field.

Brake is a new step intent, valid only under rules 12, carried in trace 4 as flag
bit 1 (SQL never parses that byte; player action records keep it zero). Tests
cover the upgrade, exact restore, swimming and braking, moving food with fixed
pools, restore continuing a live run, and brake traces replaying exactly. Genomes
from before schema 6 handle as founders. Refreshes the DEV session window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 17:28:58 -04:00

48 lines
2.9 KiB
C++

#include "evo/server/lifecycle/cellular_liquid.hpp"
namespace evo::server {
bool cellular_liquid_valid(const CellularLiquidRules& rules, biology::CellularArea area) noexcept {
const auto& c = rules.currents;
const auto& f = rules.founder;
const auto& d = rules.deposits;
// Generation itself is checked once, by the owner that keeps the generated field.
return c.width_um == area.width_um && c.height_um == area.height_um && c.pitch_um != 0 &&
c.pitch_um <= biology::max_cellular_current_pitch_um && c.min_count <= c.max_count &&
f.thrust_q10 <= static_cast<std::uint32_t>(biology::cellular_velocity_limit_q10) &&
f.reverse_thrust_q10 <=
static_cast<std::uint32_t>(biology::cellular_velocity_limit_q10) &&
f.forward_drag_ppm < biology::cellular_drag_ppm_limit &&
f.lateral_drag_ppm < biology::cellular_drag_ppm_limit &&
f.turn <= biology::cellular_heading_turn / 2 && f.thrust_cost.value == 0 &&
f.reverse_cost.value == 0 && d.merged_cap != 0 && d.bubble_radius_um != 0 &&
d.bubble_radius_um <= biology::max_cellular_deposit_radius_um && d.max_drift_q10 >= 0 &&
d.max_drift_q10 <= biology::cellular_velocity_limit_q10 &&
d.drift_decay_ppm < biology::cellular_drag_ppm_limit;
}
CellularLiquidRules cellular_liquid_rules(const biology::CellularTuning& t,
biology::CellularArea area, std::uint64_t seed) {
const auto u32 = [](std::int64_t value) { return static_cast<std::uint32_t>(value); };
return {
.currents = {seed, u32(static_cast<std::int64_t>(area.width_um)),
u32(static_cast<std::int64_t>(area.height_um)), u32(t.currents_grid_pitch_um),
u32(t.currents_min_count), u32(t.currents_max_count),
u32(t.currents_min_width_um), u32(t.currents_max_width_um),
u32(t.currents_min_speed_um_per_s), u32(t.currents_max_speed_um_per_s)},
.founder = biology::founder_cellular_handling(t, {}, {}),
.deposits = {.drift_radius_um = u32(t.food_induced_drift_radius_um),
.max_drift_q10 =
static_cast<std::int32_t>(t.food_induced_drift_max_um_per_s *
biology::cellular_velocity_q10_per_um_s),
.drift_decay_ppm = u32(t.food_induced_drift_decay_ppm_per_tick),
.merged_cap = static_cast<std::uint16_t>(t.food_merged_bubble_cap_multiple),
.bubble_radius_um = biology::cellular_mote_radius_um}};
}
std::expected<biology::CellularHandling, biology::CellularHandlingError>
cellular_liquid_handling(const biology::Genome& genome, const biology::MetabolicBudget& budget,
const CellularLiquidRules& rules) {
return biology::derive_cellular_handling(genome, budget, rules.founder);
}
} // namespace evo::server