feat(cellular): show what holds growth back and each nutrient's flows
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m23s
Foundation / postgres-tools (push) Successful in 21s
Foundation / server-image (push) Successful in 4m18s
Foundation / image (push) Successful in 4m56s
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m23s
Foundation / postgres-tools (push) Successful in 21s
Foundation / server-image (push) Successful in 4m18s
Foundation / image (push) Successful in 4m56s
Playtest: phosphorus jumped between ~100 fg and a few pg because growth spends it as it arrives and only pauses when another nutrient runs short. The owner now records, per owned life and tick, which channel narrowed the growth step (or no room) and what the tick collected, built into the body and burned; session v14 carries them (flag bits 2-4 and a 120-byte flows block). The client shows "Growing 62% - waiting for phosphorus" or "Fully grown", outlines the limiting nutrient's bar in amber, and gives each bar (and the energy figure) a tooltip with the last second's flows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "evo/network/session_protocol.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <deque>
|
||||
@@ -42,6 +43,10 @@ struct CellEnergyChange {
|
||||
std::uint64_t from_tick{}, to_tick{}, amount{};
|
||||
bool falling{};
|
||||
};
|
||||
// Rules 13 (v14): each channel's flows over the last second of views (energy, C, N, P, other).
|
||||
struct CellFlows {
|
||||
std::array<std::uint64_t, 5> collected{}, into_growth{}, burned{};
|
||||
};
|
||||
|
||||
class CellularPlay {
|
||||
public:
|
||||
@@ -95,6 +100,16 @@ class CellularPlay {
|
||||
energy_change_.reset();
|
||||
}
|
||||
energy_sample_ = EnergySample{view.life_identity, view.tick, energy};
|
||||
// One sample per tick of this life, the last second (20 ticks) kept.
|
||||
if (!flow_samples_.empty() && flow_samples_.back().life != view.life_identity)
|
||||
flow_samples_.clear();
|
||||
const auto& d = *view.diagnostics;
|
||||
if (d.has_tick_effects &&
|
||||
(flow_samples_.empty() || flow_samples_.back().tick < view.tick))
|
||||
flow_samples_.push_back(
|
||||
{view.life_identity, view.tick, {d.collected, d.into_growth, d.burned}});
|
||||
while (!flow_samples_.empty() && flow_samples_.front().tick + 20 <= view.tick)
|
||||
flow_samples_.pop_front();
|
||||
}
|
||||
// Never replay an intention onto a later life. Keep its uncertain result visible.
|
||||
if (life_ != view.life_identity) {
|
||||
@@ -309,6 +324,21 @@ class CellularPlay {
|
||||
[[nodiscard]] const auto& energy_change() const {
|
||||
return energy_change_;
|
||||
}
|
||||
// Flows per second, scaled up when views were missed.
|
||||
[[nodiscard]] CellFlows flows_per_second() const {
|
||||
CellFlows total;
|
||||
for (const auto& sample : flow_samples_)
|
||||
for (std::size_t c = 0; c < 5; ++c) {
|
||||
total.collected.at(c) += sample.flows.collected.at(c);
|
||||
total.into_growth.at(c) += sample.flows.into_growth.at(c);
|
||||
total.burned.at(c) += sample.flows.burned.at(c);
|
||||
}
|
||||
if (!flow_samples_.empty() && flow_samples_.size() < 20)
|
||||
for (auto* channel : {&total.collected, &total.into_growth, &total.burned})
|
||||
for (auto& value : *channel)
|
||||
value = value * 20 / flow_samples_.size();
|
||||
return total;
|
||||
}
|
||||
|
||||
private:
|
||||
void finish() {
|
||||
@@ -346,6 +376,11 @@ class CellularPlay {
|
||||
std::uint64_t life{}, tick{}, energy{};
|
||||
};
|
||||
std::optional<EnergySample> energy_sample_;
|
||||
struct FlowSample {
|
||||
std::uint64_t life{}, tick{};
|
||||
CellFlows flows;
|
||||
};
|
||||
std::deque<FlowSample> flow_samples_;
|
||||
std::optional<CellEnergyChange> energy_change_;
|
||||
};
|
||||
} // namespace evo::client_app
|
||||
|
||||
@@ -656,7 +656,8 @@ void dot(ImU32 color, bool hollow = false) {
|
||||
ImGui::Dummy({size, size});
|
||||
}
|
||||
// One table row: a nutrient's dot and name, a bar filled to `share`, and a value.
|
||||
void nutrient_row(std::size_t channel, const char* name, float share, const std::string& value) {
|
||||
void nutrient_row(std::size_t channel, const char* name, float share, const std::string& value,
|
||||
bool highlight = false, const std::string& tip = {}) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
dot(nutrient_colors.at(channel));
|
||||
@@ -673,7 +674,13 @@ void nutrient_row(std::size_t channel, const char* name, float share, const std:
|
||||
height / 2);
|
||||
list.AddRectFilled({at.x, top}, {at.x + width * std::clamp(share, 0.0F, 1.0F), top + height},
|
||||
nutrient_colors.at(channel), height / 2);
|
||||
// The nutrient holding growth back: an amber outline around its bar.
|
||||
if (highlight)
|
||||
list.AddRect({at.x - 2, top - 2}, {at.x + width + 2, top + height + 2},
|
||||
IM_COL32(243, 176, 77, 255), height / 2 + 2, 0, 1.5F);
|
||||
ImGui::Dummy({width, line});
|
||||
if (!tip.empty() && ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s", tip.c_str());
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted(value.c_str());
|
||||
}
|
||||
@@ -1234,6 +1241,13 @@ void hud_vitals(const PanelView& v, FormBuffers& form, bool compact) {
|
||||
ImGui::PushFont(nullptr, px(26));
|
||||
ImGui::TextUnformatted(energy_text(d->reserve_energy_pj).c_str());
|
||||
ImGui::PopFont();
|
||||
if (d->members != 0 && ImGui::IsItemHovered()) {
|
||||
const auto flows = play->flows_per_second();
|
||||
ImGui::SetTooltip("Last second: +%s collected, -%s into growth.%s",
|
||||
energy_text(flows.collected[0]).c_str(),
|
||||
energy_text(flows.into_growth[0]).c_str(),
|
||||
d->growth_limit == 1 ? "\nEnergy is holding your growth back." : "");
|
||||
}
|
||||
if (const auto& change = play->energy_change(); change && change->falling)
|
||||
disabled_wrapped("Energy is falling: feeding may not cover upkeep and movement.");
|
||||
if (v.cellular_feed_target && v.cellular_perception) {
|
||||
@@ -1244,8 +1258,23 @@ void hud_vitals(const PanelView& v, FormBuffers& form, bool compact) {
|
||||
if (patch != patches.end() && patch->energy_pj == 0)
|
||||
ImGui::TextColored(amber, "Feed target has no energy left");
|
||||
}
|
||||
// Rules 13 (v14): how far the body has grown, and what is holding it back.
|
||||
const bool revamp = d->members != 0;
|
||||
if (revamp) {
|
||||
constexpr std::array held{"", "energy", "carbon", "nitrogen",
|
||||
"phosphorus", "other matter", "room to grow here"};
|
||||
const auto grown = static_cast<unsigned>(d->growth_per_thousand / 10);
|
||||
if (d->growth_per_thousand >= 1000)
|
||||
ImGui::TextColored(lavender, "Fully grown");
|
||||
else if (d->growth_limit != 0 && d->growth_limit < held.size())
|
||||
ImGui::TextColored(amber, "Growing %u%% - waiting for %s", grown,
|
||||
held.at(d->growth_limit));
|
||||
else
|
||||
ImGui::TextColored(lavender, "Growing %u%%", grown);
|
||||
}
|
||||
ImGui::Separator();
|
||||
const bool toward_bud = bud_known(*d);
|
||||
const auto flows = revamp ? play->flows_per_second() : CellFlows{};
|
||||
if (begin_nutrient_table("matter")) {
|
||||
for (std::size_t i = 0; i < d->reserve_matter_fg.size(); ++i) {
|
||||
const auto have = d->reserve_matter_fg.at(i);
|
||||
@@ -1254,10 +1283,25 @@ void hud_vitals(const PanelView& v, FormBuffers& form, bool compact) {
|
||||
toward_bud && need != 0
|
||||
? static_cast<float>(static_cast<double>(have) / static_cast<double>(need))
|
||||
: 1.0F;
|
||||
nutrient_row(i + 1, nutrient_names.at(i + 1), share, mass_text(have));
|
||||
const bool limiting = revamp && d->growth_limit == i + 2;
|
||||
std::string tip;
|
||||
if (revamp) {
|
||||
const std::string name = nutrient_names.at(i + 1);
|
||||
tip = "Last second: +" + mass_text(flows.collected.at(i + 1)) + " collected, -" +
|
||||
mass_text(flows.into_growth.at(i + 1)) + " into growth, -" +
|
||||
mass_text(flows.burned.at(i + 1)) + " burned for energy.\n" + name +
|
||||
" goes into your body as soon as it arrives while you grow; the bar\n"
|
||||
"shows only what is left over.";
|
||||
if (limiting)
|
||||
tip += "\nThis is what is holding your growth back right now.";
|
||||
}
|
||||
nutrient_row(i + 1, nutrient_names.at(i + 1), share,
|
||||
mass_text(have) + (limiting ? " *" : ""), limiting, tip);
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
if (revamp && d->growth_limit >= 2 && d->growth_limit <= 5)
|
||||
disabled_wrapped("* holds your growth back. Hover a bar for its flows.");
|
||||
if (toward_bud)
|
||||
disabled_wrapped("Bars: progress toward your next bud.");
|
||||
if (d->has_tick_effects) {
|
||||
|
||||
Reference in New Issue
Block a user