#pragma once #include "evo/accounting/ledger.hpp" #include "evo/biology/genome.hpp" #include #include #include namespace evo::server { // ADR-0175 trial values: light on a region's habitat, as picojoules per square micrometre // of a cell's cross-section per 50 ms tick (a rational), and the share a moving cell keeps. inline constexpr std::uint64_t cellular_light_trial_irradiance = 40; inline constexpr std::uint32_t cellular_light_trial_moving_per_thousand = 250; // Declared light on one habitat. The entitlement bounds cumulative capture; light nobody // captures is not modelled and never enters the books. struct CellularLight { std::uint64_t numerator{}, denominator{1}; accounting::Picojoules entitlement{}; std::uint32_t moving_per_thousand{cellular_light_trial_moving_per_thousand}; auto operator<=>(const CellularLight&) const = default; }; [[nodiscard]] constexpr bool cellular_light_valid(const CellularLight& light) noexcept { return light.denominator != 0 && light.moving_per_thousand <= 1000 && (light.numerator == 0) == (light.entitlement.value == 0); } // Energy one cell captures in a tick: cross-section (extent squared) x irradiance x its // photosynthesis efficiency, reduced while moving, rounded down. Nothing for a genome // without the capability. Nothing on overflow (refused, never wrapped). [[nodiscard]] std::optional cellular_light_capture(const biology::Genome& genome, std::uint32_t extent_um, const CellularLight& light, bool moving) noexcept; } // namespace evo::server