feat(lifecycle): rules 13 behaviour-weighted mutation offers in the owner
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 4m34s
Foundation / postgres-tools (push) Successful in 22s
Foundation / server-image (push) Successful in 4m16s
Foundation / image (push) Successful in 4m47s
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 4m34s
Foundation / postgres-tools (push) Successful in 22s
Foundation / server-image (push) Successful in 4m16s
Foundation / image (push) Successful in 4m47s
Phase 3 of the cellular revamp build plan (ADR-0179), server half. - Every owned, active rules-13 life gathers its activity each tick from every phase (thrust and drift, brake presses, feeding and the collection limits, matter burned by channel, energy by use, contact with larger cells, engulf outcomes, growth blocked by a channel, buds made, refused or lost young, the reserve against the body) and advances its 98 triggers and 49 affinity scores. - Active play earns an offer every interval: eligible catalog mutations of the life's plan, weighted by affinity, drawn with the floored and capped chances and a seeded systematic draw (a retry draws the same offer). Wildlife, newborns and frozen cells earn nothing; a plan without schema-7 traits has no catalog. - A choice must name the life's own pending offer. It edits the offspring plan (phase 4 turns this into the split), pays the mutation's tuned cost from the reserve (matter may stand in for its energy, excluded channels excepted) and reclaims it as seeded random bubbles, merging into the farthest deposit at the deposit limit. Unaffordable choices keep the offer; declines clear it. - Offspring inherit affinity scores and lineage progress. Growth speed scales the growth step with a carried fraction. - Format 11 persists the offer tunables and each life's mutation state; the revamp tuning file gains the offer keys and optional per-mutation overrides (mutation.<key>.<field>), defaulting to the catalog with zero costs. Tests cover per-mutation overrides and refusals, the collection-limit flags, offers from active play, founder-5 plans never offered, exact restore of a pending offer, a choice editing only the plan and reclaiming its cost with closure, unaffordable choices, declines, foreign choices, and thrust moving affinity. Refreshes the DEV session window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "evo/biology/cellular_catalog.hpp"
|
||||
#include "evo/biology/cellular_habitat.hpp"
|
||||
#include "evo/biology/cellular_motion.hpp"
|
||||
#include "evo/biology/cellular_offers.hpp"
|
||||
#include "evo/biology/cellular_region_step.hpp"
|
||||
#include "evo/biology/cellular_revamp_tuning.hpp"
|
||||
#include "evo/biology/cellular_triggers.hpp"
|
||||
#include "evo/biology/development.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <compare>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
||||
// Rules 13 (ADR-0179, Cellular_Revamp_Build_Plan.md): what a cellular owner declares when it
|
||||
// upgrades to owner format 11. Taken from the Git tuning file when the region opens and
|
||||
@@ -26,9 +31,61 @@ struct CellularRevampRules {
|
||||
// Share of reserve matter carried as load, per mille: it slows thrust and turning and makes
|
||||
// thrust costlier, in proportion to the body's mass. Upkeep stays on the body.
|
||||
std::uint32_t reserve_load_per_thousand{};
|
||||
// Growth per tick in hundredths of a per mille at growth speed 100 (trial 500: 5 per mille).
|
||||
std::uint32_t growth_per_tick_centi_mille{500};
|
||||
// Mutation offers: the draw, the catalog's bounds and gates, the cadence in active ticks,
|
||||
// and every catalog mutation's tunables in catalog order.
|
||||
biology::CellularOfferRules offers{};
|
||||
biology::CellularCatalogBounds bounds{};
|
||||
std::uint32_t offer_interval_ticks{500};
|
||||
std::array<biology::CellularMutationTuning, biology::cellular_catalog_size> mutations{};
|
||||
auto operator<=>(const CellularRevampRules&) const = default;
|
||||
};
|
||||
|
||||
// A rules-13 offer: the drawn mutations (catalog ids) and their chances, in catalog order.
|
||||
inline constexpr std::size_t max_cellular_offer_options = 10;
|
||||
struct CellularRevampOffer {
|
||||
std::uint64_t event_index{}, offer_tick{};
|
||||
std::uint8_t count{};
|
||||
std::array<std::uint16_t, max_cellular_offer_options> ids{};
|
||||
std::array<std::uint32_t, max_cellular_offer_options> chances{};
|
||||
auto operator<=>(const CellularRevampOffer&) const = default;
|
||||
};
|
||||
// A rules-13 life's mutation state: affinity, lineage progress, the cadence counter, the pending
|
||||
// offer (count 0: none), the previous tick's brake (for presses) and the growth carry.
|
||||
struct CellularRevampLife {
|
||||
biology::CellularAffinity affinity{};
|
||||
biology::CellularLineageProgress progress{};
|
||||
std::uint32_t active_ticks{};
|
||||
std::uint8_t last_brake{};
|
||||
std::uint32_t growth_carry{};
|
||||
std::uint64_t events{}; // Offers made so far; the next offer's event index is events + 1.
|
||||
CellularRevampOffer offer{};
|
||||
auto operator<=>(const CellularRevampLife&) const = default;
|
||||
};
|
||||
|
||||
// The rules' offer settings as the catalog and offer code take them.
|
||||
[[nodiscard]] bool cellular_revamp_offer_rules_valid(const CellularRevampRules& rules) noexcept;
|
||||
|
||||
// Draws an offer from `plan`'s eligible mutations at its affinity, or nothing when fewer
|
||||
// mutations are eligible than the cap can fill. Seeded by world, region, life and event, so a
|
||||
// retry draws the same offer.
|
||||
[[nodiscard]] std::optional<CellularRevampOffer>
|
||||
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);
|
||||
|
||||
// What choosing a mutation costs: its amounts times its scale.
|
||||
[[nodiscard]] accounting::Inventory
|
||||
cellular_mutation_cost(const biology::CellularMutationTuning& tuning) noexcept;
|
||||
|
||||
// Returns `amount` to the region as bubbles at seeded random spots, one per non-empty channel;
|
||||
// a habitat at its deposit limit merges each into the existing deposit farthest from `from`.
|
||||
// False only on identity overflow.
|
||||
[[nodiscard]] bool cellular_reclaim(biology::CellularHabitatConfig& config,
|
||||
const accounting::Inventory& amount, std::uint64_t seed,
|
||||
biology::CellularPosition from, std::uint64_t source);
|
||||
|
||||
[[nodiscard]] bool cellular_revamp_valid(const CellularRevampRules& rules) noexcept;
|
||||
// The spent pool's drip for the tick ending at `tick`: on every `drip_interval_ticks`-th tick,
|
||||
// one bubble per non-empty channel of at most the declared size, taken from `spent`, at a
|
||||
|
||||
Reference in New Issue
Block a user