feat(biology): evolve photosynthetic producers that capture light
Foundation / checks (ecs) (push) Successful in 2m25s
Foundation / checks (deploy) (push) Successful in 5m15s
Foundation / checks (network) (push) Successful in 21m56s
Foundation / checks (client) (push) Successful in 22m54s
Foundation / checks (tsan) (push) Successful in 47m4s
Foundation / checks (postgres) (push) Successful in 1h15m49s
Foundation / checks (checks) (push) Failing after 1h30m4s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
Foundation / checks (ecs) (push) Successful in 2m25s
Foundation / checks (deploy) (push) Successful in 5m15s
Foundation / checks (network) (push) Successful in 21m56s
Foundation / checks (client) (push) Successful in 22m54s
Foundation / checks (tsan) (push) Successful in 47m4s
Foundation / checks (postgres) (push) Successful in 1h15m49s
Foundation / checks (checks) (push) Failing after 1h30m4s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
ADR-0175 implements ADR-0136 step C with trial costs to be balanced after playtesting. Genome schema 5 adds a photosynthesis efficiency (empty in schemas 1-4, so earlier offers and draws are unchanged; mutation operators 29-32 are appended). Development version 5 builds the organelles as internal membrane (p/4 of structure, upkept twice) and slows movement by p/2 per thousand. Founder 4 and cellular rules 11 let lineages earn the capability as an offspring plan that children express. Owner format 9 declares the region's light. Inside each tick's detached candidate, active unfrozen producers capture cross-section x irradiance x efficiency (a quarter while moving), credited to the reserve and boundary inflow together and replayed from recorded intentions. Well-lit wildlife producers hold still. The joint owner keeps infall, water and radiation and nests a rules-11 owner unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,8 +32,8 @@ inline constexpr std::uint64_t development_v2_rate_microseconds = 1'000'000;
|
||||
[[nodiscard]] constexpr std::uint64_t
|
||||
development_rate_microseconds(std::uint32_t development_version) noexcept {
|
||||
return development_version == 1 ? development_v1_tick_microseconds
|
||||
: development_version >= 2 && development_version <= 4
|
||||
? development_v2_rate_microseconds // Versions 3 and 4 keep version 2's rates.
|
||||
: development_version >= 2 && development_version <= 5
|
||||
? development_v2_rate_microseconds // Versions 3-5 keep version 2's rates.
|
||||
: 0;
|
||||
}
|
||||
// Chosen constants, reviewable as a unit and selected by the genome's
|
||||
@@ -64,6 +64,12 @@ struct Phenotype {
|
||||
std::uint32_t thermal_shortfall{};
|
||||
auto operator<=>(const Phenotype&) const = default;
|
||||
};
|
||||
// Development version 5 (ADR-0175; trial values): photosynthetic organelles are membrane
|
||||
// built inside the cell. At efficiency p per thousand they add p/4 of the structural mass
|
||||
// as membrane mass (so they are upkept twice, like membrane) and slow movement by p/2 per
|
||||
// thousand. Light itself is captured by the region's environment owner, never here.
|
||||
inline constexpr std::uint32_t photosynthesis_organelle_quarter = 4;
|
||||
inline constexpr std::uint32_t photosynthesis_speed_halving = 2;
|
||||
// A proposal. It reserves nothing, pays for nothing and commits nothing; the
|
||||
// matching transfer does not exist until M3.3.
|
||||
struct DevelopmentPlan {
|
||||
|
||||
@@ -34,6 +34,9 @@ inline constexpr FounderVersion primitive_founder_v1{genome_schema_v2, 2};
|
||||
inline constexpr FounderVersion primitive_founder_v2{genome_schema_v3, 3};
|
||||
// Founder 3 serves rules 7 (ADR-0137): percentage mutation steps and skilled reproduction.
|
||||
inline constexpr FounderVersion primitive_founder_v3{genome_schema_v4, 4};
|
||||
// Founder 4 serves rules 11 (ADR-0175): founder 3 that can evolve photosynthesis. Founders
|
||||
// start without it; the capability is only ever earned through mutation.
|
||||
inline constexpr FounderVersion primitive_founder_v4{genome_schema_v5, 5};
|
||||
inline constexpr std::uint32_t primitive_founder_development_version =
|
||||
primitive_founder_v1.development_version;
|
||||
// The founder genome under a world-scoped identity and its origin event. Fails only on
|
||||
|
||||
@@ -17,9 +17,10 @@ enum class Capability : std::uint8_t {
|
||||
ingestion,
|
||||
reproduction,
|
||||
target_size,
|
||||
thermal_tolerance
|
||||
thermal_tolerance,
|
||||
photosynthesis // Schema 5 (ADR-0175); unrepresentable in earlier schemas.
|
||||
};
|
||||
inline constexpr std::size_t capability_count = 7;
|
||||
inline constexpr std::size_t capability_count = 8;
|
||||
// The unit is a schema fact per kind and is never encoded, so no record can
|
||||
// contradict its own units.
|
||||
enum class Unit : std::uint8_t {
|
||||
@@ -55,7 +56,9 @@ inline constexpr std::array<CapabilitySpec, capability_count> capability_schema_
|
||||
CapabilitySpec{Unit::per_thousand, 1, 1000, false,
|
||||
capability_bit(Capability::energy_conversion)},
|
||||
CapabilitySpec{Unit::femtograms, 1, 1'000'000'000, true, 0},
|
||||
CapabilitySpec{Unit::millikelvin, 1, 100'000, false, 0}};
|
||||
CapabilitySpec{Unit::millikelvin, 1, 100'000, false, 0},
|
||||
// An empty range: no schema-1 record can carry photosynthesis.
|
||||
CapabilitySpec{Unit::per_thousand, 1, 0, false, 0}};
|
||||
// Schema 2 (ADR-0099): the same capabilities with rates per second. Each rate range is
|
||||
// schema 1's times 20, so every schema 1 value has an exact schema 2 equivalent.
|
||||
inline constexpr std::array<CapabilitySpec, capability_count> capability_schema_v2{
|
||||
@@ -68,7 +71,22 @@ inline constexpr std::array<CapabilitySpec, capability_count> capability_schema_
|
||||
CapabilitySpec{Unit::per_thousand, 1, 1000, false,
|
||||
capability_bit(Capability::energy_conversion)},
|
||||
CapabilitySpec{Unit::femtograms, 1, 1'000'000'000, true, 0},
|
||||
CapabilitySpec{Unit::millikelvin, 1, 100'000, false, 0}};
|
||||
CapabilitySpec{Unit::millikelvin, 1, 100'000, false, 0},
|
||||
CapabilitySpec{Unit::per_thousand, 1, 0, false, 0}}; // Not in schemas 2-4.
|
||||
// Schema 5 (ADR-0175): schema 2 plus photosynthesis, an efficiency per thousand that
|
||||
// needs a membrane to hold its organelles.
|
||||
inline constexpr std::array<CapabilitySpec, capability_count> capability_schema_v5{
|
||||
CapabilitySpec{Unit::per_thousand, 1, 1000, true, 0},
|
||||
CapabilitySpec{Unit::micrometres, 1, 10'000, true, 0},
|
||||
CapabilitySpec{Unit::micrometres_per_second, 0, 2'000'000, false,
|
||||
capability_bit(Capability::membrane)},
|
||||
CapabilitySpec{Unit::femtograms_per_second, 0, 20'000'000, false,
|
||||
capability_bit(Capability::membrane)},
|
||||
CapabilitySpec{Unit::per_thousand, 1, 1000, false,
|
||||
capability_bit(Capability::energy_conversion)},
|
||||
CapabilitySpec{Unit::femtograms, 1, 1'000'000'000, true, 0},
|
||||
CapabilitySpec{Unit::millikelvin, 1, 100'000, false, 0},
|
||||
CapabilitySpec{Unit::per_thousand, 1, 1000, false, capability_bit(Capability::membrane)}};
|
||||
// The current schema's table.
|
||||
inline constexpr const auto& capability_schema = capability_schema_v2;
|
||||
// Schema 1 rates are per tick of this quantum.
|
||||
@@ -114,15 +132,18 @@ inline constexpr std::uint32_t genome_schema_v3 = 3;
|
||||
// Schema 4 (rules 7, ADR-0137): schema 2's table and units; a mutation step is a tenth of
|
||||
// the current value (at least 1), and an acquired capability starts at the founder's value.
|
||||
inline constexpr std::uint32_t genome_schema_v4 = 4;
|
||||
// Schema 5 (rules 11, ADR-0175): schema 4's steps with the photosynthesis capability.
|
||||
inline constexpr std::uint32_t genome_schema_v5 = 5;
|
||||
// The newest schema. Older records stay valid and are never rewritten (ADR-0099).
|
||||
inline constexpr std::uint32_t genome_schema_version = genome_schema_v4;
|
||||
// The capability table of a supported schema (1 to 4); nullptr otherwise.
|
||||
inline constexpr std::uint32_t genome_schema_version = genome_schema_v5;
|
||||
// The capability table of a supported schema (1 to 5); nullptr otherwise.
|
||||
[[nodiscard]] constexpr const std::array<CapabilitySpec, capability_count>*
|
||||
capability_schema_for(std::uint32_t schema) noexcept {
|
||||
return schema == genome_schema_v1 ? &capability_schema_v1
|
||||
: schema == genome_schema_v2 || schema == genome_schema_v3 || schema == genome_schema_v4
|
||||
? &capability_schema_v2
|
||||
: nullptr;
|
||||
: schema == genome_schema_v5 ? &capability_schema_v5
|
||||
: nullptr;
|
||||
}
|
||||
inline constexpr std::size_t max_parents = 2;
|
||||
inline constexpr std::size_t max_genome_bytes = 256;
|
||||
|
||||
@@ -68,6 +68,8 @@ enum class MutationError : std::uint8_t {
|
||||
development
|
||||
};
|
||||
inline constexpr std::size_t max_candidates = 8;
|
||||
// ADR-0175 trial value: an acquired photosynthesis starts at 10 % efficiency.
|
||||
inline constexpr std::uint32_t photosynthesis_acquired_start = 100;
|
||||
|
||||
[[nodiscard]] std::span<const MutationOperator> mutation_catalog() noexcept;
|
||||
// Identical inputs always yield identical candidates, sorted by operator ID.
|
||||
|
||||
@@ -69,7 +69,7 @@ struct CellularEnvironmentConfig {
|
||||
};
|
||||
struct CellularEnvironmentTickReport {
|
||||
std::uint64_t tick{};
|
||||
accounting::Inventory imported{};
|
||||
accounting::Inventory imported{}; // Infall only; a rules-11 owner books its own light.
|
||||
accounting::Picojoules exported{};
|
||||
std::uint64_t events{}, credited_bubbles{}, skipped_bubbles{};
|
||||
CellularTickExecution biology;
|
||||
@@ -114,7 +114,7 @@ class CellularEnvironment {
|
||||
[[nodiscard]] std::span<const CellularInfallSource> sources() const noexcept;
|
||||
[[nodiscard]] std::span<const CellularInfallProgress> infall() const noexcept;
|
||||
[[nodiscard]] accounting::Picojoules radiation_cap() const noexcept;
|
||||
[[nodiscard]] accounting::Inventory imported() const noexcept; // All sources, cumulative.
|
||||
[[nodiscard]] accounting::Inventory imported() const noexcept; // Infall, cumulative.
|
||||
[[nodiscard]] accounting::Picojoules exported() const noexcept;
|
||||
[[nodiscard]] std::uint64_t tick() const noexcept;
|
||||
|
||||
@@ -139,6 +139,13 @@ class CellularEnvironment {
|
||||
friend std::expected<std::unique_ptr<CellularEnvironment>, CellularEnvironmentError>
|
||||
execute_environment_batch(const CellularEnvironment&, CellularEnvironmentBatch&, bool record);
|
||||
struct Exchange;
|
||||
struct Step {
|
||||
CellularEnvironmentTickReport report;
|
||||
};
|
||||
enum class StepMode : std::uint8_t { live, record, replay };
|
||||
[[nodiscard]] std::expected<Step, CellularEnvironmentError>
|
||||
joint_step(std::vector<CellularLifeIntent>& intents,
|
||||
std::span<const CellularMutationSelection> selections, StepMode mode);
|
||||
CellularEnvironment(std::unique_ptr<CellularPopulation> population,
|
||||
CellularEnvironmentConfig config);
|
||||
[[nodiscard]] std::expected<Exchange, CellularEnvironmentError>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "evo/accounting/ledger.hpp"
|
||||
#include "evo/biology/genome.hpp"
|
||||
|
||||
#include <compare>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
||||
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<std::uint64_t> cellular_light_capture(const biology::Genome& genome,
|
||||
std::uint32_t extent_um,
|
||||
const CellularLight& light,
|
||||
bool moving) noexcept;
|
||||
} // namespace evo::server
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "evo/biology/cellular_region_step.hpp"
|
||||
#include "evo/biology/mutation.hpp"
|
||||
#include "evo/server/lifecycle/cellular_light.hpp"
|
||||
#include "evo/server/lifecycle/primitive_lives.hpp"
|
||||
|
||||
#include <compare>
|
||||
@@ -50,13 +51,23 @@ inline constexpr std::uint32_t cellular_lives_maturation_rules = 9;
|
||||
// ADR-0165: explicit offspring-plan editing mode; expressed bodies retain their genomes.
|
||||
inline constexpr std::uint32_t cellular_lives_inheritance_format = 8;
|
||||
inline constexpr std::uint32_t cellular_lives_inheritance_rules = 10;
|
||||
// ADR-0175: rules 10 with founder 4 (genome schema 5), which can evolve photosynthesis.
|
||||
// Format 9 is format 8 with the region's declared light and cumulative capture.
|
||||
inline constexpr std::uint32_t cellular_lives_light_format = 9;
|
||||
inline constexpr std::uint32_t cellular_lives_photosynthesis_rules = 11;
|
||||
// Rules that retain offspring plans (formats 8 and 9): 10 and 11.
|
||||
[[nodiscard]] constexpr bool cellular_retained_plans(std::uint32_t rules) noexcept {
|
||||
return rules == cellular_lives_inheritance_rules ||
|
||||
rules == cellular_lives_photosynthesis_rules;
|
||||
}
|
||||
inline constexpr std::uint32_t cellular_growth_per_tick = 5; // Per 50 ms; trial rate.
|
||||
// The founder a region of these rules creates.
|
||||
[[nodiscard]] constexpr biology::FounderVersion
|
||||
cellular_founder_version(std::uint32_t rules) noexcept {
|
||||
return rules >= cellular_lives_reproduction_rules ? biology::primitive_founder_v3
|
||||
: rules >= cellular_lives_balance_rules ? biology::primitive_founder_v2
|
||||
: biology::primitive_founder_v1;
|
||||
return rules >= cellular_lives_photosynthesis_rules ? biology::primitive_founder_v4
|
||||
: rules >= cellular_lives_reproduction_rules ? biology::primitive_founder_v3
|
||||
: rules >= cellular_lives_balance_rules ? biology::primitive_founder_v2
|
||||
: biology::primitive_founder_v1;
|
||||
}
|
||||
// ADR-0137: a bud action also yields a twin with probability reproduction / 2 per thousand
|
||||
// (founders: 25 %), when the reserve funds it and there is room. Seeded per parent and tick.
|
||||
@@ -283,6 +294,14 @@ class CellularLives {
|
||||
// ADR-0165: explicit no-tick format-7/rules-9 -> format-8/rules-10 upgrade.
|
||||
[[nodiscard]] std::expected<std::unique_ptr<CellularLives>, CellularLivesError>
|
||||
inheritance_upgrade_candidate() const;
|
||||
// ADR-0175: explicit no-tick format-8/rules-10 -> format-9/rules-11 upgrade declaring
|
||||
// the region's light. Existing lineages keep their genome schemas; only founders born
|
||||
// afterwards can evolve photosynthesis.
|
||||
[[nodiscard]] std::expected<std::unique_ptr<CellularLives>, CellularLivesError>
|
||||
photosynthesis_upgrade_candidate(CellularLight light) const;
|
||||
// Format 9: declared light and the energy captured from it, cumulatively.
|
||||
[[nodiscard]] const CellularLight& light() const noexcept;
|
||||
[[nodiscard]] accounting::Picojoules captured_light() const noexcept;
|
||||
[[nodiscard]] std::span<const CellularOffspringRevision> offspring_revisions() const noexcept;
|
||||
// Latest successful in-memory step report; omitted from snapshots and empty after restore.
|
||||
[[nodiscard]] std::span<const CellularLifeTickFeedback> last_tick_feedback() const noexcept;
|
||||
|
||||
@@ -23,7 +23,9 @@ inline constexpr std::int16_t wildlife_full_speed = 1'000;
|
||||
|
||||
// One intention per wildlife life (zero account), sorted by life id: bud when the reserve
|
||||
// funds one, else steer to and feed from the nearest perceived patch holding energy,
|
||||
// else wander. Owned lives are left to their players.
|
||||
// else wander. Owned lives are left to their players. ADR-0175: under rules 11 with
|
||||
// the region's declared light, a photosynthetic cell that would capture at least its
|
||||
// maintenance by holding still stays still (it still feeds from whatever it touches).
|
||||
[[nodiscard]] std::expected<std::vector<CellularLifeIntent>, CellularLivesError>
|
||||
wildlife_intents(const CellularLives& state, std::uint64_t tick);
|
||||
} // namespace evo::server
|
||||
|
||||
Reference in New Issue
Block a user