Upgrade cellular client to v10 with readable play and assisted steering

This commit is contained in:
dingo
2026-10-14 19:53:28 -04:00
parent 75b8bbb333
commit 68958a9e54
21 changed files with 1603 additions and 93 deletions
+338 -5
View File
@@ -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<unsigned long long>(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<unsigned long long>(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<unsigned long long>(d.maintenance_cost_pj),
static_cast<unsigned long long>(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<std::size_t>(d.movement)));
ImGui::TextWrapped("%s", intake.at(static_cast<std::size_t>(d.intake)));
if (const auto& feedback = play->engulf_feedback(); feedback)
ImGui::TextWrapped("%s (tick %llu)", engulf.at(static_cast<std::size_t>(feedback->second)),
static_cast<unsigned long long>(feedback->first));
if (const auto& feedback = play->bud_feedback(); feedback)
ImGui::TextWrapped("%s (tick %llu)", bud.at(static_cast<std::size_t>(feedback->second)),
static_cast<unsigned long long>(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<int>(patch.x_um));
ImGui::PushID(static_cast<int>(patch.y_um));
ImGui::Separator();
ImGui::Text("Patch %u / %u um", patch.x_um, patch.y_um);
ImGui::Text("%llu pJ", static_cast<unsigned long long>(patch.energy_pj));
ImGui::TextWrapped("C %llu / N %llu / P %llu / other %llu fg",
static_cast<unsigned long long>(patch.matter_fg[0]),
static_cast<unsigned long long>(patch.matter_fg[1]),
static_cast<unsigned long long>(patch.matter_fg[2]),
static_cast<unsigned long long>(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<int>(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<unsigned long long>(c.maintenance),
static_cast<unsigned long long>(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<unsigned long long>(c.cost_energy_pj),
static_cast<unsigned long long>(c.cost_matter_fg[0]),
static_cast<unsigned long long>(c.cost_matter_fg[1]),
static_cast<unsigned long long>(c.cost_matter_fg[2]),
static_cast<unsigned long long>(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<unsigned long long>(v.remote->region),
static_cast<unsigned long long>(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);