Files
aevolution/include/evo/biology/metabolism.hpp
T
dingoandClaude Opus 5.5 86ee800f32
Foundation / checks (ecs) (push) Successful in 3m21s
Foundation / checks (deploy) (push) Successful in 5m39s
Foundation / checks (tsan) (push) Successful in 11m43s
Foundation / checks (network) (push) Successful in 22m3s
Foundation / checks (client) (push) Successful in 22m35s
Foundation / checks (checks) (push) Successful in 46m53s
Foundation / checks (postgres) (push) Successful in 48m22s
Foundation / postgres-tools (push) Successful in 1m17s
Foundation / image (push) Successful in 3m31s
Foundation / server-image (push) Successful in 6m7s
Cellular rules 7: percentage mutations, skilled budding, hunting wildlife (ADR-0137)
The region 6 playtest found a speed mutation adding 6,667 um/s (1/300 of the range,
33x a founder), so buds seemed to teleport; reproduction made buds bigger and dearer;
and wildlife never hunted. Rules 7:

- genome schema 4: a step is a tenth of the current value (at least 1); an acquired
  capability starts at the founder's value instead of a minimum it could never grow from;
- development 4: a bud is always half the body, and reproduction takes value/2000 off
  its construction energy (founders save a quarter; matter is never discounted);
- twins: a seeded roll (reproduction/2 per thousand) splits one affordable bud's
  investment into two quarter-size buds;
- wildlife engulfs a touching cell the region step lets it take, players' included.

Founder 3, owner format 6 (no new state), bundle v8 and schema v42; the cellular-v6
opening provisions it. The client's mutation callout shrinks to a "Mutation [E]" pill and
its candidate texts describe the new steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 22:41:55 -04:00

68 lines
3.7 KiB
C++

#pragma once
#include "evo/accounting/ledger.hpp"
#include "evo/biology/development.hpp"
#include <optional>
namespace evo::biology {
// Development version 4 (rules 7, ADR-0137): a bud is always this share of the parent's body.
inline constexpr std::uint32_t bud_body_per_thousand_v4 = 500;
// Shares in thousandths over the ledger's C/N/P/other channels, summing to 1000.
// The last channel absorbs the rounding remainder, so a split conserves mass.
using Composition = std::array<std::uint16_t, 4>;
// Chosen constants, selected by the same development version as ADR-0031 and
// reviewable as a unit. Declared model parameters, not balance.
struct MetabolicRules {
Composition structure;
Composition membrane;
// Picojoules per rate period per 1000 femtograms at 1000 micrometres per rate period.
std::uint64_t movement_per_kilogram;
// Picojoules of intake capacity per 1000 femtograms of it.
std::uint64_t intake_energy_per_kilogram;
};
// The exact per-channel move from the body an organism has to the one a growth
// step produces. Composing the mass difference instead would discard the rounding
// the existing body already carries, so spending the budget could not reproduce
// the derived body on every channel. Release is a rounding artifact of the
// declared composition, bounded by a few femtograms; it is not excretion.
struct ConstructionTransition {
GrowthState after; // the growth this transition actually funds
accounting::Inventory intake; // energy and matter that must be acquired
accounting::Inventory release; // matter freed as the composition rebalances
auto operator<=>(const ConstructionTransition&) const = default;
};
// Every budget a phenotype implies. Each is derived from a different phenotype
// quantity, so one genome parameter moves some and not others: none of this is a
// multiplier applied to a total.
struct MetabolicBudget {
Phenotype phenotype;
accounting::Inventory body; // matter only; a body is not energy
// Rates are per rate_microseconds, the development version's period.
accounting::Picojoules maintenance; // per rate period
accounting::Picojoules movement; // per rate period at full speed, a capacity
accounting::Picojoules demand; // maintenance plus movement
ConstructionTransition construction; // what the next growth step would move
accounting::Inventory intake_limit; // per rate period
// Zero without the reproduction capability, rather than a default.
accounting::Inventory reproduction_investment;
std::uint16_t assimilation_per_thousand{};
// The period of the rates above and of the phenotype's (development_rate_microseconds).
std::uint64_t rate_microseconds{};
auto operator<=>(const MetabolicBudget&) const = default;
};
[[nodiscard]] std::expected<MetabolicRules, DevelopmentError>
metabolic_rules_for(std::uint32_t development_version);
// The single place the genome's description of capability becomes ledger
// quantities. The genome record itself stays free of accounting types.
[[nodiscard]] std::expected<MetabolicBudget, DevelopmentError>
metabolic_budget(const Genome& genome, GrowthState growth, EnvironmentState environment);
// An analysis, not a rule (ADR-0098 decision 7): whole seconds until feeding funds the
// budget's reproduction investment, channel by channel and in energy, when the organism
// takes in its full intake limit for `feeding_per_thousand` of the time and pays its
// whole demand (maintenance and full-speed movement) all of the time. Nothing when it
// never would: no investment, a channel it never takes in, or no energy surplus.
[[nodiscard]] std::optional<std::uint64_t>
bud_funding_seconds(const MetabolicBudget& budget, std::uint32_t feeding_per_thousand) noexcept;
} // namespace evo::biology