feat(lifecycle): rules 13 mutation splits, stay-or-become and litter
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m22s
Foundation / postgres-tools (push) Successful in 22s
Foundation / server-image (push) Successful in 4m21s
Foundation / image (push) Successful in 5m6s

Phase 4 of the cellular revamp build plan (ADR-0179), server half.

- A chosen mutation now splits the cell (Cellular_reproduction_plan.md section
  4): split_cell divides body and reserve per channel by the tuned share, each
  cell develops the largest body its own genome builds from its part, and the
  rest joins its reserve, conserving every channel. Both plans carry the
  mutation; only the offspring expresses it. A split is refused, spending
  nothing and keeping the offer, below the tuned growth, without room beside
  the cell or at the region's organism cap.
- Stay or become: a choice (trace mutation byte 34) or a bud (step intent bit 2
  of byte 13) can hand control to the offspring; the parent becomes wildlife.
  Ownership now follows the account under rules 13, so validation and plan
  history accept a founder that became wildlife (ADR-0163 succession).
- Buds under rules 13: litter replaces the 25% twin (whole hundreds plus a
  chance, up to the tuned maximum, sharing one investment), the tuned bud fee is
  charged once and reclaimed, and births stop at the organism cap.
- New results split_applied and split_refused; owners below rules 13 refuse a
  become.

The revamp tuning file gains the reproduction keys. Tests cover the split's
conservation and refusals, stay and become splits with exact restore, a refused
second split, the cap, become validation and the litter count. Refreshes the DEV
session window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-22 22:19:48 -04:00
co-authored by Claude Opus 5.5
parent 7e5775b6f7
commit 9f117c9545
19 changed files with 540 additions and 71 deletions
+16
View File
@@ -50,6 +50,22 @@ fund_offspring(const Genome& parent, const Genome& offspring, GrowthState parent
[[nodiscard]] std::optional<accounting::Inventory>
offspring_cost(const Genome& parent, const Genome& offspring, std::uint32_t temperature_millikelvin,
std::uint32_t share = 1);
// Rules 13 (ADR-0179; Cellular_reproduction_plan.md section 4): a mutation split. The parent's
// body and reserve divide per channel, the offspring taking `share_per_thousand` (rounded
// down); each cell then develops the largest growth its own genome builds from its part of the
// body, and matter beyond that joins its reserve. Nothing is built, burned or lost: on every
// channel the two bodies and reserves sum to the parent's. Refused, changing nothing, when
// the parent is below `min_growth` or damaged, or either part builds no cell at all.
struct SplitTransition {
GrowthState parent_growth{}, child_growth{};
accounting::Inventory parent_body{}, parent_reserve{}, child_body{}, child_reserve{};
auto operator<=>(const SplitTransition&) const = default;
};
[[nodiscard]] std::expected<SplitTransition, BuddingError>
split_cell(const Genome& parent, const Genome& child, GrowthState growth,
const accounting::Inventory& body, const accounting::Inventory& reserve,
std::uint32_t temperature_millikelvin, std::uint32_t share_per_thousand,
std::uint32_t min_growth, const BodyTuning& tuning = default_body_tuning);
// What one bud takes from a fully grown, undamaged parent of this genome at this temperature
// (ADR-0129 amendment): investment matter per channel, and construction energy plus the
// bud's provision; exactly what `fund_bud` charges such a parent. Nullopt when the genome
@@ -45,6 +45,11 @@ struct CellularRevampTuning {
std::int64_t mutation_min_points{}, mutation_max_points{}, mutation_recipe_min_share{};
std::int64_t mutation_max_offspring{}, mutation_carbon_for_light_fg{},
mutation_buds_for_adhesion{};
// Reproduction (Cellular_reproduction_plan.md).
std::int64_t reproduction_split_share_per_mille{}, reproduction_split_min_growth_per_mille{};
std::int64_t reproduction_bud_fee_e_pj{}, reproduction_bud_fee_c_fg{},
reproduction_bud_fee_n_fg{}, reproduction_bud_fee_p_fg{}, reproduction_bud_fee_o_fg{};
std::int64_t reproduction_bud_fee_scale_percent{}, reproduction_organism_cap{};
// Each catalog mutation's tunables, in catalog order. Optional keys
// `mutation.<key>.<field>` override the defaults from its spec.
std::array<CellularMutationTuning, cellular_catalog_size> mutations{};
+2
View File
@@ -25,6 +25,8 @@ struct CellularStepIntent {
// Rules 13 (ADR-0179): matter channels the player keeps from being burned for anything but
// upkeep, bit 0 carbon to bit 3 other matter. Wildlife keeps nothing.
std::uint8_t exclude{};
// Rules 13: with `bud`, the player continues as the (first) bud; the parent becomes wildlife.
bool become{};
auto operator<=>(const CellularStepIntent&) const = default;
};
@@ -178,6 +178,8 @@ struct CellularLifeIntent {
struct CellularMutationSelection {
std::uint64_t life_id{}, event_index{}, offer_tick{}, successor_id{};
std::uint16_t operator_id{};
// Rules 13: the split's offspring becomes the player's cell; the founder becomes wildlife.
bool become{};
auto operator<=>(const CellularMutationSelection&) const = default;
};
// declined (ADR-0120 amendment): operator 0 consumed the offer without changing the genome.
@@ -186,7 +188,9 @@ enum class CellularMutationResult : std::uint8_t {
life_died,
insufficient_funding,
declined,
offspring_plan_applied // Rules 10: inherited plan changed, expressed body did not.
offspring_plan_applied, // Rules 10: inherited plan changed, expressed body did not.
split_applied, // Rules 13: the cell split; the offspring expresses the mutation.
split_refused // Rules 13: no split now (size, room or region cap); offer kept.
};
struct CellularMutationExecution {
std::uint64_t life_id{}, successor_id{};
@@ -39,6 +39,12 @@ struct CellularRevampRules {
biology::CellularCatalogBounds bounds{};
std::uint32_t offer_interval_ticks{500};
std::array<biology::CellularMutationTuning, biology::cellular_catalog_size> mutations{};
// Reproduction: the offspring's share of a split and the growth a cell needs to split; the
// on-demand bud's fee (amounts times scale, reclaimed); the region's organism cap.
std::uint32_t split_share_per_thousand{500}, split_min_growth{1'000};
accounting::Inventory bud_fee{};
std::uint32_t bud_fee_scale_percent{};
std::uint32_t organism_cap{256};
auto operator<=>(const CellularRevampRules&) const = default;
};
@@ -75,6 +81,14 @@ cellular_draw_offer(const biology::Genome& plan, const CellularRevampLife& life,
const CellularRevampRules& rules, std::uint64_t world, std::uint64_t region,
std::uint64_t life_id, std::uint64_t tick);
// How many offspring one bud makes from `litter` (hundredths of an extra offspring) and a roll:
// one, plus every whole hundred, plus one more when roll % 100 falls below the remainder; at most
// max_litter / 100 + 1.
[[nodiscard]] constexpr std::uint32_t
cellular_litter_count(std::uint32_t litter, std::uint64_t roll, std::uint32_t max_litter) noexcept {
const auto count = 1 + litter / 100 + (roll % 100 < litter % 100 ? 1U : 0U);
return count < max_litter / 100 + 1 ? count : max_litter / 100 + 1;
}
// What choosing a mutation costs: its amounts times its scale.
[[nodiscard]] accounting::Inventory
cellular_mutation_cost(const biology::CellularMutationTuning& tuning) noexcept;