Foundation / checks (client) (push) Successful in 4s
Foundation / checks (checks) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 3s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m30s
Foundation / postgres-tools (push) Successful in 22s
Foundation / server-image (push) Successful in 4m12s
Foundation / image (push) Successful in 4m40s
Phase 1 of the cellular revamp build plan (ADR-0179). The cellular owner gains rules 13 on owner format 11: an explicit no-tick format-10/rules-12 upgrade declares the region's revamp rules (so far the body's essential upkeep share), existing lives keep their genomes, and founders born afterwards are founder 6 (genome schema 7, development 7). Format 11 is format 10 plus the revamp rules block; it stays undeployed while later phases extend it. The tick, perception and wildlife controller derive budgets with the declared body tuning, which earlier development versions ignore. Revamp tunables live in their own Git file, deploy/kubernetes/region/dev/tuning/cellular-revamp.tuning, parsed by parse_cellular_revamp_tuning with the same format and refusals as the rules-12 file, so images from before rules 13 never meet keys they do not know. Both parsers now share read_tuning_lines; the rules-12 file's behaviour is unchanged. The revamp file is not yet mounted into the region (build plan, phase 6). Tests cover the upgrade and its refusals, mixed founder 5 and founder 6 lives ticking with closure, exact restore and continuation, trace replay, and the new tuning file including the checked-in DEV copy. Refreshes the DEV session window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
113 lines
5.6 KiB
C++
113 lines
5.6 KiB
C++
#pragma once
|
|
|
|
#include "evo/biology/cellular_kinematics.hpp"
|
|
#include "evo/biology/metabolism.hpp"
|
|
|
|
#include <compare>
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <expected>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
// Git-managed trial values (Cellular_Region_Movement_Plan.md, tuning file). The file is
|
|
// plain `key = value` lines with `#` comments and integer values; `_` may separate digits.
|
|
// Every key below is required exactly once and range-checked, so a typo fails loudly
|
|
// instead of running with a default.
|
|
namespace evo::biology {
|
|
inline constexpr std::int64_t cellular_tuning_version = 1;
|
|
inline constexpr std::size_t max_cellular_tuning_bytes = std::size_t{64} * 1'024;
|
|
|
|
struct CellularTuning {
|
|
std::int64_t version{};
|
|
// Region shape and capacity; shape applies when a region opens.
|
|
std::int64_t region_width_um{}, region_height_um{};
|
|
std::int64_t region_organism_cap{}, region_deposit_limit{}, region_perception_radius_um{};
|
|
// Founder handling.
|
|
std::int64_t founder_thrust_um_per_s2{}, founder_reverse_thrust_um_per_s2{};
|
|
std::int64_t founder_drag_ppm_per_tick{}, founder_lateral_drag_ppm_per_tick{};
|
|
std::int64_t founder_turn_heading_per_s{}; // 65,536 heading units per turn.
|
|
// Thrust energy as a share of the metabolic full-speed movement cost, per thousand.
|
|
std::int64_t founder_thrust_cost_per_mille{};
|
|
// Currents.
|
|
std::int64_t currents_min_count{}, currents_max_count{};
|
|
std::int64_t currents_min_width_um{}, currents_max_width_um{};
|
|
std::int64_t currents_min_speed_um_per_s{}, currents_max_speed_um_per_s{};
|
|
std::int64_t currents_grid_pitch_um{};
|
|
// Moving food.
|
|
std::int64_t food_merged_bubble_cap_multiple{}, food_visible_moving_bubbles{};
|
|
std::int64_t food_induced_drift_radius_um{}, food_induced_drift_max_um_per_s{};
|
|
std::int64_t food_induced_drift_decay_ppm_per_tick{};
|
|
// Thermal map and biology (temperatures in millikelvin).
|
|
std::int64_t thermal_ambient_min_mk{}, thermal_ambient_max_mk{};
|
|
std::int64_t founder_preferred_mk{}, founder_comfort_band_mk{}, founder_body_tau_ms{};
|
|
std::int64_t founder_lethal_cold_mk{}, founder_lethal_heat_mk{};
|
|
std::int64_t thermal_off_preference_per_mille_per_k{}, thermal_transition_per_mille_per_k{};
|
|
std::int64_t thermal_multiplier_cap_per_mille{};
|
|
// Lifecycle.
|
|
std::int64_t lifecycle_logout_delay_ms{};
|
|
// Mutation offers.
|
|
std::int64_t mutation_step_points{}, mutation_paired_points{};
|
|
std::int64_t mutation_recovery_floor_per_mille{};
|
|
std::int64_t mutation_offer_interval_ms{}, mutation_offer_options{};
|
|
auto operator<=>(const CellularTuning&) const = default;
|
|
};
|
|
|
|
enum class CellularTuningErrorKind : std::uint8_t {
|
|
too_large,
|
|
syntax,
|
|
unknown_key,
|
|
duplicate_key,
|
|
invalid_value,
|
|
out_of_range,
|
|
missing_key,
|
|
inconsistent,
|
|
unsupported_version
|
|
};
|
|
struct CellularTuningError {
|
|
CellularTuningErrorKind kind{};
|
|
std::size_t line{}; // 1-based; zero when not tied to a line.
|
|
std::string key;
|
|
auto operator<=>(const CellularTuningError&) const = default;
|
|
};
|
|
|
|
[[nodiscard]] std::expected<CellularTuning, CellularTuningError>
|
|
parse_cellular_tuning(std::string_view text);
|
|
// The shared line reader for Git tuning files: comments and blank lines dropped, each other
|
|
// line split into a valid key and its unparsed value text. Views point into `text`.
|
|
struct TuningLine {
|
|
std::size_t line{}; // 1-based.
|
|
std::string_view key, value;
|
|
};
|
|
[[nodiscard]] std::expected<std::vector<TuningLine>, CellularTuningError>
|
|
read_tuning_lines(std::string_view text, std::size_t max_bytes);
|
|
// Optional '-', then digits with single '_' separators between digits; at most 18 digits.
|
|
[[nodiscard]] std::optional<std::int64_t> parse_tuning_integer(std::string_view text) noexcept;
|
|
// Canonical text: every key once, in schema order, so equal tunings encode identically.
|
|
[[nodiscard]] std::string encode_cellular_tuning(const CellularTuning& tuning);
|
|
[[nodiscard]] std::string_view describe(CellularTuningErrorKind kind) noexcept;
|
|
|
|
// Founder handling per 50 ms tick, rounded down; costs are supplied by the metabolic budget.
|
|
[[nodiscard]] CellularHandling founder_cellular_handling(const CellularTuning& tuning,
|
|
accounting::Picojoules thrust_cost,
|
|
accounting::Picojoules reverse_cost);
|
|
|
|
enum class CellularHandlingError : std::uint8_t { unsupported_rate, overflow };
|
|
// Development 6: an organism's handling from its movement arrangement, scaled from the
|
|
// founder's tuned handling (index 100 = founder). Output scales thrust, braking scales
|
|
// reverse thrust, steering scales turning; streamlining lowers forward drag only and
|
|
// coasting lowers both, so a coasting body also tops out faster. Full-output costs per tick
|
|
// are the budget's full-speed movement cost times output (or braking) over efficiency.
|
|
// Without the movement capability or with shed output, the body cannot thrust or turn.
|
|
// A genome from before schema 6 has no arrangement and handles as the founder does.
|
|
[[nodiscard]] std::expected<CellularHandling, CellularHandlingError>
|
|
derive_cellular_handling(const Genome& genome, const MetabolicBudget& budget,
|
|
const CellularTuning& tuning);
|
|
// The same from the founder's per-tick handling directly; its costs are ignored.
|
|
[[nodiscard]] std::expected<CellularHandling, CellularHandlingError>
|
|
derive_cellular_handling(const Genome& genome, const MetabolicBudget& budget,
|
|
const CellularHandling& founder);
|
|
} // namespace evo::biology
|