Resolve cellular engulfment and detritus in the region step
Foundation / checks (ecs) (push) Successful in 2m17s
Foundation / checks (deploy) (push) Successful in 3m57s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 6m13s
Foundation / checks (checks) (push) Canceled after 6m19s
Foundation / checks (tsan) (push) Canceled after 3m58s
Foundation / checks (client) (push) Canceled after 6m17s
Foundation / checks (network) (push) Canceled after 6m18s
Foundation / checks (ecs) (push) Successful in 2m17s
Foundation / checks (deploy) (push) Successful in 3m57s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 6m13s
Foundation / checks (checks) (push) Canceled after 6m19s
Foundation / checks (tsan) (push) Canceled after 3m58s
Foundation / checks (client) (push) Canceled after 6m17s
Foundation / checks (network) (push) Canceled after 6m18s
ADR-0124 implements ADR-0098's predation and corpse rules for the cellular trial. Under rules 3 the pure region step adds an engulf phase after every life's step: in ascending life id, a predator takes the lowest-id contacted survivor whose total mass, times 1.5 per micrometre of its membrane, is at most the predator's. The prey's whole inventory moves once; the predator keeps what its remaining per-tick intake allows and the rest, like every starvation corpse, becomes detritus in the patch at the dead cell's 1 mm cell. Corpse candidates report their cause. Rules 2 is unchanged and ignores engulf intents. Owner, protocol v11, persistence and recovery wiring follow in the next 11.3f steps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,18 @@
|
||||
namespace evo::biology {
|
||||
inline constexpr std::size_t max_cellular_tick_lives = 256;
|
||||
|
||||
// ADR-0124 (rules 3): a predator needs total mass >= ratio x prey total mass, with the
|
||||
// ratio in thousandths per micrometre of prey membrane (tunable; 1.5 for 1 um).
|
||||
inline constexpr std::uint64_t cellular_engulf_ratio_milli_per_membrane_um = 1'500;
|
||||
|
||||
struct CellularRegionRules {
|
||||
// Rules 3: engulfment, and every corpse's inventory deposited as patch detritus.
|
||||
// Rules 2 (false) is the original trial: engulf intents are ignored and starvation
|
||||
// corpses keep their inventory.
|
||||
bool engulf_and_detritus{};
|
||||
auto operator<=>(const CellularRegionRules&) const = default;
|
||||
};
|
||||
|
||||
struct CellularLifeStepInput {
|
||||
std::uint64_t life_id{}; // Stable world identity; arbitrates same-tick patch contention.
|
||||
CellularPosition position;
|
||||
@@ -21,11 +33,21 @@ struct CellularLifeStepInput {
|
||||
accounting::Inventory reserve;
|
||||
accounting::Inventory heat; // Energy-only owner; matter channels must be zero.
|
||||
MetabolicBudget budget;
|
||||
std::uint32_t membrane_um{}; // Genome membrane thickness; contests engulfment (rules 3).
|
||||
std::uint64_t source{}; // Provenance for a detritus patch this life creates (rules 3).
|
||||
auto operator<=>(const CellularLifeStepInput&) const = default;
|
||||
};
|
||||
enum class CellularEngulfStatus : std::uint8_t {
|
||||
not_requested,
|
||||
engulfed, // Took the reported prey.
|
||||
no_eligible_prey, // Nothing in contact was small enough.
|
||||
unsupported // Rules 2 region: the intent had no effect.
|
||||
};
|
||||
struct CellularLifeStepResult {
|
||||
std::uint64_t life_id{};
|
||||
CellularStepCandidate candidate;
|
||||
CellularEngulfStatus engulf{CellularEngulfStatus::not_requested};
|
||||
std::uint64_t prey_id{};
|
||||
auto operator<=>(const CellularLifeStepResult&) const = default;
|
||||
};
|
||||
struct CellularPatchStockUpdate {
|
||||
@@ -33,10 +55,15 @@ struct CellularPatchStockUpdate {
|
||||
accounting::Inventory stock;
|
||||
auto operator<=>(const CellularPatchStockUpdate&) const = default;
|
||||
};
|
||||
enum class CellularDeathCause : std::uint8_t { starved = 1, engulfed = 2 };
|
||||
struct CellularCorpseCandidate {
|
||||
std::uint64_t life_id{};
|
||||
CellularPosition position;
|
||||
accounting::Inventory inventory; // Body and reserve; accumulated heat is transferred out.
|
||||
// Rules 2: body and reserve. Rules 3: empty, because the inventory moved to the
|
||||
// predator and detritus. Accumulated heat is transferred out in both.
|
||||
accounting::Inventory inventory;
|
||||
CellularDeathCause cause{CellularDeathCause::starved};
|
||||
std::uint64_t predator_id{}; // Engulfed only.
|
||||
auto operator<=>(const CellularCorpseCandidate&) const = default;
|
||||
};
|
||||
struct CellularRegionStepCandidate {
|
||||
@@ -44,7 +71,10 @@ struct CellularRegionStepCandidate {
|
||||
// Sorted by stable life_id, independent of connection or input order.
|
||||
std::vector<CellularLifeStepResult> lives;
|
||||
std::vector<CellularPatchStockUpdate> patches;
|
||||
// Dead this tick (starved or engulfed), sorted by life_id.
|
||||
std::vector<CellularCorpseCandidate> starved;
|
||||
// Rules 3 detritus patches created at empty cells, sorted by address.
|
||||
std::vector<CellularPatch> new_patches;
|
||||
accounting::Picojoules heat_released{};
|
||||
auto operator<=>(const CellularRegionStepCandidate&) const = default;
|
||||
};
|
||||
@@ -57,7 +87,8 @@ enum class CellularRegionStepError : std::uint8_t {
|
||||
invalid_heat,
|
||||
overflow,
|
||||
life_step,
|
||||
habitat
|
||||
habitat,
|
||||
invalid_intent
|
||||
};
|
||||
|
||||
// Detached shared-habitat candidate. Same-tick claims resolve by ascending stable life id;
|
||||
@@ -65,8 +96,10 @@ enum class CellularRegionStepError : std::uint8_t {
|
||||
// life step rejects the complete candidate; the caller publishes nothing. If maintenance
|
||||
// cannot be paid, the life dies in this tick: body and reserve move to one corpse candidate,
|
||||
// and its accumulated heat is reported separately for transfer to the world heat owner.
|
||||
// Under rules 3 (ADR-0124) an engulf phase follows, and every dead life's inventory is
|
||||
// deposited into the patch at its cell (a new patch when the cell is empty).
|
||||
[[nodiscard]] std::expected<CellularRegionStepCandidate, CellularRegionStepError>
|
||||
propose_cellular_region_step(std::uint64_t begin_tick, CellularArea area,
|
||||
std::span<const CellularLifeStepInput> lives,
|
||||
const CellularHabitat& habitat);
|
||||
const CellularHabitat& habitat, CellularRegionRules rules = {});
|
||||
} // namespace evo::biology
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace evo::biology {
|
||||
struct CellularStepIntent {
|
||||
CellularIntent movement{};
|
||||
std::optional<CellularPatchAddress> intake_target;
|
||||
// ADR-0124: take one smaller contacted cell after every life's step (rules 3 only).
|
||||
// Exclusive with an intake target; the server chooses the prey.
|
||||
bool engulf{};
|
||||
auto operator<=>(const CellularStepIntent&) const = default;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user