#pragma once #include "evo/biology/lineage.hpp" #include "evo/biology/mutation.hpp" #include "evo/processes/genome_strategy.hpp" namespace evo::processes { // One point of the gradient. The two axes reach a run by different routes, and // neither route is the other's. Temperature enters the derivation: it sets the // phenotype's thermal shortfall, which reaches the ecology through the scheduling // rule below. Resource level does not enter the derivation at all. Founders are // derived fully grown, so their construction transition is empty and // `EnvironmentState::available` cannot move `intake_limit`, assimilation or // reproduction investment; the resource level reaches a run only as the nutrient // pool an episode starts with, which bounds producer growth. struct GradientCell { std::uint32_t temperature_millikelvin; std::uint64_t nutrients; auto operator<=>(const GradientCell&) const = default; }; struct EnsembleConfig { std::vector gradient; std::uint64_t seeds_per_cell; std::uint64_t tick_limit; std::uint32_t base_lifespan; // Ticks of scheduled life lost per kelvin of thermal shortfall. This extends // ADR-0029's lifespan rule, which is a harness scheduling device and not // biology. It is not a mortality model and no contract knows about it. std::uint32_t lifespan_lost_per_kelvin; }; // What one strategy did in one half of one cell's seeds. Reported per half so an // effect that only appears in one of them is visible as the artifact it is. struct StrategyOutcome { std::uint64_t genome; std::uint64_t episodes; std::uint64_t births; std::uint64_t organisms; // An organism observed to die and one whose episode simply stopped are not the // same fact, and the two are never added together. `deaths` counts organisms // seen to die and `lived_ticks` sums their complete lifetimes. `survivors` // counts organisms still alive when observation ended and `observed_ticks` // sums how long each was watched, which is a lower bound on a life whose // length is not known. A mean lifetime computed over both would understate // every survivor, so a reader has to choose which question it is asking. std::uint64_t deaths; std::uint64_t lived_ticks; std::uint64_t survivors; std::uint64_t observed_ticks; std::uint64_t thermal_shortfall; // summed over the episodes of this half std::uint32_t scheduled_lifespan; auto operator<=>(const StrategyOutcome&) const = default; }; struct CellReport { GradientCell cell; std::vector first_half; std::vector second_half; std::uint64_t ticks; std::uint64_t extinctions; auto operator<=>(const CellReport&) const = default; }; struct EnsembleReport { std::vector cells; std::uint64_t episodes; std::uint64_t ticks; std::uint64_t archived_genomes; std::uint64_t archived_organisms; std::uint64_t fingerprint; auto operator<=>(const EnsembleReport&) const = default; }; // Produces the founder strategies by diverging one ancestor before any episode // runs. Nothing mutates during an episode: an organism diverging on its own is // the NPC-mutation question that remains open. [[nodiscard]] std::expected, EcosystemError> diverge_founders(const biology::Genome& ancestor, std::size_t wanted, std::uint64_t seed); // Runs the grid, recording every birth and death in the archive as it happens, so // the diversity a report carries comes from retained records. [[nodiscard]] std::expected run_ensemble(biology::LineageArchive& archive, std::span founders, const EcosystemConfig& base, const EnsembleConfig& plan, std::uint64_t seed); } // namespace evo::processes