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
|
||||
|
||||
Reference in New Issue
Block a user