#pragma once #include "evo/biology/cellular_currents.hpp" #include "evo/biology/cellular_habitat.hpp" #include #include #include #include // Moving food (Cellular_Region_Movement_Plan.md, moving food; rules 12). After each tick's // lives have fed against the deposits where they were, every bubble moves with the local flow // plus the drift that passing cells induced, bubbles that touch merge (stock is summed, never // created), and addresses are made unique again. Pools stay where they were placed. namespace evo::biology { // A living cell's world velocity this tick, for the drift it induces on nearby bubbles. struct CellularWake { CellularPosition position; std::uint32_t extent_um{}; std::int32_t velocity_x_q10{}, velocity_y_q10{}; auto operator<=>(const CellularWake&) const = default; }; struct CellularDepositMotionRules { std::uint32_t drift_radius_um{}; // Cells push bubbles closer than this. std::int32_t max_drift_q10{}; // Largest induced drift speed. std::uint32_t drift_decay_ppm{}; // Induced drift lost per tick. std::uint16_t merged_cap{}; // Bubbles stop merging at this many scattered ones. std::uint32_t bubble_radius_um{}; // Radius of one unmerged bubble. auto operator<=>(const CellularDepositMotionRules&) const = default; }; struct CellularDepositMotionReport { std::uint32_t moved{}, merges{}, nudged{}; auto operator<=>(const CellularDepositMotionReport&) const = default; }; struct CellularDepositMotion { CellularHabitatConfig config; CellularDepositMotionReport report; }; // Radius of a bubble holding `merged` scattered bubbles: area grows with the count. [[nodiscard]] std::uint32_t cellular_merged_radius(std::uint32_t bubble_radius_um, std::uint16_t merged) noexcept; // Detached: returns the next format-3 configuration, or an error when the input is not a // format-3 habitat matching the field's area. `wakes` must be ordered by stable life id. [[nodiscard]] std::expected advect_cellular_deposits(const CellularHabitatConfig& config, const CellularFlowField& field, std::span wakes, const CellularDepositMotionRules& rules); } // namespace evo::biology