From 68958a9e54bc004c0214b6e005cc02658b1189eb Mon Sep 17 00:00:00 2001 From: dingo Date: Wed, 14 Oct 2026 19:53:28 -0400 Subject: [PATCH] Upgrade cellular client to v10 with readable play and assisted steering --- apps/evo-client/cellular_controls.hpp | 79 ++++ apps/evo-client/cellular_play.hpp | 281 ++++++++++++++ apps/evo-client/cellular_scene.hpp | 47 +++ apps/evo-client/controls_flow.hpp | 2 + apps/evo-client/main.cpp | 91 ++--- apps/evo-client/panels.cpp | 343 +++++++++++++++++- apps/evo-client/panels.hpp | 6 + apps/evo-client/remote_session.hpp | 158 ++++++-- cmake/ClientProbe.cmake | 1 + docs/STATUS.md | 10 + docs/engineering/CLIENT.md | 68 +++- docs/engineering/CLIENT_UI_STATE.md | 36 ++ docs/engineering/M11_8_DELIVERY_PLAN.md | 5 +- docs/engineering/VALIDATION.md | 35 ++ .../playtests/M11_9_REPEATED_LIFE_PLAYTEST.md | 7 +- src/client/platform/application.cpp | 31 ++ tests/client_lifecycle.cpp | 14 +- tests/client_panels.cpp | 168 ++++++++- tests/client_remote_session.cpp | 160 +++++++- tests/client_ui_model.cpp | 135 +++++++ tools/client/README-package.txt | 19 + 21 files changed, 1603 insertions(+), 93 deletions(-) create mode 100644 apps/evo-client/cellular_controls.hpp create mode 100644 apps/evo-client/cellular_play.hpp create mode 100644 apps/evo-client/cellular_scene.hpp diff --git a/apps/evo-client/cellular_controls.hpp b/apps/evo-client/cellular_controls.hpp new file mode 100644 index 0000000..bef0a17 --- /dev/null +++ b/apps/evo-client/cellular_controls.hpp @@ -0,0 +1,79 @@ +#pragma once +#include "evo/client/input.hpp" +#include "evo/client/organism_view.hpp" +#include "evo/network/session_protocol.hpp" +#include +#include +#include +#include + +namespace evo::client_app { +struct CellularControls { + bool auto_feed{true}, slow_near_food{true}, precision{}; + int speed_percent{100}; +}; +struct CellularSteering { + client::Intention intention; + std::optional> patch; +}; +// Assistance uses only the owner's copied view. It never predicts or moves a body. +// The cellular bridge currently encodes the footprint's lower-left position in x/y +// (ADR-0102), unlike the centre offsets used by the general organism fixture. +[[nodiscard]] inline CellularSteering +steer_cellular(const CellularControls& controls, client::Intention intention, + const network::CellularPerception* perception, + const client::OrganismPresentation* organisms, + std::optional> manual) { + CellularSteering result{intention, controls.auto_feed ? std::nullopt : manual}; + double scale = static_cast(std::clamp(controls.speed_percent, 1, 100)) / 100; + if (controls.precision) + scale *= 0.2; + if (perception && organisms && perception->life_identity != 0) { + const auto cells = organisms->cells(); + const auto own = + std::ranges::find(cells, perception->life_identity, &client::OrganismCell::id); + if (own != cells.end()) { + const double x = + static_cast(own->voxel.x) * 1'000'000 + static_cast(own->x.value); + const double y = + static_cast(own->voxel.y) * 1'000'000 + static_cast(own->y.value); + const double extent = static_cast(own->phenotype.extent); + for (const auto& p : perception->patches) { + if (p.energy_pj == 0 && + std::ranges::all_of(p.matter_fg, [](auto v) { return v == 0; })) + continue; + const double dx = + std::max({static_cast(p.x_um) - x - extent, x - p.x_um - 1000, 0.0}); + const double dy = + std::max({static_cast(p.y_um) - y - extent, y - p.y_um - 1000, 0.0}); + if (controls.auto_feed && !result.patch && dx == 0 && dy == 0) + result.patch = {p.x_um, p.y_um}; + // Presentation preference: approach food at at most 500 um/s (25 um/tick). + // Recomputed from the current phenotype after every mutation. Authority + // still determines displacement, contact, funding and intake. + if (controls.slow_near_food && dx <= 1000 && dy <= 1000 && + own->phenotype.movement_speed > 0) + scale = + std::min(scale, 500.0 / static_cast(own->phenotype.movement_speed)); + } + } + } + const auto component = [scale](std::int16_t value) { + const auto scaled = static_cast(value * scale); + // The protocol has finite precision; never turn held movement into a stop. + return scaled == 0 && value != 0 ? static_cast(value > 0 ? 1 : -1) : scaled; + }; + result.intention.move_x = component(intention.move_x); + result.intention.move_y = component(intention.move_y); + return result; +} +[[nodiscard]] inline bool can_fund(const network::CellularOfferedCandidate& candidate, + const network::CellularLifeDiagnostics& reserve) { + if (candidate.cost_energy_pj > reserve.reserve_energy_pj) + return false; + for (std::size_t i = 0; i < candidate.cost_matter_fg.size(); ++i) + if (candidate.cost_matter_fg[i] > reserve.reserve_matter_fg[i]) + return false; + return true; +} +} // namespace evo::client_app diff --git a/apps/evo-client/cellular_play.hpp b/apps/evo-client/cellular_play.hpp new file mode 100644 index 0000000..6dbecd6 --- /dev/null +++ b/apps/evo-client/cellular_play.hpp @@ -0,0 +1,281 @@ +#pragma once + +#include "evo/network/session_protocol.hpp" +#include +#include +#include +#include +#include +#include +#include + +namespace evo::client_app { +// Presentation and outstanding requests only. No biological prediction or saved authority. +struct MutationChoice { + std::uint64_t life{}, event{}, offer_tick{}; + std::uint16_t operator_id{}; + friend bool operator==(const MutationChoice&, const MutationChoice&) = default; +}; +enum class CellAction : std::uint8_t { engulf, bud, mutation }; +enum class CellActionState : std::uint8_t { + queued, + sent, + admitted, + unresolved, + committed, + no_effect, + refused +}; +struct CellActionRecord { + CellAction kind{}; + CellActionState state{CellActionState::queued}; + std::uint64_t id{}, life{}, tick{}; + MutationChoice choice{}; + network::AdmitStatus refusal{network::AdmitStatus::admitted}; +}; + +class CellularPlay { + public: + static constexpr std::size_t history_limit = 8; + void initialize(std::uint64_t first_id) { + next_id_ = first_id == 0 ? 1 : first_id; + birth_request_ = allocate_id(); + birth_pending_ = true; + } + [[nodiscard]] std::uint64_t allocate_id() { + const auto id = next_id_; + if (next_id_ != 0) + next_id_ = next_id_ == std::numeric_limits::max() ? 0 : next_id_ + 1; + return id; + } + void connected() { + connected_ = true; + } + void disconnected() { + connected_ = false; + fresh_ = false; + offer_.reset(); + if (pending_) { + if (pending_->state == CellActionState::queued) { + pending_->state = CellActionState::refused; + finish(); + } else { + pending_->state = CellActionState::unresolved; + } + } + } + void observe(const network::CellularPerception& view) { + if (view.tick < view_tick_) + return; + view_tick_ = view.tick; + fresh_ = true; + if (ended_ && view.life_identity == ended_->life_identity) + return; // A retained pre-death view must never revive this identity. + // Never replay an intention onto a later life. Keep its uncertain result visible. + if (life_ != view.life_identity) { + offer_.reset(); + engulf_feedback_.reset(); + bud_feedback_.reset(); + if (pending_) { + pending_->state = pending_->state == CellActionState::queued + ? CellActionState::refused + : CellActionState::unresolved; + finish(); + } + } + life_ = view.life_identity; + if (view.diagnostics && view.diagnostics->has_tick_effects) { + const auto& d = *view.diagnostics; + if (d.engulf != network::CellularEngulfResult::not_reported && + d.engulf != network::CellularEngulfResult::not_requested) + engulf_feedback_ = std::pair{view.tick, d.engulf}; + if (d.bud != network::CellularBudOutcome::not_reported && + d.bud != network::CellularBudOutcome::not_requested) + bud_feedback_ = std::pair{view.tick, d.bud}; + } + if (life_ != 0) { + birth_pending_ = false; + if (ended_ && ended_->life_identity != life_) + ended_.reset(); + } + } + void observe_offer(const std::optional& offer) { + offer_ = offer && offer->life_identity == life_ && fresh_ && !ended_ ? offer : std::nullopt; + } + void observe_end(const network::CellularLifeEnded& ended) { + if (ended.life_identity == seen_end_ || (life_ != 0 && life_ != ended.life_identity) || + (ended_ && ended_->tick >= ended.tick) || ended.tick < birth_tick_) + return; + seen_end_ = ended.life_identity; + ended_ = ended; + life_ = 0; + offer_.reset(); + if (pending_ && pending_->state == CellActionState::queued) { + pending_->state = CellActionState::refused; + finish(); + } + // The discrete action may still have a final result arriving in this poll. + } + [[nodiscard]] bool can_act() const { + return connected_ && fresh_ && life_ != 0 && !ended_ && !pending_ && !birth_pending_; + } + [[nodiscard]] bool queue(CellAction kind, std::uint64_t tick, MutationChoice choice = {}) { + if (!can_act() || tick == 0) + return false; + if (kind == CellAction::mutation && + (!offer_ || choice.life != life_ || choice.event != offer_->event_index || + choice.offer_tick != offer_->offer_tick || tick <= choice.offer_tick || + !std::ranges::any_of(offer_->candidates, [&](const auto& c) { + return c.operator_id == choice.operator_id; + }))) + return false; + const auto id = allocate_id(); + if (id == 0) + return false; + pending_ = CellActionRecord{kind, CellActionState::queued, id, life_, tick, choice}; + return true; + } + void sent() { + if (pending_) + pending_->state = CellActionState::sent; + } + void rechecking() { + if (pending_ && pending_->state != CellActionState::queued) + pending_->state = CellActionState::unresolved; + } + void receipt(const network::ActionReceipt& receipt) { + if (!pending_ || pending_->id != receipt.action_id) + return; + if (receipt.status == network::AdmitStatus::admitted || + receipt.status == network::AdmitStatus::duplicate) { + pending_->state = CellActionState::admitted; + } else if (pending_->kind == CellAction::mutation && + receipt.status == network::AdmitStatus::not_ready) { + // The host can report not_ready after an uncertain durable reservation. + pending_->state = CellActionState::unresolved; + } else if (pending_->state != CellActionState::unresolved && + pending_->state != CellActionState::admitted) { + pending_->state = CellActionState::refused; + pending_->refusal = receipt.status; + finish(); + } + // A refused retry cannot disprove a previously admitted or uncertain action. + } + void outcome(const network::ActionOutcome& outcome) { + if (!pending_ || pending_->id != outcome.action_id) { + // Final replies may arrive after the life ended or the user kept an unknown. + for (auto& record : history_) + if (record.id == outcome.action_id && record.state == CellActionState::unresolved) { + if (outcome.result == network::ActionResult::committed) + record.state = CellActionState::committed; + else if (outcome.result == network::ActionResult::committed_no_effect) + record.state = CellActionState::no_effect; + else if (outcome.result == network::ActionResult::not_committed) + record.state = CellActionState::refused; + } + return; + } + using enum network::ActionResult; + switch (outcome.result) { + case committed: + pending_->state = CellActionState::committed; + break; + case committed_no_effect: + pending_->state = CellActionState::no_effect; + break; + case not_committed: + pending_->state = CellActionState::refused; + break; + case pending: + pending_->state = CellActionState::admitted; + return; + case unknown: + pending_->state = CellActionState::unresolved; + return; + } + finish(); + } + // User may leave an uncertain result in the bounded record, never as a success/refusal. + void keep_unknown() { + if (pending_ && pending_->state == CellActionState::unresolved) + finish(); + } + [[nodiscard]] bool can_restart() const { + return connected_ && fresh_ && life_ == 0 && !birth_pending_; + } + [[nodiscard]] bool restart() { + if (!can_restart()) + return false; + const auto id = allocate_id(); + if (id == 0) + return false; + birth_request_ = id; + birth_pending_ = true; + return true; + } + void birth(const network::PrimitiveLifeOutcome& result) { + if (result.request_id != birth_request_) + return; + birth_result_ = result.result; + birth_pending_ = result.result == network::PrimitiveLifeResult::pending || + result.result == network::PrimitiveLifeResult::unknown || + result.result == network::PrimitiveLifeResult::born; + if (result.result == network::PrimitiveLifeResult::born) { + ended_.reset(); + birth_tick_ = view_tick_; + } + } + [[nodiscard]] std::uint64_t birth_request() const { + return birth_request_; + } + [[nodiscard]] bool birth_pending() const { + return birth_pending_; + } + [[nodiscard]] network::PrimitiveLifeResult birth_result() const { + return birth_result_; + } + [[nodiscard]] std::uint64_t life() const { + return life_; + } + [[nodiscard]] bool fresh() const { + return connected_ && fresh_; + } + [[nodiscard]] const auto& offer() const { + return offer_; + } + [[nodiscard]] const auto& ended() const { + return ended_; + } + [[nodiscard]] const auto& pending() const { + return pending_; + } + [[nodiscard]] const auto& history() const { + return history_; + } + [[nodiscard]] const auto& engulf_feedback() const { + return engulf_feedback_; + } + [[nodiscard]] const auto& bud_feedback() const { + return bud_feedback_; + } + + private: + void finish() { + if (!pending_) + return; + if (history_.size() == history_limit) + history_.pop_front(); + history_.push_back(*pending_); + pending_.reset(); + } + std::uint64_t next_id_{1}, life_{}, view_tick_{}, birth_tick_{}, birth_request_{}, seen_end_{}; + bool connected_{}, fresh_{}, birth_pending_{}; + network::PrimitiveLifeResult birth_result_{network::PrimitiveLifeResult::pending}; + std::optional offer_; + std::optional ended_; + std::optional pending_; + std::deque history_; + std::optional> engulf_feedback_; + std::optional> bud_feedback_; +}; +} // namespace evo::client_app diff --git a/apps/evo-client/cellular_scene.hpp b/apps/evo-client/cellular_scene.hpp new file mode 100644 index 0000000..053ccf1 --- /dev/null +++ b/apps/evo-client/cellular_scene.hpp @@ -0,0 +1,47 @@ +#pragma once +#include "evo/client/camera.hpp" +#include "evo/render/frame.hpp" +#include +#include + +namespace evo::client_app { +inline constexpr std::size_t patch_rectangles = 3; +// The border keeps the 1 mm contact footprint readable; the inset is decorative. +// No stock percentage is invented: the centre mark means some stock remains. +inline void patch_box(std::vector& out, client::ScreenPoint low, + client::ScreenPoint high, bool stocked, bool selected, double width, + double height, bool stale = false) { + const double minimum = selected ? 5 : 3; + const double hx = std::max((high.x - low.x) / 2, minimum); + const double hy = std::max((low.y - high.y) / 2, minimum); + const double x = (low.x + high.x) / 2, y = (low.y + high.y) / 2; + const auto rect = [&](double l, double t, double r, double b, render::Color color) { + l = std::max(l, 0.0); + t = std::max(t, 0.0); + r = std::min(r, width); + b = std::min(b, height); + if (stale) { + color.red /= 2; + color.green /= 2; + color.blue /= 2; + } + if (r > l && b > t) + out.push_back({static_cast(l), static_cast(t), static_cast(r - l), + static_cast(b - t), color}); + }; + rect(x - hx, y - hy, x + hx, y + hy, + selected ? render::Color{233, 182, 85, 255} + : stocked ? render::Color{49, 112, 105, 255} + : render::Color{58, 69, 77, 255}); + if (hx <= 6 || hy <= 6) + return; + const double border = selected ? 2 : 1; + rect(x - hx + border, y - hy + border, x + hx - border, y + hy - border, + selected ? render::Color{53, 49, 31, 255} : render::Color{17, 40, 43, 255}); + if (stocked) { + const double mark = std::clamp(std::min(hx, hy) * 0.08, 2.0, 5.0); + rect(x - mark, y - mark, x + mark, y + mark, + selected ? render::Color{233, 182, 85, 255} : render::Color{90, 185, 150, 255}); + } +} +} // namespace evo::client_app diff --git a/apps/evo-client/controls_flow.hpp b/apps/evo-client/controls_flow.hpp index 31344b0..ca2c1b4 100644 --- a/apps/evo-client/controls_flow.hpp +++ b/apps/evo-client/controls_flow.hpp @@ -94,6 +94,8 @@ class ControlsFlow { static_cast(ui.notify(text, level, lifetime_ms).has_value()); // Bounded. } void apply(client::Application& app, client::UiState& ui) { + if (!editor_) + return; const auto applied = editor_->apply(); if (!applied) { problem_ = applied.error(); diff --git a/apps/evo-client/main.cpp b/apps/evo-client/main.cpp index af7ee5f..79508fa 100644 --- a/apps/evo-client/main.cpp +++ b/apps/evo-client/main.cpp @@ -1,3 +1,4 @@ +#include "cellular_scene.hpp" #include "controls_flow.hpp" #include "evo/client/application.hpp" #include "evo/client/launcher.hpp" @@ -33,10 +34,11 @@ constexpr std::uint32_t fixture_mask = (1U << 0) | (1U << 1) | (1U << 2) | (1U < constexpr unsigned frames_per_authority_tick = 60; // Frame composition: environment bound + organisms + 6 host rectangles (capture bar, // intention dot, 4-sided selection highlight). Text and panels are the toolkit overlay. -constexpr std::size_t host_rectangles = 6 + evo::network::max_cellular_perceived_patches; +constexpr std::size_t host_rectangles = + 6 + evo::client_app::patch_rectangles * evo::network::max_cellular_perceived_patches; // M11.3: the cellular arena is millimetres across, far below the metre-scale default // camera; the first view frames this much of it around the own cell. -constexpr double cellular_view_mm = 12; +constexpr double cellular_view_mm = 6; constexpr std::size_t organism_budget = evo::render::max_rectangles - evo::render::max_environment_rectangles - host_rectangles; // Local in-memory stand-in for authoritative region views until M9.7. It is never @@ -204,28 +206,6 @@ void marker_box(std::vector& out, double x, double y, bo : own ? evo::render::Color{250, 190, 40, 255} : evo::render::Color{90, 170, 250, 255}}); } -// A cellular food patch over its true 1 mm footprint (contact means overlapping it), dim so -// the cell stays visible on top; zoomed far out it shrinks to a bright marker instead. -void patch_box(std::vector& out, evo::client::ScreenPoint low, - evo::client::ScreenPoint high, bool stocked, bool selected, double width, - double height) { - const double minimum = selected ? 5 : 3; - const double half_x = std::max((high.x - low.x) / 2, minimum); - const double half_y = std::max((low.y - high.y) / 2, minimum); - const bool footprint = half_x > 6 && half_y > 6; - const double x = (low.x + high.x) / 2, y = (low.y + high.y) / 2; - const double x0 = std::max(x - half_x, 0.0), y0 = std::max(y - half_y, 0.0); - const double x1 = std::min(x + half_x, width), y1 = std::min(y + half_y, height); - if (x1 > x0 && y1 > y0) - out.push_back({static_cast(x0), static_cast(y0), static_cast(x1 - x0), - static_cast(y1 - y0), - selected ? (footprint ? evo::render::Color{120, 92, 24, 255} - : evo::render::Color{250, 190, 40, 255}) - : stocked ? (footprint ? evo::render::Color{32, 100, 60, 255} - : evo::render::Color{80, 220, 130, 255}) - : footprint ? evo::render::Color{52, 58, 64, 255} - : evo::render::Color{115, 125, 135, 255}}); -} void outline(std::vector& out, double l, double t, double r, double b, double width, double height) { const auto rect = [&](double x0, double y0, double x1, double y1) { @@ -456,6 +436,7 @@ int main(int argc, char** argv) try { view.remote = remote->status(); view.outcomes = &remote->outcomes(); view.cellular_perception = remote->cellular_perception(); + view.cellular_play = &remote->cellular_play(); view.cellular_feed_target = cellular_feed_target; } view.visible_organisms = drawn_organisms; @@ -508,23 +489,47 @@ int main(int argc, char** argv) try { disconnect_dialog.reset(); if (actions.dismiss_notice) static_cast(ui.dismiss(*actions.dismiss_notice)); - if (actions.stop_feeding) + if (actions.stop_feeding) { cellular_feed_target.reset(); - if (actions.feed_patch) + buffers.cellular_controls.auto_feed = false; + } + if (actions.feed_patch) { cellular_feed_target = actions.feed_patch; - if (auto* remote = host.session(); remote && mode() == Mode::remote) + buffers.cellular_controls.auto_feed = false; + } + if (auto* remote = host.session(); remote && mode() == Mode::remote) { + if (actions.cell_action && remote->request_cellular(*actions.cell_action)) + cellular_feed_target.reset(); + if (actions.mutation) + static_cast(remote->request_cellular(evo::client_app::CellAction::mutation, + *actions.mutation)); + if (actions.restart_life && remote->restart_cellular()) { + cellular_feed_target.reset(); + selection.clear(); + } + if (actions.keep_unknown) + remote->keep_cellular_unknown(); remote->set_cellular_feed_target(cellular_trial ? cellular_feed_target : std::nullopt); + remote->set_cellular_controls(buffers.cellular_controls); + } controls.step(actions, **app, ui); actions = {}; // The launcher and modal dialogs own input: no world movement or selection. + const auto* input_session = host.session(); + const bool cell_input_blocked = input_session && input_session->cellular_trial() && + (!input_session->cellular_play().fresh() || + input_session->cellular_play().life() == 0 || + input_session->cellular_play().ended().has_value()); (*app)->set_ui_capture(mode() == Mode::launcher || ui.dialog().has_value() || - controls.open()); + controls.open() || cell_input_blocked); const auto navigation = (*app)->take_navigation(); // Local input counter; in remote mode the session sets the server tick. const auto intention = (*app)->sample_intention(count); if (!intention) return 1; host.step(now, *intention, ui); // Only while connecting or connected. + if (const auto* remote = host.session(); remote && cellular_trial) + cellular_feed_target = remote->cellular_feed_target(); // M10.5c: the camera follows the server's view until the user moves it; from then // on its centre is the session's interest (the server clamps and filters it). if (auto* remote = host.session(); remote && mode() == Mode::remote) { @@ -581,16 +586,20 @@ int main(int argc, char** argv) try { &evo::client::OrganismCell::id); if (own != cells.end()) { const double pitch = evo::world::cell_pitch_mm; - const evo::client::WorldPoint centre{ - static_cast(own->voxel.x) * pitch + - static_cast(own->x.value) / 1000, - static_cast(own->voxel.y) * pitch + - static_cast(own->y.value) / 1000}; + evo::client::WorldPoint centre{static_cast(own->voxel.x) * pitch + + static_cast(own->x.value) / 1000, + static_cast(own->voxel.y) * pitch + + static_cast(own->y.value) / + 1000}; const double scale = cellular_framed ? camera->units_per_mm() : static_cast(std::min(state.logical_width, state.logical_height)) / cellular_view_mm; + // Keep the followed cell in the visible arena beside the journal. + const double shift = state.logical_width < 880 ? 171.0 : -10.0; + centre.x_mm -= shift / scale; + centre.y_mm += 29.0 / scale; if (auto moved = evo::client::Camera::create(camera->viewport(), centre, scale)) { *camera = *moved; @@ -632,14 +641,14 @@ int main(int argc, char** argv) try { {(static_cast(patch.x_um) + 1000) / 1000, (static_cast(patch.y_um) + 1000) / 1000}); if (low && high) - patch_box(boxes, *low, *high, - patch.energy_pj != 0 || - std::ranges::any_of(patch.matter_fg, - [](auto v) { return v != 0; }), - cellular_feed_target && - cellular_feed_target->first == patch.x_um && - cellular_feed_target->second == patch.y_um, - width, height); + evo::client_app::patch_box( + boxes, *low, *high, + patch.energy_pj != 0 || + std::ranges::any_of(patch.matter_fg, + [](auto v) { return v != 0; }), + cellular_feed_target && cellular_feed_target->first == patch.x_um && + cellular_feed_target->second == patch.y_um, + width, height, !remote->cellular_play().fresh()); } const auto report = evo::render::append_organisms( boxes, organism_budget, orgs, diff --git a/apps/evo-client/panels.cpp b/apps/evo-client/panels.cpp index 19bd9b3..948bf25 100644 --- a/apps/evo-client/panels.cpp +++ b/apps/evo-client/panels.cpp @@ -108,7 +108,9 @@ void launcher(const PanelView& v, FormBuffers& form, PanelActions& a) { ImGui::SetNextWindowSize({std::min(px(520), io.DisplaySize.x - px(16)), 0}, ImGuiCond_Always); ImGui::Begin("Aeternalis Evolution - engineering client", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse); - ImGui::TextWrapped("Choose a data source. Nothing here is a game or a player account."); + ImGui::TextColored(green, "AETERNALIS / EVOLUTION"); + ImGui::TextWrapped("Begin a cellular life in the shared dev ecosystem, or explore the local " + "engineering fixture."); if (ImGui::SmallButton("Controls...")) a.open_controls = true; ImGui::Separator(); @@ -125,7 +127,7 @@ void launcher(const PanelView& v, FormBuffers& form, PanelActions& a) { ImGui::InputText("Dev CA file", form.authority.data(), form.authority.size()); ImGui::InputText("Grant bundle file", form.grants.data(), form.grants.size()); bool cellular_trial = v.cellular_trial; - if (ImGui::Checkbox("Cellular trial (v9)", &cellular_trial)) + if (ImGui::Checkbox("Cellular play (v10)", &cellular_trial)) a.cellular_trial = cellular_trial; const bool start = phase == LaunchPhase::choosing && ImGui::Button("Connect", {px(160), 0}); ImGui::EndDisabled(); @@ -513,6 +515,333 @@ void session(const PanelView& v, PanelActions& a) { ImGui::End(); } +const char* cell_action_name(CellAction kind) { + switch (kind) { + case CellAction::engulf: + return "Engulf"; + case CellAction::bud: + return "Bud"; + case CellAction::mutation: + return "Mutation"; + } + return "Action"; +} +const char* cell_action_state(CellActionState state) { + switch (state) { + case CellActionState::queued: + return "Queued"; + case CellActionState::sent: + return "Sent / awaiting admission"; + case CellActionState::admitted: + return "Accepted / awaiting commit"; + case CellActionState::unresolved: + return "Unresolved / outcome unknown"; + case CellActionState::committed: + return "Committed"; + case CellActionState::no_effect: + return "Committed / no effect"; + case CellActionState::refused: + return "Refused / no new action"; + } + return "Unknown"; +} +void cell_record(const CellActionRecord& record) { + ImGui::TextColored(record.state == CellActionState::committed ? green : amber, "%s", + cell_action_name(record.kind)); + ImGui::TextWrapped("%s", cell_action_state(record.state)); + if (record.state == CellActionState::refused && + record.refusal != network::AdmitStatus::admitted) + disabled_wrapped(std::string{cellular_admission_message(record.refusal)}.c_str()); +} +void cell_vitals(const PanelView& v) { + const auto* p = v.cellular_perception; + const auto* play = v.cellular_play; + ImGui::TextColored(green, "VITAL SIGNS"); + if (!play || !play->fresh()) + ImGui::TextColored(amber, "Waiting for a fresh server view"); + if (!p || !p->diagnostics || !play || play->life() == 0) { + disabled_wrapped("Your cell's reserves will appear here when a living cell is visible."); + return; + } + const auto& d = *p->diagnostics; + ImGui::TextDisabled("ENERGY RESERVE"); + ImGui::PushFont(nullptr, 24); + ImGui::TextWrapped("%llu pJ", static_cast(d.reserve_energy_pj)); + ImGui::PopFont(); + ImGui::Separator(); + if (ImGui::BeginTable("matter", 2, ImGuiTableFlags_SizingStretchSame)) { + constexpr std::array names{"Carbon", "Nitrogen", "Phosphorus", "Other matter"}; + for (std::size_t i = 0; i < names.size(); ++i) { + ImGui::TableNextColumn(); + ImGui::TextDisabled("%s", names[i]); + ImGui::Text("%llu fg", static_cast(d.reserve_matter_fg[i])); + } + ImGui::EndTable(); + } + ImGui::Separator(); + if (!d.has_tick_effects) { + disabled_wrapped("Tick effects are unavailable until the next committed tick."); + return; + } + ImGui::TextWrapped("Last tick: upkeep %llu pJ / movement %llu pJ", + static_cast(d.maintenance_cost_pj), + static_cast(d.movement_cost_pj)); + constexpr std::array movement{"Unavailable", "Resting", "Moving", "Movement blocked", + "Not enough energy to move"}; + constexpr std::array intake{"Unavailable", "Not feeding", "Food absorbed", "Food patch missing", + "Move into contact to feed"}; + constexpr std::array engulf{"Unavailable", + "Not requested", + "Prey engulfed", + "No eligible prey in contact", + "Engulf unsupported here", + "Engulf failed: no cell touching yours", + "Engulf failed: prey is too large", + "Engulf failed: prey's membrane is too thick"}; + constexpr std::array bud{"Unavailable", + "Not requested", + "Wildlife bud created", + "Cell cannot bud yet", + "Not enough resources to bud", + "No space for a bud"}; + ImGui::TextWrapped("%s", movement.at(static_cast(d.movement))); + ImGui::TextWrapped("%s", intake.at(static_cast(d.intake))); + if (const auto& feedback = play->engulf_feedback(); feedback) + ImGui::TextWrapped("%s (tick %llu)", engulf.at(static_cast(feedback->second)), + static_cast(feedback->first)); + if (const auto& feedback = play->bud_feedback(); feedback) + ImGui::TextWrapped("%s (tick %llu)", bud.at(static_cast(feedback->second)), + static_cast(feedback->first)); +} +void cell_food(const PanelView& v, PanelActions& a, FormBuffers& form) { + ImGui::TextColored(green, "FEED & SURVIVE"); + ImGui::Checkbox("Feed automatically", &form.cellular_controls.auto_feed); + ImGui::Checkbox("Slow near food", &form.cellular_controls.slow_near_food); + ImGui::Checkbox("Precision steering (20%)", &form.cellular_controls.precision); + ImGui::SetNextItemWidth(-1); + ImGui::SliderInt("##speed", &form.cellular_controls.speed_percent, 1, 100, "Speed: %d%%"); + disabled_wrapped("Steer onto food. Automatic feeding targets a stocked patch touching your " + "cell. Choose a patch below to switch to manual feeding."); + const bool active = v.cellular_play && v.cellular_play->fresh() && v.cellular_play->life() != 0; + ImGui::BeginDisabled(!active); + if (v.cellular_feed_target && ImGui::Button("Stop feeding", {-1, 0})) + a.stop_feeding = true; + if (const auto* p = v.cellular_perception) { + if (p->patches.empty()) + disabled_wrapped("No food is visible within sensor range."); + for (const auto& patch : p->patches) { + ImGui::PushID(static_cast(patch.x_um)); + ImGui::PushID(static_cast(patch.y_um)); + ImGui::Separator(); + ImGui::Text("Patch %u / %u um", patch.x_um, patch.y_um); + ImGui::Text("%llu pJ", static_cast(patch.energy_pj)); + ImGui::TextWrapped("C %llu / N %llu / P %llu / other %llu fg", + static_cast(patch.matter_fg[0]), + static_cast(patch.matter_fg[1]), + static_cast(patch.matter_fg[2]), + static_cast(patch.matter_fg[3])); + const bool selected = v.cellular_feed_target == std::pair{patch.x_um, patch.y_um}; + if (selected) + ImGui::TextColored(green, "FEEDING TARGET"); + else if (ImGui::Button("Feed here", {-1, 0})) + a.feed_patch = {patch.x_um, patch.y_um}; + ImGui::PopID(); + ImGui::PopID(); + } + } + ImGui::EndDisabled(); +} +void cell_actions(const PanelView& v, PanelActions& a) { + const auto* play = v.cellular_play; + ImGui::Separator(); + ImGui::TextColored(green, "ACT ONCE"); + ImGui::BeginDisabled(!play || !play->can_act()); + const float width = (ImGui::GetContentRegionAvail().x - ImGui::GetStyle().ItemSpacing.x) / 2; + if (ImGui::Button("Engulf", {width, px(32)})) + a.cell_action = CellAction::engulf; + ImGui::SameLine(); + if (ImGui::Button("Bud", {width, px(32)})) + a.cell_action = CellAction::bud; + ImGui::EndDisabled(); + disabled_wrapped("Engulf attempts nearby prey. Bud funds an independent descendant; you keep " + "your cell. Automatic feeding resumes after the action tick."); + if (!play) + return; + if (const auto& pending = play->pending(); pending) { + ImGui::Separator(); + cell_record(*pending); + if (pending->state == CellActionState::unresolved) { + disabled_wrapped("The reply was lost or is unavailable. Checking the original request; " + "no second action is created."); + if (ImGui::Button("Keep result as unknown", {-1, 0})) + a.keep_unknown = true; + } + } +} +void cell_evolution(const PanelView& v, PanelActions& a) { + const auto* play = v.cellular_play; + ImGui::TextColored(green, "LIFE & EVOLUTION"); + if (!play) + return; + if (play->life() == 0) { + ImGui::Separator(); + if (const auto& ended = play->ended(); ended) { + ImGui::TextColored(amber, "THIS LIFE HAS ENDED"); + const auto cause = ended->cause; + ImGui::TextWrapped("%s", cause == network::CellularDeathReason::starved + ? "Your cell starved." + : cause == network::CellularDeathReason::engulfed + ? "Your cell was engulfed." + : "The cause was not recorded."); + ImGui::TextWrapped("Its history and descendants remain. Your next life begins as a new " + "primitive cell."); + } else { + ImGui::TextWrapped("%s", play->birth_pending() ? "Establishing your cell..." + : "No active cell is visible."); + disabled_wrapped("A missing view alone does not reveal a death cause. A suspended cell " + "may still be waiting for space to resume."); + } + ImGui::BeginDisabled(!play->can_restart()); + if (ImGui::Button("Start new life", {-1, px(38)})) + a.restart_life = true; + ImGui::EndDisabled(); + if (v.remote && !v.remote->cellular_action.empty()) + ImGui::TextWrapped("%s", v.remote->cellular_action.c_str()); + return; + } + const auto& offer = play->offer(); + if (!offer) { + ImGui::Separator(); + ImGui::TextWrapped("Feed. Adapt. Leave descendants."); + disabled_wrapped("Useful feeding earns mutation opportunities. When an offer arrives, " + "choose a tradeoff for this life."); + ImGui::Spacing(); + disabled_wrapped("No offer is available yet. Wildlife descendants inherit your genome and " + "live independently."); + return; + } + ImGui::TextColored(amber, "MUTATION AVAILABLE"); + disabled_wrapped("Useful feeding earned this choice. Each change trades a capability against " + "upkeep and body mass. The server checks your reserve when it commits."); + constexpr std::array capabilities{"Energy conversion", "Membrane", "Movement", + "Ingestion", "Reproduction", "Target size", + "Thermal tolerance"}; + constexpr std::array effects{"Increase", "Decrease", "Acquire", "Shed"}; + for (const auto& c : offer->candidates) { + ImGui::PushID(static_cast(c.operator_id)); + ImGui::Separator(); + ImGui::TextWrapped("%s %s", effects.at(c.effect), capabilities.at(c.capability)); + constexpr std::array increase{"Convert more intake into usable energy.", + "Build a thicker protective membrane.", + "Raise your maximum movement speed.", + "Raise how much food you can ingest per second.", + "Increase your reproduction capability.", + "Grow toward a larger target body mass.", + "Widen your temperature tolerance."}; + constexpr std::array decrease{"Reduce energy conversion capability.", + "Build a thinner membrane.", + "Lower your maximum movement speed.", + "Lower how much food you can ingest per second.", + "Reduce your reproduction capability.", + "Grow toward a smaller target body mass.", + "Narrow your temperature tolerance."}; + disabled_wrapped(c.effect == 3 ? "Remove this capability from your genome." + : c.effect == 2 ? "Add this capability to your genome." + : c.effect == 0 ? increase.at(c.capability) + : decrease.at(c.capability)); + constexpr std::array units{"per 1000", "um", "um/s", "fg/s", "per 1000", "fg", "mK"}; + ImGui::TextWrapped("Successor value %u %s", c.parameter, units.at(c.capability)); + ImGui::TextWrapped("Maintenance %llu pJ / s\nTotal mass %llu fg", + static_cast(c.maintenance), + static_cast(c.total_mass)); + const auto* perception = v.cellular_perception; + const bool affordable = + perception && perception->diagnostics && can_fund(c, *perception->diagnostics); + ImGui::TextWrapped("Cost: %llu pJ\nC %llu / N %llu / P %llu / other %llu fg", + static_cast(c.cost_energy_pj), + static_cast(c.cost_matter_fg[0]), + static_cast(c.cost_matter_fg[1]), + static_cast(c.cost_matter_fg[2]), + static_cast(c.cost_matter_fg[3])); + if (!affordable) + ImGui::TextColored(amber, "Need more reserves"); + ImGui::BeginDisabled(!affordable || !play->can_act() || !v.remote || + v.remote->server_tick <= offer->offer_tick); + if (ImGui::Button("Choose mutation", {-1, px(30)})) + a.mutation = MutationChoice{offer->life_identity, offer->event_index, offer->offer_tick, + c.operator_id}; + ImGui::EndDisabled(); + ImGui::PopID(); + } +} +void cell_log(const PanelView& v, FormBuffers& form) { + ImGui::TextColored(green, "ACTION RECORD"); + if (v.cellular_play) { + const auto& records = v.cellular_play->history(); + if (records.empty()) + disabled_wrapped("Your discrete action results will appear here."); + for (auto it = records.rbegin(); it != records.rend(); ++it) { + cell_record(*it); + ImGui::Separator(); + } + } + if (v.remote) { + ImGui::TextWrapped("Region %llu / tick %llu / grants %zu", + static_cast(v.remote->region), + static_cast(v.remote->server_tick), + v.remote->grants_left); + } + ImGui::Checkbox("Engineering panels", &form.engineering); + disabled_wrapped("On disconnect your biology freezes immediately, but the cell remains " + "vulnerable for the 10-second linger before suspension."); +} +void cellular(const PanelView& v, FormBuffers& form, PanelActions& a) { + const auto& io = ImGui::GetIO(); + const float margin = px(12), top = px(58); + const bool compact = io.DisplaySize.x < px(880); + const float height = std::max(px(80), io.DisplaySize.y - top - margin); + const float left_width = compact ? std::min(px(330), io.DisplaySize.x - 2 * margin) : px(280); + const auto flags = ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | + ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings; + ImGui::SetNextWindowPos({margin, top}, ImGuiCond_Always); + ImGui::SetNextWindowSize({left_width, height}, ImGuiCond_Always); + ImGui::Begin("Cellular field journal", nullptr, flags); + if (ImGui::BeginTabBar("cell-tabs")) { + if (ImGui::BeginTabItem("Cell")) { + disabled_wrapped(form.cellular_controls.auto_feed ? "AUTO FEED ON / steering in Food" + : "MANUAL FEED / steering in Food"); + cell_vitals(v); + cell_actions(v, a); + if (v.bindings) { + ImGui::Separator(); + disabled_wrapped(controls_hint(*v.bindings).c_str()); + } + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Food")) { + cell_food(v, a, form); + ImGui::EndTabItem(); + } + if (compact && ImGui::BeginTabItem("Life")) { + cell_evolution(v, a); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Log")) { + cell_log(v, form); + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); + } + ImGui::End(); + if (!compact) { + ImGui::SetNextWindowPos({io.DisplaySize.x - margin, top}, ImGuiCond_Always, {1, 0}); + ImGui::SetNextWindowSize({px(300), height}, ImGuiCond_Always); + ImGui::Begin("Evolution", nullptr, flags); + cell_evolution(v, a); + ImGui::End(); + } +} + // Newest at the bottom right. Each notice wraps its text beside a reserved close // column, so the button is always visible; the stack stops at 60 % of the viewport // height and counts what it could not show (those still expire or can be dismissed @@ -605,9 +934,13 @@ PanelActions draw_panels(const PanelView& view, FormBuffers& form, launcher(view, form, actions); } else { banner(view, actions); - legend(view, display); - inspector(view); - session(view, actions); + if (view.remote && view.remote->cellular_trial) + cellular(view, form, actions); + if (!view.remote || !view.remote->cellular_trial || form.engineering) { + legend(view, display); + inspector(view); + session(view, actions); + } } controls(view, actions); notices(view, actions); diff --git a/apps/evo-client/panels.hpp b/apps/evo-client/panels.hpp index d25d29a..6d2ec9d 100644 --- a/apps/evo-client/panels.hpp +++ b/apps/evo-client/panels.hpp @@ -23,6 +23,8 @@ inline constexpr float notice_width = 320, notice_close_width = 22; inline constexpr const char* notice_window_prefix = "##notice"; // Text-field storage for the connect form (bounded; never persisted). struct FormBuffers { + bool engineering{}; + CellularControls cellular_controls; std::array endpoint{}, server_name{}, authority{}, grants{}; void load(const client::ConnectForm& form); [[nodiscard]] client::ConnectForm form() const; @@ -45,6 +47,7 @@ struct PanelView { const client::UiState* ui{}; std::optional remote; const network::CellularPerception* cellular_perception{}; + const CellularPlay* cellular_play{}; std::optional> cellular_feed_target; const client::OutcomeLog* outcomes{}; int visible_organisms{-1}; // -1 when unknown. @@ -63,6 +66,9 @@ struct PanelActions { std::optional cellular_trial; std::optional> feed_patch; bool stop_feeding{}; + std::optional cell_action; + std::optional mutation; + bool restart_life{}, keep_unknown{}; }; // Draws every panel for this frame. `display` may be changed by the layer selector. [[nodiscard]] PanelActions draw_panels(const PanelView& view, FormBuffers& form, diff --git a/apps/evo-client/remote_session.hpp b/apps/evo-client/remote_session.hpp index 5b40882..bf16ba9 100644 --- a/apps/evo-client/remote_session.hpp +++ b/apps/evo-client/remote_session.hpp @@ -2,7 +2,7 @@ // M10.5c remote dev session for the engineering client (ADR-0093, over ADR-0091/0092 // sessions). Without EVO_CLIENT_NETWORK (a build without EVO_BUILD_QUIC) remote mode is // unavailable. The client only presents copies of replicated snapshots and sends bounded -// bounded intentions; the explicit cellular trial uses reliable v9 actions and its +// intentions; the explicit cellular trial uses reliable v10 actions and its // owner-filtered perception view. Grant bytes stay inside the session: each is handed to one // connection and wiped here; never printed, shown or persisted. // @@ -31,6 +31,8 @@ // is followed with a grant for that region. Grants are picked by their region claim (the // session-grant-v1 layout is public; the claim only routes, the region still verifies), so a // bundle may hold grants for several regions. +#include "cellular_controls.hpp" +#include "cellular_play.hpp" #include "evo/client/camera.hpp" #include "evo/client/environment_view.hpp" #include "evo/client/input.hpp" @@ -173,14 +175,8 @@ class RemoteSession { session.transport_.authority_pem_file = m.authority_path; session.grants_ = m.grants; session.cellular_trial_ = cellular_trial; - session.next_cellular_action_id_ = - static_cast(std::chrono::system_clock::now().time_since_epoch().count()); - if (session.next_cellular_action_id_ == 0) - session.next_cellular_action_id_ = 1; - session.cellular_birth_request_id_ = - session.next_cellular_action_id_ ^ 0x43454C4C00000000ULL; - if (session.cellular_birth_request_id_ == 0) - session.cellular_birth_request_id_ = 1; + session.cellular_play_.initialize(static_cast( + std::chrono::system_clock::now().time_since_epoch().count())); session.used_.assign(m.grants.size(), false); // The endpoint typed in the launcher is the first grant's region. session.target_region_ = grant_region(m.grants.front()); @@ -212,16 +208,48 @@ class RemoteSession { return cellular_trial_; } [[nodiscard]] const network::CellularPerception* cellular_perception() const noexcept { - return client_ && client_->cellular_perception() ? &*client_->cellular_perception() - : nullptr; + if (!client_) + return nullptr; + const auto& p = client_->cellular_perception(); + return p ? &*p : nullptr; } [[nodiscard]] const std::string& cellular_action_status() const noexcept { return cellular_action_status_; } + [[nodiscard]] const CellularPlay& cellular_play() const noexcept { + return cellular_play_; + } + [[nodiscard]] bool request_cellular(CellAction kind, MutationChoice choice = {}) { + const auto tick = kind == CellAction::mutation + ? server_tick_ + : server_tick_ + (sent_tick_ && *sent_tick_ == server_tick_ ? 2 : 1); + if (!cellular_trial_ || !cellular_play_.queue(kind, tick, choice)) + return false; + action_check_at_ = {}; + if (kind != CellAction::mutation) + cellular_feed_target_.reset(); + return true; + } + [[nodiscard]] bool restart_cellular() { + if (!cellular_trial_ || !cellular_play_.restart()) + return false; + cellular_feed_target_.reset(); + birth_check_at_ = {}; + return true; + } + void keep_cellular_unknown() { + cellular_play_.keep_unknown(); + } + void set_cellular_controls(CellularControls controls) { + cellular_controls_ = controls; + } void set_cellular_feed_target( std::optional> target) noexcept { cellular_feed_target_ = target; } + [[nodiscard]] auto cellular_feed_target() const noexcept { + return cellular_feed_target_; + } [[nodiscard]] RemoteStatus status() const { RemoteStatus s; const bool live = client_ && client_->state() == client::RegionSessionState::established; @@ -329,21 +357,28 @@ class RemoteSession { return; if (!established_) welcome(ui, launcher); - if (cellular_trial_ && !cellular_birth_request_sent_ && - c.request_primitive_life(cellular_birth_request_id_)) - cellular_birth_request_sent_ = true; server_tick_ = c.server_tick(); if (server_tick_ != observed_tick_) { // Every watermark or snapshot tick times the clock. observed_tick_ = server_tick_; clock_.observe(server_tick_, now); } - if (cellular_trial_) - send_cellular(intention); - else - send(intention); receipts(); cellular_results(); snapshot(); + if (cellular_trial_) { + const auto old_life = cellular_play_.life(); + if (const auto& p = c.cellular_perception()) + cellular_play_.observe(*p); + if (const auto& ended = c.life_ended()) + cellular_play_.observe_end(*ended); + cellular_play_.observe_offer(c.mutation_offer()); + if (old_life != cellular_play_.life()) + cellular_feed_target_.reset(); + service_cellular(now); + send_cellular(intention); + } else { + send(intention); + } present(now); if (wanted_ && (!sent_interest_ || *wanted_ != *sent_interest_) && now - interest_at_ >= std::chrono::milliseconds{250} && c.set_interest(*wanted_)) { @@ -413,7 +448,7 @@ class RemoteSession { return false; client::RegionSessionClientConfig config; if (cellular_trial_) - config.protocol_version = network::session_protocol_v9; + config.protocol_version = network::session_protocol_v10; const auto route = routes_.find(target_region_); config.transport = route != routes_.end() ? route->second : transport_; if (ticket_) { // A handoff: the ticket replaces a grant, once. @@ -462,7 +497,10 @@ class RemoteSession { backoff_ = std::min(backoff_ * 2, std::chrono::seconds{30}); } void welcome(client::UiState& ui, client::Launcher& launcher) { - const auto& w = *client_->welcome(); + const auto& welcome_message = client_->welcome(); + if (!welcome_message) + return; + const auto& w = *welcome_message; established_ = true; welcomed_ = true; backoff_ = std::chrono::seconds{2}; @@ -486,6 +524,8 @@ class RemoteSession { markers_.clear(); observed_tick_ = 0; stale_view_ = false; + cellular_play_.connected(); + action_check_at_ = birth_check_at_ = {}; launcher.observe(client::ConnectSignal::welcome); notify(ui, "Connected to the dev region (fresh baseline).", client::NoticeLevel::info); std::printf("session welcome session=%llu epoch=%llu tick=%llu\n", @@ -521,15 +561,49 @@ class RemoteSession { } void send_cellular(const client::Intention& intention) { if (server_tick_ == 0 || (sent_tick_ && server_tick_ <= *sent_tick_) || - next_cellular_action_id_ == 0) + !cellular_play_.fresh() || cellular_play_.life() == 0 || cellular_play_.ended()) return; const auto tick = server_tick_ + 1; - if (!client_->send_cellular_action(next_cellular_action_id_, tick, intention.move_x, - intention.move_y, cellular_feed_target_)) + const auto steering = steer_cellular(cellular_controls_, intention, cellular_perception(), + organisms_.current(), cellular_feed_target_); + cellular_feed_target_ = steering.patch; + const auto id = cellular_play_.allocate_id(); + if (id == 0 || + !client_->send_cellular_action(id, tick, steering.intention.move_x, + steering.intention.move_y, cellular_feed_target_)) return; - ++next_cellular_action_id_; sent_tick_ = server_tick_; } + void service_cellular(Clock::time_point now) { + if (cellular_play_.birth_pending() && now >= birth_check_at_) { + if (client_->request_primitive_life(cellular_play_.birth_request())) + birth_check_at_ = now + std::chrono::seconds{2}; + } + const auto& pending = cellular_play_.pending(); + if (!pending || now < action_check_at_) + return; + const auto& p = *pending; + cellular_play_.rechecking(); // A refused retry cannot settle a lost original reply. + bool sent = false; + if (p.kind == CellAction::mutation) { + sent = client_->send_cellular_mutation(p.id, p.tick, p.choice.life, p.choice.event, + p.choice.offer_tick, p.choice.operator_id); + } else if (p.state == CellActionState::queued) { + if (p.tick > server_tick_ + 1) + return; // Do not replace a movement/feeding intention already sent this tick. + sent = client_->send_cellular_action( + p.id, p.tick, 0, 0, {}, p.kind == CellAction::engulf, p.kind == CellAction::bud); + if (sent) + sent_tick_ = server_tick_; // The discrete intention owns this tick's target. + } else { + sent = client_->query_action(p.id); // A query can never bud a second time. + } + if (sent) { + if (p.state == CellActionState::queued) + cellular_play_.sent(); + action_check_at_ = now + std::chrono::seconds{2}; + } + } void cellular_results() { for (const auto& receipt : client_->take_primitive_life_receipts()) if (receipt.status != network::AdmitStatus::admitted) @@ -537,6 +611,9 @@ class RemoteSession { std::to_string(static_cast(receipt.status)) + ")"; for (const auto& outcome : client_->take_primitive_life_outcomes()) { + if (outcome.request_id != cellular_play_.birth_request()) + continue; + cellular_play_.birth(outcome); switch (outcome.result) { case network::PrimitiveLifeResult::born: cellular_action_status_ = @@ -559,15 +636,18 @@ class RemoteSession { break; case network::PrimitiveLifeResult::unknown: cellular_action_status_ = "Birth outcome is unknown; retrying exact request"; - cellular_birth_request_sent_ = false; break; } } - for (const auto& receipt : client_->take_action_receipts()) + for (const auto& receipt : client_->take_action_receipts()) { + cellular_play_.receipt(receipt); if (receipt.status != network::AdmitStatus::admitted) cellular_action_status_ = cellular_admission_message(receipt.status); - for (const auto& outcome : client_->take_action_outcomes()) + } + for (const auto& outcome : client_->take_action_outcomes()) { + cellular_play_.outcome(outcome); cellular_action_status_ = cellular_outcome_message(outcome.result, outcome.tick); + } } void receipts() { for (const auto& r : client_->take_intention_receipts()) { @@ -716,7 +796,8 @@ class RemoteSession { stale_view_ = was_established || stale_view_; predictor_.reset(); // The marker ended with its session. client_.reset(); - cellular_birth_request_sent_ = false; + cellular_play_.disconnected(); + cellular_feed_target_.reset(); established_ = false; // A crossing or a redirect is followed at once: no grant for a handoff, no pause. if (reason == SessionCloseReason::handed_off && offer && learn_route(offer->destination)) { @@ -809,10 +890,11 @@ class RemoteSession { bool established_{}, welcomed_{}, exhausted_{}; bool following_{true}; // The camera follows the server's (default) view. bool cellular_trial_{}; - std::uint64_t next_cellular_action_id_{}, cellular_birth_request_id_{}; + CellularPlay cellular_play_; + CellularControls cellular_controls_; + Clock::time_point action_check_at_{}, birth_check_at_{}; std::optional> cellular_feed_target_; std::string cellular_action_status_; - bool cellular_birth_request_sent_{}; }; #else inline constexpr bool remote_available = false; @@ -839,8 +921,23 @@ class RemoteSession { [[nodiscard]] const std::string& cellular_action_status() const noexcept { return action_status_; } + [[nodiscard]] const CellularPlay& cellular_play() const noexcept { + return cellular_play_; + } + [[nodiscard]] bool request_cellular(CellAction, MutationChoice = {}) { + return false; + } + [[nodiscard]] bool restart_cellular() { + return false; + } + void keep_cellular_unknown() {} + void set_cellular_controls(CellularControls) {} void set_cellular_feed_target(std::optional>) noexcept { } + [[nodiscard]] std::optional> + cellular_feed_target() const noexcept { + return {}; + } [[nodiscard]] RemoteStatus status() const { RemoteStatus status; status.phase = "unavailable in this build"; @@ -857,6 +954,7 @@ class RemoteSession { client::Launcher&) {} private: + CellularPlay cellular_play_; std::string action_status_; client::EnvironmentLayer environment_; client::OrganismLayer organisms_; diff --git a/cmake/ClientProbe.cmake b/cmake/ClientProbe.cmake index dcdb3a0..01ef675 100644 --- a/cmake/ClientProbe.cmake +++ b/cmake/ClientProbe.cmake @@ -122,6 +122,7 @@ if(EVO_BUILD_CLIENT) evo_owned_target(evo-client-organism-tests) add_test(NAME client-organisms COMMAND evo-client-organism-tests) add_executable(evo-client-ui-model-tests tests/client_ui_model.cpp) + target_include_directories(evo-client-ui-model-tests PRIVATE "${PROJECT_SOURCE_DIR}/apps/evo-client") target_link_libraries(evo-client-ui-model-tests PRIVATE evo_client_ui) evo_owned_target(evo-client-ui-model-tests) add_test(NAME client-ui-model COMMAND evo-client-ui-model-tests) diff --git a/docs/STATUS.md b/docs/STATUS.md index 796ee0a..c4f17b6 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -1,5 +1,15 @@ # Project status and next steps +## Client update - 2026-10-14 (v10) + +The desktop cellular client now negotiates v10, exposes mutations with funded +costs, engulf/bud feedback, reserves, death and restart, and retains unresolved +requests through reconnect. Automatic feeding, adjustable/precision steering, +food approach assistance and a responsive teal interface address playtest +usability. See [CLIENT](engineering/CLIENT.md) and the validation entry for +checks and remaining live-play/hardware qualification. No deployment or world +state change is part of this client update. + ## Current gate - 2026-10-11 (M11.3 exploratory probe) The maintainer reports that the Git checks passed, `evo-region` is running, and diff --git a/docs/engineering/CLIENT.md b/docs/engineering/CLIENT.md index 9e464e3..0e7f911 100644 --- a/docs/engineering/CLIENT.md +++ b/docs/engineering/CLIENT.md @@ -2,8 +2,9 @@ This opens a resizable native window showing camera-controlled environment habitats and organisms either from a local in-memory fixture authority or from one dev -region over an authenticated dev session. It does not run an ecosystem locally, -predict remote state or implement cellular gameplay. +region over an authenticated dev session. Cellular play uses the authoritative +v10 server; the client presents observations and sends intentions. The separate +engineering motion probe predicts only its synthetic marker. Contract: [client architecture](../architecture/CLIENT_ARCHITECTURE.md), ADR-0078. Camera/input: [contracts and limits](CAMERA_INPUT.md), ADR-0079. Environment: [presentation and encodings](ENVIRONMENT_RENDERING.md), ADR-0080. @@ -28,6 +29,69 @@ short notifications expire and can be dismissed. ## Build and run +### Cellular v10 + +Choose **Cellular play (v10)** before connecting, or add `--cellular` to the +connection command. For the current M11.9 DEV opening use grants for world 100, +region 4 and fresh playtest accounts (ADR-0123). The client does not deploy or +provision a region. + +- **Cell:** energy and C/N/P/other reserves, latest maintenance/movement/intake, + and Engulf/Bud buttons. Engulf and Bud are individual requests; automatic feeding + resumes after their action tick. The server chooses prey and funds/places descendants. Last observed + engulf/bud feedback stays visible with its tick, even after later idle ticks. +- **Food:** automatic feeding defaults on and targets the first stocked, contacted + patch in the owner's ordered view. Manual selection disables auto-feed; Stop + feeding disables it too. Speed (1-100%), precision (20% of selected speed), and + Slow near food are local intention preferences. The latter defaults on and limits + approach speed toward 500 um/s within 1 mm of a stocked patch, recomputed from the + observed phenotype. Protocol integer precision can exceed that cap at extreme + speeds. These preferences never change authoritative speed, contact or intake. +- **Evolution:** choose one unranked mutation from the owner's earned offer. + The current development-2 cellular trial uses per-second capability rates and + maintenance; mass is in femtograms. Plain-language descriptions explain each + capability change. Construction energy and all four matter costs use the amended + v10 candidate records (ADR-0129); choices are disabled when current reserves cannot + fund them. The server rechecks funding when the request commits. +- **Life ended:** the server's cause, when delivered, and **Start new life**. + Each new life uses a new request ID. Duplicate clicks and reconnects reuse the + outstanding request, and held world input is cleared while no current life is + available. A missing view alone is never presented as a known death. +- **Log:** the last eight discrete requests and optional engineering panels. + Sent/admitted are distinct from committed. A committed engulf/bud intention + does not itself prove biological success; the tick feedback reports its effect. + +The dark teal UI uses the existing embedded scalable font. At narrow sizes the +Evolution panel becomes the **Life** tab; panels remain within the viewport and +scroll vertically. Existing Ctrl+= / Ctrl+- scaling and rebindable movement apply. +Food patches have a thin contact boundary and a stock marker, with amber for the +current target and dimming while disconnected. The camera starts at a closer 6 mm +view and keeps the followed cell beside the journal. Organism shapes and biological +colour encodings remain those of ADR-0081 for every controller. + +One discrete request is outstanding at a time. During an automatic reconnect its +ID and original payload stay in memory. Bud/engulf recovery queries the original +action; mutation recovery repeats the exact selection. A lost reply remains +unresolved until an authoritative final result arrives. **Keep result as unknown** +retains it in the bounded record and permits another explicit request; it does +not cancel the original. Request history is not persisted across app exit or an +explicit disconnect to the launcher. + +Existing protocol limits: a mutation result lost across a server restart may +remain unresolved (the host's final-choice replay cache is transient); type 27 +death notices are not a historical death query. Automatic feeding uses observed +contact, so a patch crossed entirely between observations can still be missed; +slowing near food reduces that risk without predicting authority. + +Coordinate contract discrepancy found during this work: the cellular bridge sends +ADR-0102 lower-left footprint coordinates through the general presentation's +centre-offset fields. Assistance deliberately interprets only cellular-session +coordinates as the bridge sends them. Renderer/bridge geometry changes are deferred: +a future scoped contract amendment should either carry an explicit coordinate +convention or consistently convert the cellular presentation to centres, updating +contact assistance, picking and replication tests together. This upgrade does not +silently change the shared organism geometry contract. + After [explicit SDL preparation](CLIENT_DEPENDENCIES.md), in a compiler shell: ```sh diff --git a/docs/engineering/CLIENT_UI_STATE.md b/docs/engineering/CLIENT_UI_STATE.md index 43ce9b3..630df96 100644 --- a/docs/engineering/CLIENT_UI_STATE.md +++ b/docs/engineering/CLIENT_UI_STATE.md @@ -1,5 +1,41 @@ # M9.8b/c UI state, launcher and event bounds +## Cellular v10 application state + +`apps/evo-client/cellular_play.hpp` owns toolkit-independent presentation state: +the current owner life/offer, latest death notice, one outstanding discrete action, +and at most eight completed or unresolved records. It never changes biology. +Receipts are admission only; outcomes settle a request. A refused retry cannot +disprove a lost original reply. Mutation `not_ready` may mean an uncertain durable +reservation, so it remains unresolved. IDs never wrap; stale offers, dead lives, +unfresh sessions and duplicate clicks cannot submit new choices. + +Reconnect drops the offer until a fresh owner view, cancels unsent queued actions, +and retains sent requests for reconciliation. Life changes cannot carry a queued +action to the new life. Delayed final replies can update retained unknown records. +New lives receive new birth request IDs; retries of an outstanding birth keep its +ID. Death messages are deduplicated so a retained notice cannot end a later life. +Meaningful engulf/bud diagnostics retain their observed tick and reset on life +change. UI does not infer action success from a receipt, empty view or vanished offer. + +`cellular_controls.hpp` selects only stocked patches in observed contact, scales +movement intentions for speed/precision/food assistance, and compares every mutation +cost channel with the displayed reserve. `cellular_scene.hpp` renders each patch +in at most three clipped rectangles; the application reserves that worst-case +budget before drawing organisms. No dependency or simulation rule changes. + +The v10 panels consume this state and return actions; the app owns session sends. +Cell/Food/Log tabs and a separate Evolution panel replace the default engineering +panels in cellular mode. A narrow viewport moves evolution to a Life tab. Log can +show the existing engineering panels. The existing platform adapter owns the +palette, rounded geometry, embedded font and input capture. `client-ui-model`, +`client-remote-session` and `client-panels` exercise state, loopback v10 delivery, +production widget clicks, duplicate suppression and bounded layout under NDEBUG. + +`evo-client-panel-tests OUTPUT_DIRECTORY` additionally saves actual rendered +review BMPs at 640x480, 960x640 and 1280x800, including the death screen; those use +explicit test presentation values and are not evidence of a live DEV playtest. + Owned, toolkit-independent state; all calls on the client main thread. No authority or simulation state. Time is explicit monotonic milliseconds supplied by the host. diff --git a/docs/engineering/M11_8_DELIVERY_PLAN.md b/docs/engineering/M11_8_DELIVERY_PLAN.md index 3f544e1..cba72d8 100644 --- a/docs/engineering/M11_8_DELIVERY_PLAN.md +++ b/docs/engineering/M11_8_DELIVERY_PLAN.md @@ -28,8 +28,9 @@ outcomes. The UI adds a responsive cellular HUD and dark teal theme using the existing toolkit/font. See [CLIENT](CLIENT.md) for operation and protocol limits. Human accessibility/hardware checks and first-session/repeated-life observations -remain. Existing v10 signals do not provide detailed engulf refusals, full mutation -prices, or historical death/result recovery across every server restart. +remain. The amended v10 signals now display detailed engulf refusals and mutation +prices, with affordability checks. Historical death/result recovery across every +server restart remains a protocol limitation. ## Progress diff --git a/docs/engineering/VALIDATION.md b/docs/engineering/VALIDATION.md index 8ef9ddb..f4bf50e 100644 --- a/docs/engineering/VALIDATION.md +++ b/docs/engineering/VALIDATION.md @@ -7494,3 +7494,38 @@ Executed locally: MSVC Debug 69/69, network 75/75, client-network protocol/QUIC/ session/cellular 15/15 (`evo-client.exe` was in use and not relinked); the WSL PostgreSQL C++ suite; g++-14 `-Werror -Wshadow` and clang-tidy-19 on the changed sources and server main; clang-format 19.1.5. + +## 2026-10-14 — desktop v10 play flow and presentation + +Client-only integration of ADR-0121/0125/0127/0129, including the amended 64-byte +mutation candidates: choice costs/affordability, per-channel reserves, latched +engulf/bud diagnostics, death and restart. Discrete requests preserve their exact +identity through reconnect and keep uncertain results explicit. Automatic feeding +and speed/precision/food assistance send bounded intentions only. Responsive teal +panels, closer framing and three-rectangle food patches use existing dependencies. + +Executed locally: +- MSVC Release/NDEBUG `tools/windows-check.ps1 -Preset client-package -Action check`: + 17/17 passed (117.56 s), including v6-v10 codec, QUIC sessions, remote-session + recovery, production panel interaction and client smoke/lifecycle checks. +- WSL Ubuntu Clang 19 Release warnings-as-errors build of the client and changed + tests; `ctest --test-dir build/tidy-client-network -R + 'client-(ui-model|panels|remote-session)' --output-on-failure`: 3/3 (37.96 s). +- Clang 19 ASan/UBSan `client-asan`: UI model, panels and lifecycle 3/3 (27.21 s). +- clang-tidy-19 on changed client translation units, with app headers included: + no owned-code findings; the final model/panel rerun also passed. +- Repository `format-check` with clang-format 19 and `git diff --check` passed. +- Production SDL/ImGui panels rendered with explicit test observations at 640x480, + 960x640 and 1280x800, plus death screen. Screenshots inspected in + `build/v10-review`; UI tests cover mutation/bud/restart clicks, disabled + unaffordable choices, duplicate suppression, clipping and scroll bounds. + +Limits: these are loopback and synthetic presentation checks, not a live DEV +playtest or hardware/DPI/accessibility qualification. The existing client-network +executable was locked by running client sessions; those were left running and the +separate client-package preset validated the Windows executable. Initial sandboxed +Ninja subprocess startup required rerunning the authorized build outside the +sandbox. No new dependency, simulation version/golden, deployment or World0 change. +The existing cellular lower-left versus general presentation centre-coordinate +discrepancy and proposed scoped resolution are recorded in CLIENT.md; shared +organism geometry was not expanded as part of this gate. diff --git a/docs/playtests/M11_9_REPEATED_LIFE_PLAYTEST.md b/docs/playtests/M11_9_REPEATED_LIFE_PLAYTEST.md index 127062f..e2b7300 100644 --- a/docs/playtests/M11_9_REPEATED_LIFE_PLAYTEST.md +++ b/docs/playtests/M11_9_REPEATED_LIFE_PLAYTEST.md @@ -10,9 +10,10 @@ trial value (ADR-0098, ADR-0120, ADR-0124, ADR-0125, ADR-0128). - A DEV region provisioned with the `cellular-v4` opening (rules 5: engulfment, detritus, budding wildlife, offline freeze) on a server image that passed CI. - An engineering client with the v10 path: movement, feeding, engulf, bud, the - mutation offer and chooser, and the death and restart flow. Those screens are the - maintainer's (M11.8 client half); a session without them tests less, and the - notes must say which were present. + mutation offer and chooser, and the death and restart flow. These screens are now + implemented (see CLIENT.md), including amended v10 costs and engulf reasons. + Record the client build and steering/feeding assistance settings; older clients + test less, and the notes must say which screens were present. - A fresh grant bundle per participant (`renew-dev-m10.sh` output) and a three-hour session window. diff --git a/src/client/platform/application.cpp b/src/client/platform/application.cpp index c8e77a1..37c6058 100644 --- a/src/client/platform/application.cpp +++ b/src/client/platform/application.cpp @@ -46,6 +46,37 @@ struct Toolkit { // scales with the window, which the bitmap font cannot do cleanly. if (io.Fonts->AddFontDefaultVector() == nullptr) return false; + auto& style = ImGui::GetStyle(); + style.WindowRounding = 12; + style.ChildRounding = 8; + style.FrameRounding = 6; + style.PopupRounding = 8; + style.GrabRounding = 6; + style.WindowPadding = {16, 14}; + style.FramePadding = {10, 6}; + style.ItemSpacing = {8, 9}; + auto* colors = style.Colors; + colors[ImGuiCol_WindowBg] = {0.035F, 0.065F, 0.085F, 0.97F}; + colors[ImGuiCol_ChildBg] = {0.055F, 0.095F, 0.12F, 0.9F}; + colors[ImGuiCol_PopupBg] = {0.045F, 0.08F, 0.10F, 1.0F}; + colors[ImGuiCol_Border] = {0.18F, 0.31F, 0.34F, 0.65F}; + colors[ImGuiCol_Text] = {0.88F, 0.94F, 0.93F, 1.0F}; + colors[ImGuiCol_TextDisabled] = {0.52F, 0.66F, 0.68F, 1.0F}; + colors[ImGuiCol_FrameBg] = {0.10F, 0.18F, 0.21F, 1.0F}; + colors[ImGuiCol_FrameBgHovered] = {0.15F, 0.28F, 0.31F, 1.0F}; + colors[ImGuiCol_FrameBgActive] = {0.18F, 0.35F, 0.36F, 1.0F}; + colors[ImGuiCol_Button] = {0.10F, 0.30F, 0.28F, 1.0F}; + colors[ImGuiCol_ButtonHovered] = {0.16F, 0.45F, 0.38F, 1.0F}; + colors[ImGuiCol_ButtonActive] = {0.20F, 0.55F, 0.44F, 1.0F}; + colors[ImGuiCol_Header] = {0.10F, 0.26F, 0.28F, 1.0F}; + colors[ImGuiCol_HeaderHovered] = colors[ImGuiCol_ButtonHovered]; + colors[ImGuiCol_HeaderActive] = colors[ImGuiCol_ButtonActive]; + colors[ImGuiCol_TitleBg] = {0.04F, 0.09F, 0.12F, 1.0F}; + colors[ImGuiCol_TitleBgActive] = {0.08F, 0.20F, 0.22F, 1.0F}; + colors[ImGuiCol_CheckMark] = {0.40F, 0.88F, 0.68F, 1.0F}; + colors[ImGuiCol_Tab] = {0.08F, 0.17F, 0.20F, 1.0F}; + colors[ImGuiCol_TabSelected] = {0.12F, 0.32F, 0.31F, 1.0F}; + colors[ImGuiCol_TabHovered] = colors[ImGuiCol_ButtonHovered]; base_style = ImGui::GetStyle(); platform = ImGui_ImplSDL3_InitForSDLRenderer(window, target); return platform && attach_renderer(target); diff --git a/tests/client_lifecycle.cpp b/tests/client_lifecycle.cpp index 8402c6a..f21f9eb 100644 --- a/tests/client_lifecycle.cpp +++ b/tests/client_lifecycle.cpp @@ -286,13 +286,15 @@ void toolkit_capture() { int presses = 0; bool text_focus = false; std::array text{}, field{}; - ImVec2 field_min{}, field_max{}; + ImVec2 field_min{}, field_max{}, button_centre{}; app->set_overlay([&] { ImGui::SetNextWindowPos({0, 0}, ImGuiCond_Always); - ImGui::SetNextWindowSize({150, 150}, ImGuiCond_Always); + ImGui::SetNextWindowSize({180, 190}, ImGuiCond_Always); ImGui::Begin("panel", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize); if (ImGui::Button("Press", {130, 40})) ++presses; + const auto button_min = ImGui::GetItemRectMin(), button_max = ImGui::GetItemRectMax(); + button_centre = {(button_min.x + button_max.x) / 2, (button_min.y + button_max.y) / 2}; ImGui::InputText("field", field.data(), field.size()); field_min = ImGui::GetItemRectMin(); field_max = ImGui::GetItemRectMax(); @@ -331,7 +333,7 @@ void toolkit_capture() { // Over the widget: the button activates once, the world sees no click. // The panel exists before the user clicks (as every application panel does). CHECK(app->present(frame) == Step::rendered && app->present(frame) == Step::rendered); - CHECK(!click(60, 30) && presses == 1 && app->ui_wants_pointer()); + CHECK(!click(button_centre.x, button_centre.y) && presses == 1 && app->ui_wants_pointer()); // Open world: a click is delivered once, then consumed. const auto world = click(260, 200); CHECK(world && world->x == 260 && world->y == 200 && presses == 1); @@ -347,9 +349,9 @@ void toolkit_capture() { // nothing and the widget still activates on the toolkit's next frames. mouse(SDL_EVENT_MOUSE_MOTION, 260, 200); CHECK(app->poll_events() && app->present(frame) == Step::rendered && !app->ui_wants_pointer()); - mouse(SDL_EVENT_MOUSE_MOTION, 60, 30); - mouse(SDL_EVENT_MOUSE_BUTTON_DOWN, 60, 30); - mouse(SDL_EVENT_MOUSE_BUTTON_UP, 60, 30); + mouse(SDL_EVENT_MOUSE_MOTION, button_centre.x, button_centre.y); + mouse(SDL_EVENT_MOUSE_BUTTON_DOWN, button_centre.x, button_centre.y); + mouse(SDL_EVENT_MOUSE_BUTTON_UP, button_centre.x, button_centre.y); CHECK(app->poll_events() && !app->take_navigation().click); for (int i = 0; i < 5 && presses == 1; ++i) CHECK(app->present(frame) == Step::rendered && app->poll_events()); diff --git a/tests/client_panels.cpp b/tests/client_panels.cpp index 8c91123..79cc846 100644 --- a/tests/client_panels.cpp +++ b/tests/client_panels.cpp @@ -2,8 +2,10 @@ // software renderer, pinned toolkit). Notices fit their fixed-width window with a // visible close button; clicking it (move + press + release in one batch, no settling // frame) dismisses exactly that notice and never reaches the world. +#include "cellular_scene.hpp" #include "controls_flow.hpp" #include "evo/client/application.hpp" +#include "evo/render/organism.hpp" #include "panels.hpp" #include #include @@ -25,6 +27,11 @@ void check(bool ok, std::source_location at = std::source_location::current()) { throw std::runtime_error("client panels line " + std::to_string(at.line())); } #define CHECK(...) check(static_cast(__VA_ARGS__)) +template const T& required(const std::optional& value) { + if (!value) + throw std::runtime_error("missing panel test value"); + return *value; +} SDL_Window* window() { int count{}; SDL_Window** windows = SDL_GetWindows(&count); @@ -349,12 +356,171 @@ void apply_save_restart() { CHECK(intention && intention->move_x == -1000); std::filesystem::remove_all(dir); } +void cellular_panels(const std::filesystem::path& review) { + for (const auto size : {std::pair{960, 640}, std::pair{1280, 800}, std::pair{640, 480}}) { + const auto [width, height] = size; + auto opened = Application::open({width, height, false, "software"}); + CHECK(opened); + auto app = std::move(*opened); + const auto id = SDL_GetWindowID(window()); + SDL_Event focus{}; + focus.type = SDL_EVENT_WINDOW_FOCUS_GAINED; + focus.window.windowID = id; + CHECK(SDL_PushEvent(&focus) && app->poll_events()); + std::vector boxes{ + {0, 0, static_cast(width), static_cast(height), {8, 19, 25, 255}}}; + const auto camera = + Camera::create({width, height, width, height}, {width < 880 ? 0.29 : 2.1, 3.29}, 100); + CHECK(camera); + for (int x = 0; x < 5; ++x) + for (int y = 0; y < 6; ++y) { + const auto low = + camera->world_to_screen({static_cast(x), static_cast(y)}); + const auto high = camera->world_to_screen({x + 1.0, y + 1.0}); + CHECK(low && high); + patch_box(boxes, *low, *high, (x + y) % 4 != 0, x == 2 && y == 3, width, height); + } + OrganismCell organism; + organism.id = 901; + organism.x = {2200}; + organism.y = {3200}; + organism.phenotype.extent = 300; + organism.phenotype.total_mass = 10000; + organism.phenotype.structural_mass = 9000; + organism.phenotype.membrane_mass = 1000; + organism.phenotype.conversion_per_thousand = 650; + organism.phenotype.movement_speed = 500; + organism.phenotype.ingestion_rate = 400; + organism.growth.realized_per_thousand = 1000; + const auto population = + OrganismPresentation::create({{100, 1}, 102, 1}, 0, std::array{organism}); + CHECK(population); + CHECK(render::append_organisms(boxes, 100, &*population, Freshness::current, *camera)); + const auto frame = render::Frame::create(boxes); + CHECK(frame); + UiState ui; + Launcher launch; + Selection selection; + EnvironmentLayer environment; + OrganismLayer organisms; + CellularPlay play; + play.initialize(100); + play.connected(); + network::CellularLifeDiagnostics diagnostics; + diagnostics.reserve_energy_pj = 248000; + diagnostics.reserve_matter_fg = {15000, 2400, 800, 6000}; + diagnostics.has_tick_effects = true; + diagnostics.maintenance_cost_pj = 80; + diagnostics.movement_cost_pj = 20; + diagnostics.movement = network::CellularMovementResult::moved; + diagnostics.intake = network::CellularIntakeResult::acquired; + diagnostics.engulf = network::CellularEngulfResult::membrane_too_thick; + network::CellularPerception perception{ + 102, 901, {{1000, 2000, 50000, {100, 20, 10, 40}}}, diagnostics}; + play.observe(perception); + play.observe_offer(network::CellularMutationOffer{ + 102, + 901, + 1, + 100, + {{3, 2, 0, 500, 1600, 22000, 1200, {100, 20, 10, 40}}, + {5, 1, 0, 2, 2000, 26000, 5000, {500, 80, 20, 120}}, + {8, 3, 0, 400, 1800, 24000, 300000, {400, 60, 20, 100}}}}); + FormBuffers form; + render::EnvironmentDisplay display; + PanelView view; + view.mode = Mode::remote; + view.launcher = &launch; + view.environment = &environment; + view.organisms = &organisms; + view.selection = &selection; + view.ui = &ui; + view.bindings = &app->bindings(); + view.cellular_perception = &perception; + view.cellular_play = &play; + view.remote.emplace(); + view.remote->phase = "connected"; + view.remote->cellular_trial = true; + view.remote->server_tick = 102; + view.remote->region = 4; + PanelActions action; + app->set_overlay([&] { action = draw_panels(view, form, display); }); + const auto draw = [&] { + CHECK(app->poll_events() && app->present(*frame) == Step::rendered); + }; + for (int i = 0; i < 3; ++i) + draw(); + const auto* journal = ImGui::FindWindowByName("Cellular field journal"); + CHECK(journal && journal->Active && journal->ScrollMax.x == 0); + CHECK(journal->Pos.x >= 0 && journal->Pos.y >= 0 && + journal->Pos.x + journal->Size.x <= static_cast(width) && + journal->Pos.y + journal->Size.y <= static_cast(height)); + if (!review.empty()) { + std::filesystem::create_directories(review); + CHECK(app->request_screenshot( + (review / ("cellular-" + std::to_string(width) + ".bmp")).string())); + draw(); + } + if (width != 960) + continue; + const auto* evolution = ImGui::FindWindowByName("Evolution"); + CHECK(evolution && evolution->Active && evolution->ScrollMax.x == 0); + CHECK(evolution->Pos.x >= journal->Pos.x + journal->Size.x && + evolution->Pos.x + evolution->Size.x <= static_cast(width)); + // Click the first production choice. Pointer ownership prevents world selection. + const auto probe = [&](const ImGuiWindow* panel, float x_fraction, const auto& done) { + const float x = panel->Pos.x + panel->Size.x * x_fraction; + for (int offset = 90; static_cast(offset) < panel->Size.y - 10; offset += 5) { + const float y = panel->Pos.y + static_cast(offset); + mouse(id, SDL_EVENT_MOUSE_MOTION, x, y); + mouse(id, SDL_EVENT_MOUSE_BUTTON_DOWN, x, y); + mouse(id, SDL_EVENT_MOUSE_BUTTON_UP, x, y); + CHECK(app->poll_events() && !app->take_navigation().click); + for (int i = 0; i < 3; ++i) { + CHECK(app->present(*frame) == Step::rendered && app->poll_events()); + if (done()) + return true; + } + } + return false; + }; + auto depleted = diagnostics; + depleted.reserve_energy_pj = 0; + perception.diagnostics = depleted; + draw(); + CHECK(!probe(evolution, 0.5F, [&] { return action.mutation.has_value(); })); + perception.diagnostics = diagnostics; + draw(); + CHECK(probe(evolution, 0.5F, [&] { return action.mutation.has_value(); })); + CHECK(action.mutation == MutationChoice{901, 1, 100, 3}); + CHECK(play.queue(CellAction::mutation, 102, required(action.mutation))); + const auto mutation_id = required(play.pending()).id; + draw(); + CHECK(!probe(evolution, 0.5F, [&] { return action.mutation.has_value(); })); + play.outcome({mutation_id, network::ActionResult::committed, 103, 5}); + draw(); + CHECK(probe(journal, 0.75F, [&] { return action.cell_action == CellAction::bud; })); + play.observe_end({104, 901, network::CellularDeathReason::engulfed}); + perception = {104, 0, {}, {}}; + play.observe(perception); + draw(); + if (!review.empty()) { + CHECK(app->request_screenshot((review / "cellular-death.bmp").string())); + draw(); + } + CHECK(probe(evolution, 0.5F, [&] { return action.restart_life; })); + CHECK(play.restart()); + draw(); + CHECK(!probe(evolution, 0.5F, [&] { return action.restart_life; })); + } +} } // namespace -int main() try { +int main(int argc, char** argv) try { notices(); controls_panel(); apply_save_restart(); + cellular_panels(argc == 2 ? std::filesystem::path{argv[1]} : std::filesystem::path{}); std::puts("client panel tests passed"); return 0; } catch (const std::exception& e) { diff --git a/tests/client_remote_session.cpp b/tests/client_remote_session.cpp index d2f8dda..510d8f9 100644 --- a/tests/client_remote_session.cpp +++ b/tests/client_remote_session.cpp @@ -36,6 +36,11 @@ void check(bool ok, std::source_location at = std::source_location::current()) { throw std::runtime_error("client remote session line " + std::to_string(at.line())); } #define CHECK(...) check(static_cast(__VA_ARGS__)) +template const T& required(const std::optional& value) { + if (!value) + throw std::runtime_error("missing remote client test value"); + return *value; +} constexpr std::string_view name = "dev-region.evolution.test"; constexpr world::WorldIdentity world_id{7, 3}; constexpr std::uint64_t region = 12; @@ -97,7 +102,9 @@ client::EnvironmentCell cell(std::int64_t x, std::int64_t y, std::uint64_t quant // A region on loopback with a 21 x 21 slice (x, y in -10..10 at z -7), one snapshot per tick. struct Region { - explicit Region(const Files& f) : files{f} { + explicit Region(const Files& f, + const std::function& configure = {}) + : files{f} { server::RegionSessionsConfig c; c.transport.certificate_pem_file = f.certificate.string(); c.transport.key_pem_file = f.key.string(); @@ -107,13 +114,17 @@ struct Region { c.control.epoch = epoch; c.control.max_account_attempts = 16; c.issuer_keys.push_back({1, *key.public_key()}); + if (configure) + configure(c); + const bool cellular = c.accept_cellular_actions; auto made = server::RegionSessions::create(std::move(c)); CHECK(made.has_value()); sessions = std::move(*made); sessions->set_default_interest({3, 3, -7, 7}); // Probe markers (ADR-0094) over the slice's cells, spawning in the middle of (3, 3). - CHECK(sessions->set_motion_area({-10'000'000, -10'000'000, 10'999'999, 10'999'999, -7}, - 3'500'000, 3'500'000)); + if (!cellular) + CHECK(sessions->set_motion_area({-10'000'000, -10'000'000, 10'999'999, 10'999'999, -7}, + 3'500'000, 3'500'000)); } WireGrant grant(const AccountId& who, std::uint64_t serial, std::uint64_t in_region = region) const { @@ -153,11 +164,14 @@ struct Region { }); } static_cast(sessions->take_events()); + if (after_poll) + after_poll(); } const Files& files; GrantSigningKey key = *GrantSigningKey::import(DeploymentEnvironment::dev, 1, scalar()); std::unique_ptr sessions; std::uint64_t epoch{3}, tick{100}, replicated{}; + std::function after_poll; }; struct Client { @@ -488,6 +502,145 @@ void crossing_regions(const Files& f) { CHECK(a.phase() == LaunchPhase::failed && world.probes.at(dana).owner == 2); CHECK(db1.claims == region1_claims && db2.claims == region2_claims + 1); } +// Real RemoteSession over QUIC; the fixture records authority answers without simulating biology. +void cellular_v10(const Files& files) { + using namespace evo::client_app; + struct Ledger final : ActionLedger { + std::map records; + std::expected, ActionLedgerError> + find(const AccountId&, std::uint64_t id) override { + return records.contains(id) ? std::optional{records.at(id).outcome} : std::nullopt; + } + std::expected, ActionLedgerError> + find_record(const AccountId&, std::uint64_t id) override { + return records.contains(id) ? std::optional{records.at(id)} : std::nullopt; + } + } ledger; + test::WorldDb world; + test::RegionDb control{world, region}; + std::vector mutations; + std::vector births; + std::uint64_t life = 0, next_life = 901; + bool resolve_mutation = false; + const auto owner = account(0xD0); + Region r{files, [&](server::RegionSessionsConfig& config) { + config.ledger = &control; + config.actions = &ledger; + config.accept_cellular_actions = true; + config.create_primitive_life = [&](const AccountId& a, std::uint64_t generation, + std::uint64_t id) { + CHECK(a == owner && generation != 0); + births.push_back(id); + life = next_life; + return PrimitiveLifeOutcome{id, PrimitiveLifeResult::born, life, 1}; + }; + config.query_primitive_life = config.create_primitive_life; + config.select_cellular_mutation = [&](const AccountId& a, std::uint64_t generation, + const CellularMutationAction& m) { + CHECK(a == owner && generation != 0); + mutations.push_back(m); + return server::CellularMutationAnswer{ + resolve_mutation ? AdmitStatus::duplicate : AdmitStatus::admitted, 102, + resolve_mutation ? std::optional{ActionOutcome{ + m.action_id, ActionResult::committed, 102, 3}} + : std::nullopt}; + }; + }}; + std::uint64_t sent_view{}, view_session{}, sent_life{}; + bool offer = true; + r.after_poll = [&] { + const auto session = r.sessions->holder(owner); + if (!session || (sent_view == r.tick && view_session == *session && sent_life == life)) + return; + sent_view = r.tick; + view_session = *session; + sent_life = life; + CHECK(r.sessions->send_cellular_perception( + owner, + {r.tick, life, {}, life ? std::optional{CellularLifeDiagnostics{}} : std::nullopt})); + if (offer && life != 0) + CHECK(r.sessions->send_mutation_offer(owner, + {r.tick, life, 1, 99, {{3, 2, 0, 50, 20, 30}}})); + }; + Client c; + CHECK(c.host.connect( + RemoteSession::open(r.material({r.grant(owner, 1), r.grant(owner, 2)}), true))); + CHECK(c.until(r, [&] { return c.host.session()->cellular_play().offer().has_value(); })); + auto& remote = *c.host.session(); + CHECK(!births.empty() && remote.cellular_play().life() == 901); + CHECK(remote.request_cellular(CellAction::mutation, {901, 1, 99, 3})); + CHECK(!remote.request_cellular(CellAction::mutation, {901, 1, 99, 3})); + CHECK(c.until(r, [&] { + return !mutations.empty() && + required(remote.cellular_play().pending()).state == CellActionState::admitted; + })); + const auto original = mutations.front(); + r.sessions->shutdown(Clock::now()); + CHECK(c.until(r, [&] { return remote.status().phase == "reconnecting"; })); + CHECK(!remote.request_cellular(CellAction::bud)); + resolve_mutation = true; + CHECK(c.until(r, [&] { return !remote.cellular_play().history().empty(); }, 20)); + CHECK(mutations.size() >= 2 && mutations.back().action_id == original.action_id && + mutations.back().life_identity == original.life_identity && + mutations.back().tick == original.tick && + mutations.back().operator_id == original.operator_id && births.size() == 1); + CHECK(remote.cellular_play().history().back().state == CellActionState::committed); + // No patch coordinates or intake accompany a bud; one request creates one carried action. + remote.set_cellular_feed_target({{1000, 2000}}); + CHECK(remote.request_cellular(CellAction::bud)); + CHECK(!remote.cellular_feed_target()); + const auto bud_id = required(remote.cellular_play().pending()).id; + std::optional bud; + CHECK(c.until( + r, + [&] { + for (const auto& carried : r.sessions->carry(r.tick + 1)) + if (carried.action_id == bud_id) + bud = carried; + return bud.has_value(); + }, + 20)); + CHECK(required(bud).cellular_input); + const auto input = decode_cellular_action_input(required(required(bud).cellular_input)); + CHECK(input && input->bud && !input->engulf && !input->has_intake_target); + ledger.records.emplace( + bud_id, DurableActionRecord{{bud_id, ActionResult::committed, required(bud).tick, 4}, + required(bud).cellular_input}); + r.sessions->committed(std::span{&required(bud), 1}, 4); + CHECK(c.until(r, [&] { return !remote.cellular_play().pending(); })); + CHECK(remote.cellular_play().history().back().id == bud_id); + CHECK(remote.request_cellular(CellAction::engulf)); + const auto engulf_id = required(remote.cellular_play().pending()).id; + std::optional engulf; + CHECK(c.until( + r, + [&] { + for (const auto& carried : r.sessions->carry(r.tick + 1)) + if (carried.action_id == engulf_id) + engulf = carried; + return engulf.has_value(); + }, + 20)); + CHECK(required(engulf).cellular_input); + const auto engulf_input = + decode_cellular_action_input(required(required(engulf).cellular_input)); + CHECK(engulf_input && engulf_input->engulf && !engulf_input->bud && + !engulf_input->has_intake_target); + r.sessions->dropped(std::span{&required(engulf), 1}, true); + CHECK(c.until(r, [&] { return !remote.cellular_play().pending(); })); + // Death and a fresh request on the same connection. Repeated UI clicks issue only one. + offer = false; + life = 0; + ++r.tick; + CHECK(r.sessions->send_life_ended(owner, {r.tick, 901, CellularDeathReason::starved})); + CHECK(c.until(r, [&] { return remote.cellular_play().can_restart(); })); + CHECK(required(remote.cellular_play().ended()).cause == CellularDeathReason::starved); + CHECK(remote.restart_cellular() && !remote.restart_cellular()); + next_life = 902; + ++r.tick; + CHECK(c.until(r, [&] { return births.size() == 2 && remote.cellular_play().life() == 902; })); + CHECK(births[0] != births[1] && !remote.cellular_play().ended()); +} } // namespace int main() try { @@ -526,6 +679,7 @@ int main() try { refusals(r); } crossing_regions(files); + cellular_v10(files); std::filesystem::remove_all(files.dir); std::puts("client remote session tests passed"); return 0; diff --git a/tests/client_ui_model.cpp b/tests/client_ui_model.cpp index 7ac983a..066f86e 100644 --- a/tests/client_ui_model.cpp +++ b/tests/client_ui_model.cpp @@ -1,6 +1,9 @@ // M9.8c toolkit-independent UI model: labels keep data states distinct, selection // follows presentations, the launcher bounds credentials and errors, and the outcome // log stays bounded. +#include "cellular_controls.hpp" +#include "cellular_play.hpp" +#include "cellular_scene.hpp" #include "evo/client/labels.hpp" #include "evo/client/launcher.hpp" #include "evo/client/outcome_log.hpp" @@ -25,6 +28,11 @@ void check(bool ok, std::source_location at = std::source_location::current()) { throw std::runtime_error("client UI model line " + std::to_string(at.line())); } #define CHECK(...) check(static_cast(__VA_ARGS__)) +template const T& required(const std::optional& value) { + if (!value) + throw std::runtime_error("missing client model test value"); + return *value; +} constexpr world::WorldIdentity identity{3, 9}; EnvironmentCell cell(std::int64_t x) { @@ -69,6 +77,56 @@ OrganismPresentation organisms(std::vector cells, std::uint64_t ti return std::move(*p); } +void cellular_assistance() { + using namespace client_app; + auto own = organism(42, 980); + own.y = {2000}; + own.phenotype.movement_speed = 10000; + auto population = organisms({own}); + network::CellularPerception view{2, 42, {{1000, 2000, 100, {}}}, {}}; + CellularControls controls; + const Intention diagonal{1, 2, 707, -707}; + auto steering = steer_cellular(controls, diagonal, &view, &population, {}); + CHECK(steering.patch == std::pair{1000, 2000}); + CHECK(steering.intention.move_x == 35 && steering.intention.move_y == -35); + own.x = {979}; + population = organisms({own}); + CHECK(!steer_cellular(controls, diagonal, &view, &population, {}).patch); + controls.slow_near_food = false; + controls.precision = true; + controls.speed_percent = 50; + steering = steer_cellular(controls, diagonal, &view, &population, {}); + CHECK(steering.intention.move_x == 70 && steering.intention.move_y == -70); + controls.auto_feed = false; + CHECK(steer_cellular(controls, {}, &view, &population, {{9000, 9000}}).patch == + std::pair{9000, 9000}); + controls.auto_feed = true; + view.patches[0].energy_pj = 0; + own.x = {1000}; + population = organisms({own}); + CHECK(!steer_cellular(controls, {}, &view, &population, {}).patch); + view.patches[0].matter_fg[2] = 1; + CHECK(steer_cellular(controls, {}, &view, &population, {}).patch); + view.life_identity = 0; + CHECK(!steer_cellular(controls, {}, &view, &population, {}).patch); + network::CellularOfferedCandidate candidate; + candidate.cost_energy_pj = 10; + candidate.cost_matter_fg = {1, 2, 3, 4}; + network::CellularLifeDiagnostics reserve; + reserve.reserve_energy_pj = 10; + reserve.reserve_matter_fg = {1, 2, 3, 4}; + CHECK(can_fund(candidate, reserve)); + reserve.reserve_matter_fg[3] = 3; + CHECK(!can_fund(candidate, reserve)); + reserve.reserve_matter_fg[3] = 4; + reserve.reserve_energy_pj = 9; + CHECK(!can_fund(candidate, reserve)); + std::vector scene; + patch_box(scene, {-10, 100}, {100, -10}, true, true, 80, 80); + CHECK(scene.size() == patch_rectangles); + for (const auto& r : scene) + CHECK(r.x >= 0 && r.y >= 0 && r.x + r.width <= 80 && r.y + r.height <= 80); +} void labels() { const auto c = cell(0); const auto water = describe_field(c, world::Field::water); @@ -332,6 +390,81 @@ void session_host() { CHECK(!host.connect(FakeSession{server})); CHECK(server.alive == 0 && host.session() == nullptr); } +void cellular_play() { + using namespace evo::client_app; + using namespace evo::network; + CellularPlay play; + play.initialize(100); + CHECK(play.birth_request() == 100 && play.birth_pending()); + play.connected(); + play.observe({101, 900, {}, CellularLifeDiagnostics{}}); + CHECK(play.can_act() && !play.can_restart()); + CellularLifeDiagnostics feedback; + feedback.has_tick_effects = true; + feedback.bud = CellularBudOutcome::insufficient_funding; + play.observe({101, 900, {}, feedback}); + play.observe({102, 900, {}, CellularLifeDiagnostics{}}); + CHECK(play.bud_feedback() == + std::pair{std::uint64_t{101}, CellularBudOutcome::insufficient_funding}); + const CellularMutationOffer offer{101, 900, 1, 100, {{3, 2, 0, 50, 20, 30}}}; + play.observe_offer(offer); + CHECK(!play.queue(CellAction::mutation, 102, {900, 2, 100, 3})); + CHECK(!play.queue(CellAction::mutation, 100, {900, 1, 100, 3})); + CHECK(!play.queue(CellAction::mutation, 102, {900, 1, 100, 8})); + CHECK(play.queue(CellAction::mutation, 102, {900, 1, 100, 3})); + const auto id = required(play.pending()).id; + CHECK(!play.queue(CellAction::bud, 102)); // Double clicks cannot create another action. + play.sent(); + play.receipt({id, AdmitStatus::not_ready, 101, 0}); + CHECK(required(play.pending()).state == CellActionState::unresolved); + play.disconnected(); + CHECK(!play.can_act() && !play.offer()); + play.connected(); + CHECK(!play.can_act()); + play.observe({103, 900, {}, CellularLifeDiagnostics{}}); + play.receipt({id, AdmitStatus::invalid_action, 103, 0}); + CHECK(required(play.pending()).state == + CellActionState::unresolved); // Refused retry != failed original. + play.outcome({id, ActionResult::committed, 102, 1}); + CHECK(!play.pending() && play.history().back().state == CellActionState::committed); + CHECK(play.queue(CellAction::bud, 104)); + const auto bud = required(play.pending()).id; + play.sent(); + play.observe_end({104, 900, CellularDeathReason::starved}); + play.observe({103, 900, {}, CellularLifeDiagnostics{}}); // Retained view is older than death. + CHECK(play.life() == 0 && play.can_restart() && !play.can_act()); + CHECK(play.restart()); + const auto request = play.birth_request(); + CHECK(request != 100 && !play.restart()); + play.birth({100, PrimitiveLifeResult::born, 900, 1}); // Old request cannot finish this birth. + CHECK(play.birth_pending()); + play.birth({request, PrimitiveLifeResult::born, 901, 3}); + CHECK(!play.can_restart()); // Birth reply may precede the first new-life view. + play.observe({105, 901, {}, CellularLifeDiagnostics{}}); + play.observe_end({104, 900, CellularDeathReason::starved}); + CHECK(play.life() == 901 && !play.ended() && !play.pending()); + play.outcome({bud, ActionResult::not_committed, 0, 0}); + CHECK(play.history().back().state == CellActionState::refused); + for (int i = 0; i < 20; ++i) { + CHECK(play.queue(CellAction::engulf, 106)); + const auto action = required(play.pending()).id; + play.sent(); + play.outcome({action, ActionResult::unknown, 0, 0}); + play.keep_unknown(); + } + CHECK(play.history().size() == CellularPlay::history_limit); + CHECK(play.history().back().state == CellActionState::unresolved); + play.disconnected(); + CHECK(!play.queue(CellAction::engulf, 106) && !play.can_restart()); + play.connected(); + play.observe({106, 901, {}, CellularLifeDiagnostics{}}); + CHECK(play.queue(CellAction::bud, 107)); + play.disconnected(); + CHECK(!play.pending() && play.history().back().state == CellActionState::refused); + CellularPlay exhausted; + exhausted.initialize(std::numeric_limits::max()); + CHECK(exhausted.allocate_id() == 0 && exhausted.allocate_id() == 0); +} } // namespace int main() try { @@ -340,6 +473,8 @@ int main() try { launcher(); outcome_log(); session_host(); + cellular_play(); + cellular_assistance(); std::puts("client UI model tests passed"); return 0; } catch (const std::exception& e) { diff --git a/tools/client/README-package.txt b/tools/client/README-package.txt index 431f2cd..c86471a 100644 --- a/tools/client/README-package.txt +++ b/tools/client/README-package.txt @@ -36,6 +36,25 @@ US-layout key positions. Changed controls are saved in %APPDATA%\Aeternalis Games\Evolution Engineering Client\controls-v1.txt. No other settings, logs or credentials are written by the client. +Cellular play (v10) +------------------ +Check Cellular play (v10) before Connect, or add --cellular to the connection +command. For the current dev playtest use fresh accounts and region 4 grants. +Cell shows reserves and Engulf/Bud actions. Feeding is automatic when touching +stocked food. Food offers manual targeting, a speed slider, precision steering, +and optional slowing near food. Evolution explains earned mutation choices and +shows their energy/matter cost; unaffordable choices are disabled. On a +narrow window, Evolution is the Life tab. Log keeps recent discrete results and +can reveal engineering panels. Ctrl+= and Ctrl+- adjust UI scale. + +Engulf and Bud are single actions; automatic feeding resumes after their tick. +A bud becomes wildlife; you keep your cell. Engulf and bud failures and death +causes come from the server. Mutation funding is rechecked at commitment. +Accepted actions await a committed result. An unknown result is +not success or failure. Start new life creates a fresh primitive cell after death; +old lives are never revived. Request history lasts only for this app connection +flow, including automatic reconnects, and is not saved on exit. + Useful options: --version, --fixture, --renderer software, --controls FILE. Any unknown option prints the full usage.