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,7 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "evo/biology/cellular_catalog.hpp"
|
||||
#include "evo/biology/cellular_tuning.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <compare>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
@@ -23,6 +25,8 @@ struct CellularRevampTuning {
|
||||
std::int64_t body_essential_upkeep_per_mille{};
|
||||
// Body: share of reserve matter carried as load on handling and thrust costs.
|
||||
std::int64_t body_reserve_load_per_mille{};
|
||||
// Body: growth per tick at growth speed 100, in hundredths of a per mille.
|
||||
std::int64_t body_growth_per_tick_centi_mille{};
|
||||
// Energy: picojoules 1,000 fg of each matter channel stand in for (burn efficiency 100).
|
||||
std::int64_t energy_burn_carbon_pj_per_kfg{}, energy_burn_nitrogen_pj_per_kfg{},
|
||||
energy_burn_phosphorus_pj_per_kfg{}, energy_burn_other_pj_per_kfg{};
|
||||
@@ -33,8 +37,24 @@ struct CellularRevampTuning {
|
||||
predation_kill_bubble_per_mille{};
|
||||
// The spent pool's drip back into the region.
|
||||
std::int64_t spent_drip_interval_ticks{}, spent_drip_bubble_pj{}, spent_drip_bubble_fg{};
|
||||
// Mutation offers (Cellular_mutation_plan.md section 3).
|
||||
std::int64_t mutation_options{}, mutation_floor_ppm{}, mutation_cap_ppm{};
|
||||
std::int64_t mutation_score_min{}, mutation_score_max{};
|
||||
std::int64_t mutation_max_multiplier_per_mille{}, mutation_min_multiplier_per_mille{};
|
||||
std::int64_t mutation_offer_interval_ticks{};
|
||||
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{};
|
||||
// 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{};
|
||||
auto operator<=>(const CellularRevampTuning&) const = default;
|
||||
};
|
||||
// A mutation's tunables as the file names them.
|
||||
inline constexpr std::array<std::string_view, 15> cellular_mutation_tuning_fields{
|
||||
"enabled", "base_weight", "increase_points", "decrease_points", "primary_step",
|
||||
"paired_step", "spread_step", "increase_ticks", "decrease_ticks", "cost_e_pj",
|
||||
"cost_c_fg", "cost_n_fg", "cost_p_fg", "cost_o_fg", "cost_scale_percent"};
|
||||
|
||||
[[nodiscard]] std::expected<CellularRevampTuning, CellularTuningError>
|
||||
parse_cellular_revamp_tuning(std::string_view text);
|
||||
|
||||
@@ -61,6 +61,8 @@ struct CellularStepCandidate {
|
||||
// Rules 13 (ADR-0179): reserve matter burned in place of energy, for the region's spent
|
||||
// pool. Costs paid this way add no heat.
|
||||
accounting::Inventory spent{};
|
||||
// Rules 13: a collection limit held matter (or energy) back while food was left.
|
||||
bool matter_limited{}, energy_limited{};
|
||||
auto operator<=>(const CellularStepCandidate&) const = default;
|
||||
};
|
||||
// Rules 12: liquid-relative motion inputs for one life (Cellular_Region_Movement_Plan.md).
|
||||
|
||||
@@ -74,6 +74,8 @@ inline constexpr std::uint32_t cellular_lives_revamp_rules = 13;
|
||||
rules == cellular_lives_revamp_rules;
|
||||
}
|
||||
inline constexpr std::uint32_t cellular_growth_per_tick = 5; // Per 50 ms; trial rate.
|
||||
// Rules 13: a bud engulfed within this many ticks of birth reports to its parent (2 minutes).
|
||||
inline constexpr std::uint64_t cellular_bud_early_ticks = 2'400;
|
||||
// The founder a region of these rules creates.
|
||||
[[nodiscard]] constexpr biology::FounderVersion
|
||||
cellular_founder_version(std::uint32_t rules) noexcept {
|
||||
@@ -136,6 +138,7 @@ struct CellularOwnedLife {
|
||||
std::uint64_t frozen_since{};
|
||||
std::uint64_t offspring_genome{}; // Format 8; older formats retain zero.
|
||||
biology::CellularMotionState motion{}; // Format 10; older formats retain zero.
|
||||
CellularRevampLife revamp{}; // Format 11 (rules 13): mutation state.
|
||||
auto operator<=>(const CellularOwnedLife&) const = default;
|
||||
};
|
||||
struct CellularOwnedCorpse {
|
||||
|
||||
@@ -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