From e2da92768c5b4cd8277d4b02589f93317d73b9e9 Mon Sep 17 00:00:00 2001 From: dingo Date: Mon, 26 Oct 2026 08:28:57 -0400 Subject: [PATCH] feat(cellular): show growth and gate splits; DEV splits at half growth Playtest: after one mutation every later choice came back "split refused" because a split needs a grown cell, and the client gave no reason. The v14 body block now carries the body's growth per thousand (the reserved bytes) and a split-ready flag; the client disables Stay / Become until the cell can split ("Grow to split (now 62%)") and shows growth in the Body panel. Adhesion and organism choices do not split and stay open. The DEV revamp tuning splits once half grown (split_min_growth 500, was full growth); it takes effect in the next region opened. Co-Authored-By: Claude Opus 5.5 --- apps/evo-client/panels.cpp | 11 +++++-- apps/evo-server/cellular_bridge.hpp | 5 ++++ .../region/dev-session-route/listener.yaml | 2 +- .../region/dev/tuning/cellular-revamp.tuning | 2 +- include/evo/network/session_protocol.hpp | 3 ++ .../network/session-v14-cellular-revamp.md | 4 +-- src/network/protocol/session_protocol.cpp | 29 ++++++++++++------- src/server/session/region_sessions.cpp | 3 +- tests/cellular_intent_protocol_tests.cpp | 7 +++-- tests/cellular_revamp_tuning_tests.cpp | 2 +- 10 files changed, 47 insertions(+), 21 deletions(-) diff --git a/apps/evo-client/panels.cpp b/apps/evo-client/panels.cpp index 2af89fd..c764654 100644 --- a/apps/evo-client/panels.cpp +++ b/apps/evo-client/panels.cpp @@ -1426,7 +1426,8 @@ void hud_notes(const PanelView& v, FormBuffers& form, PanelActions& a, bool comp } if (ImGui::CollapsingHeader("Body")) { const auto& t = d->traits; - ImGui::Text("Mass %s", mass_text(d->total_mass_fg).c_str()); + ImGui::Text("Mass %s Grown %u%%", mass_text(d->total_mass_fg).c_str(), + static_cast(d->growth_per_thousand / 10)); ImGui::TextDisabled("Density %u Upkeep efficiency %u Growth %u", unsigned{t[0]}, unsigned{t[1]}, unsigned{t[2]}); ImGui::TextDisabled("Engulf capacity %u Kill absorption %u", unsigned{t[12]}, @@ -1585,6 +1586,9 @@ void named_offer_card(const PanelView& v, const network::CellularMutationOffer& ImGui::EndTable(); const bool organism = d && d->members > 1; const bool adhesion = spec.effect == biology::CellularEffect::acquire_adhesion; + // A choice that splits the cell waits until it has grown enough (the offer waits too). + const bool splits = !organism && !adhesion; + const bool grown = !splits || (d && d->split_ready); if (adhesion) disabled_wrapped("Your cell and its split-off offspring stay joined: one organism with " "one genome and one reserve, growing toward Emerge."); @@ -1593,9 +1597,12 @@ void named_offer_card(const PanelView& v, const network::CellularMutationOffer& else disabled_wrapped("Your cell splits: both keep the change in their plan; only the " "offspring expresses it."); + if (!grown) + ImGui::TextColored(amber, "Grow to split (now %u%%). Feed; the offer waits.", + d ? static_cast(d->growth_per_thousand / 10) : 0U); const bool ready = play && play->can_act() && v.remote && v.remote->server_tick > offer.offer_tick; - ImGui::BeginDisabled(!affordable || !ready); + ImGui::BeginDisabled(!affordable || !ready || !grown); const MutationChoice stay{offer.life_identity, offer.event_index, offer.offer_tick, c.operator_id, false}; if (organism || adhesion) { diff --git a/apps/evo-server/cellular_bridge.hpp b/apps/evo-server/cellular_bridge.hpp index e86840b..ee83a72 100644 --- a/apps/evo-server/cellular_bridge.hpp +++ b/apps/evo-server/cellular_bridge.hpp @@ -286,6 +286,8 @@ class CellularBridge { } // Rules 13 (v14): the body block. Older sessions never see it. diagnostics.members = life.revamp.members; + diagnostics.growth_per_thousand = static_cast( + std::min(life.growth.realized_per_thousand, 1000)); if (const auto genome = state.archive().find(life.identity.genome)) { const auto& traits = genome->cellular_traits(); const auto t = traits.value_or(biology::CellularTraits{}); @@ -302,6 +304,9 @@ class CellularBridge { diagnostics.emerge_members = static_cast( std::min(rules.emerge_members, 0xFFFF)); diagnostics.can_emerge = server::cellular_can_emerge(life, rules); + diagnostics.split_ready = + life.revamp.members == 1 && + life.growth.realized_per_thousand >= rules.split_min_growth; if (feedback != state.last_tick_feedback().end() && feedback->life_id == life.identity.life && feedback->tick == tick) diagnostics.exclude = feedback->exclude; diff --git a/deploy/kubernetes/region/dev-session-route/listener.yaml b/deploy/kubernetes/region/dev-session-route/listener.yaml index 66f09ee..c6e3c4d 100644 --- a/deploy/kubernetes/region/dev-session-route/listener.yaml +++ b/deploy/kubernetes/region/dev-session-route/listener.yaml @@ -12,7 +12,7 @@ spec: env: - {name: REGION_SESSION, value: "dev"} - {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"} - - {name: REGION_SESSION_WINDOW, value: "dev-20261026T120359-8e97f3ea:1793030639"} + - {name: REGION_SESSION_WINDOW, value: "dev-20261026T122846-560e1ebf:1793032126"} - {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"} ports: # QUIC (ADR-0090): UDP only; nothing listens on TCP 7400. diff --git a/deploy/kubernetes/region/dev/tuning/cellular-revamp.tuning b/deploy/kubernetes/region/dev/tuning/cellular-revamp.tuning index 4db2dfc..a71f5ba 100644 --- a/deploy/kubernetes/region/dev/tuning/cellular-revamp.tuning +++ b/deploy/kubernetes/region/dev/tuning/cellular-revamp.tuning @@ -49,7 +49,7 @@ mutation.buds_for_adhesion = 5 # on-demand buds before Adhesion is offe # Reproduction (reproduction plan). reproduction.split_share_per_mille = 500 # the offspring's share of a mutation split -reproduction.split_min_growth_per_mille = 1_000 # a cell splits only fully grown +reproduction.split_min_growth_per_mille = 500 # a cell splits once half grown reproduction.bud_fee_e_pj = 0 # on-demand bud fee per channel, times the scale; reclaimed reproduction.bud_fee_c_fg = 0 reproduction.bud_fee_n_fg = 0 diff --git a/include/evo/network/session_protocol.hpp b/include/evo/network/session_protocol.hpp index 7b92fc4..9daf1e9 100644 --- a/include/evo/network/session_protocol.hpp +++ b/include/evo/network/session_protocol.hpp @@ -387,6 +387,9 @@ struct CellularLifeDiagnostics { std::uint16_t members{}, emerge_members{}; std::uint8_t exclude{}; bool can_emerge{}; + // How grown the body is (per thousand), and whether a mutation choice can split it now. + std::uint16_t growth_per_thousand{}; + bool split_ready{}; std::uint64_t payable_energy_pj{}, total_mass_fg{}; std::array traits{}; friend bool operator==(const CellularLifeDiagnostics&, diff --git a/schemas/network/session-v14-cellular-revamp.md b/schemas/network/session-v14-cellular-revamp.md index 85fc30e..59b2c9f 100644 --- a/schemas/network/session-v14-cellular-revamp.md +++ b/schemas/network/session-v14-cellular-revamp.md @@ -11,8 +11,8 @@ v13's. Older versions keep their exact layouts and never see a v14 field. | 2 | Members: cells in the organism (1 for a single cell; at least 1 with a life) | | 2 | Emergence threshold in members (0 below rules 13) | | 1 | Matter channels kept from burning this tick (bits 0-3: C, N, P, other) | -| 1 | Flags: bit 0 Emerge is open; other bits zero | -| 2 | Reserved zero | +| 1 | Flags: bit 0 Emerge is open; bit 1 a mutation choice can split the cell now (single cell, grown to the region's split threshold); other bits zero | +| 2 | Growth per thousand of full size (0-1,000) | | 8 | Payable energy (pJ): the reserve's energy plus what its burnable matter stands in for | | 8 | Total mass (fg): body and reserve matter | | 2 each | The 20 heritable body traits in `biology::CellularTraits` order: density, upkeep efficiency, growth speed, collection (E, C, N, P, O), burn (C, N, P, O), engulf capacity, kill absorption, litter, recipe (C, N, P, O), adhesion | diff --git a/src/network/protocol/session_protocol.cpp b/src/network/protocol/session_protocol.cpp index 6638269..8a86e20 100644 --- a/src/network/protocol/session_protocol.cpp +++ b/src/network/protocol/session_protocol.cpp @@ -38,8 +38,8 @@ constexpr std::size_t cellular_liquid_block_bytes = 4 + 4 + 2 + 1 + 1 + 8 + (9 * constexpr std::size_t cellular_perception_v13_prefix_bytes = cellular_perception_v12_prefix_bytes + cellular_liquid_block_bytes; // v14 (rules 13) appends the body block: members and threshold (2 x u16), exclusions, flags -// (bit 0 Emerge open), two reserved bytes, payable energy and total mass (2 x u64) and twenty -// u16 traits. +// (bit 0 Emerge open, bit 1 a choice can split now), growth per thousand (u16), payable energy +// and total mass (2 x u64) and twenty u16 traits. constexpr std::size_t cellular_revamp_block_bytes = 2 + 2 + 1 + 1 + 2 + 8 + 8 + (20 * 2); constexpr std::size_t cellular_perception_v14_prefix_bytes = cellular_perception_v13_prefix_bytes + cellular_revamp_block_bytes; @@ -265,10 +265,12 @@ std::vector encode_session(const SessionMessage& message, std::uin const auto& body = perception->diagnostics; if (version != session_protocol_v14 && body && (body->members || body->emerge_members || body->exclude || body->can_emerge || - body->payable_energy_pj || body->total_mass_fg || + body->growth_per_thousand || body->split_ready || body->payable_energy_pj || + body->total_mass_fg || std::ranges::any_of(body->traits, [](std::uint16_t value) { return value != 0; }))) return {}; - if (version == session_protocol_v14 && body && (body->members == 0 || body->exclude > 0x0F)) + if (version == session_protocol_v14 && body && + (body->members == 0 || body->exclude > 0x0F || body->growth_per_thousand > 1000)) return {}; if (!liquid && (perception->currents || (perception->diagnostics && (perception->diagnostics->velocity_x_q10 || @@ -501,8 +503,9 @@ std::vector encode_session(const SessionMessage& message, std::uin put(out, b.members, 2); put(out, b.emerge_members, 2); out.push_back(b.exclude); - out.push_back(b.can_emerge ? 1 : 0); - put(out, 0, 2); + out.push_back(static_cast((b.can_emerge ? 1U : 0U) | + (b.split_ready ? 2U : 0U))); + put(out, b.growth_per_thousand, 2); put(out, b.payable_energy_pj, 8); put(out, b.total_mass_fg, 8); for (const auto value : b.traits) @@ -1003,17 +1006,19 @@ std::expected decode_session(std::span(get(payload, at, 2)); b.emerge_members = static_cast(get(payload, at + 2, 2)); b.exclude = payload[at + 4]; - b.can_emerge = payload[at + 5] == 1; + b.can_emerge = (payload[at + 5] & 1U) != 0; + b.split_ready = (payload[at + 5] & 2U) != 0; + b.growth_per_thousand = static_cast(get(payload, at + 6, 2)); b.payable_energy_pj = get(payload, at + 8, 8); b.total_mass_fg = get(payload, at + 16, 8); for (std::size_t i = 0; i < b.traits.size(); ++i) b.traits.at(i) = static_cast(get(payload, at + 24 + i * 2, 2)); const bool empty = b.members == 0 && b.emerge_members == 0 && b.exclude == 0 && - payload[at + 5] == 0 && b.payable_energy_pj == 0 && - b.total_mass_fg == 0 && + payload[at + 5] == 0 && b.growth_per_thousand == 0 && + b.payable_energy_pj == 0 && b.total_mass_fg == 0 && std::ranges::all_of(b.traits, [](auto v) { return v == 0; }); - if (b.exclude > 0x0F || payload[at + 5] > 1 || payload[at + 6] != 0 || - payload[at + 7] != 0 || (m.diagnostics ? b.members == 0 : !empty)) + if (b.exclude > 0x0F || payload[at + 5] > 3 || b.growth_per_thousand > 1000 || + (m.diagnostics ? b.members == 0 : !empty)) return std::unexpected(SessionCodecError::invalid_value); if (m.diagnostics) { auto& d = *m.diagnostics; @@ -1021,6 +1026,8 @@ std::expected decode_session(std::span