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

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:
dingo
2026-10-26 09:48:37 -04:00
co-authored by Claude Opus 5.5
parent 6988cf39b2
commit 15b4342934
12 changed files with 224 additions and 23 deletions
+35
View File
@@ -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
+46 -2
View File
@@ -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) {
+11
View File
@@ -264,6 +264,17 @@ class CellularBridge {
diagnostics.engulf = engulf_result(feedback->engulf);
diagnostics.bud = feedback->bud ? bud_outcome(*feedback->bud)
: network::CellularBudOutcome::not_requested;
// Rules 13 (v14): what held growth back and the tick's flows by channel.
diagnostics.growth_limit = feedback->growth_limit;
const auto channels = [](const accounting::Inventory& value) {
return std::array<std::uint64_t, 5>{
value.energy.value, value.matter[0].value, value.matter[1].value,
value.matter[2].value, value.matter[3].value};
};
diagnostics.collected = channels(feedback->collected);
diagnostics.into_growth = channels(feedback->into_growth);
diagnostics.burned = channels(feedback->burned);
diagnostics.burned[0] = 0; // Energy is spent, never burned.
}
// Rules 12 (v13): the authoritative motion state and the region's currents, from
// which the client regenerates the identical flow field.
@@ -12,7 +12,7 @@ spec:
env:
- {name: REGION_SESSION, value: "dev"}
- {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"}
- {name: REGION_SESSION_WINDOW, value: "dev-20261026T132256-8130c52f:1793035376"}
- {name: REGION_SESSION_WINDOW, value: "dev-20261026T134825-268af5f0:1793036905"}
- {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"}
ports:
# QUIC (ADR-0090): UDP only; nothing listens on TCP 7400.
+5
View File
@@ -390,6 +390,11 @@ struct CellularLifeDiagnostics {
// How grown the body is (per thousand), and whether a mutation choice can split it now.
std::uint16_t growth_per_thousand{};
bool split_ready{};
// What held this tick's growth step back (0 nothing; 1 energy; 2-5 C, N, P, other; 6 no
// room), and the tick's flows by channel (energy, C, N, P, other): collected from food,
// built into the body, and burned in place of energy (matter only).
std::uint8_t growth_limit{};
std::array<std::uint64_t, 5> collected{}, into_growth{}, burned{};
std::uint64_t payable_energy_pj{}, total_mass_fg{};
std::array<std::uint16_t, 20> traits{};
friend bool operator==(const CellularLifeDiagnostics&,
@@ -240,6 +240,11 @@ struct CellularLifeTickFeedback {
bool resume_blocked{};
accounting::Picojoules light{}; // Rules 11 (ADR-0175): light captured this tick.
std::uint8_t exclude{}; // Rules 13: the matter channels kept from burning this tick.
// Rules 13, owned lives: what held this tick's growth step back (0 nothing: a full step or
// fully grown; 1 energy; 2-5 carbon, nitrogen, phosphorus, other; 6 no room), and what the
// tick moved: collected from food, built into the body, and burned in place of energy.
std::uint8_t growth_limit{};
accounting::Inventory collected{}, into_growth{}, burned{};
auto operator<=>(const CellularLifeTickFeedback&) const = default;
};
// Which owner version a new region starts on. Offers: format 2, rules 2 (the M11.3/11.4
@@ -11,12 +11,16 @@ v13's. Older versions keep their exact layouts and never see a v14 field.
| 2 | Members: cells in the organism (1 for a single cell; at least 1 with a life) |
| 2 | Emergence threshold in members (0 below rules 13) |
| 1 | Matter channels kept from burning this tick (bits 0-3: C, N, P, other) |
| 1 | Flags: bit 0 Emerge is open; bit 1 a mutation choice can split the cell now (single cell, grown to the region's split threshold); other bits zero |
| 1 | Flags: bit 0 Emerge is open; bit 1 a mutation choice can split the cell now (single cell, grown to the region's split threshold); bits 2-4 what held this tick's growth step back (0 nothing, 1 energy, 2-5 C, N, P, other, 6 no room); bits 5-7 zero |
| 2 | Growth per thousand of full size (0-1,000) |
| 8 | Payable energy (pJ): the reserve's energy plus what its burnable matter stands in for |
| 8 | Total mass (fg): body and reserve matter |
| 2 each | The 20 heritable body traits in `biology::CellularTraits` order: density, upkeep efficiency, growth speed, collection (E, C, N, P, O), burn (C, N, P, O), engulf capacity, kill absorption, litter, recipe (C, N, P, O), adhesion |
It is followed by a 120-byte flows block: the tick's amounts by channel (energy, C, N, P,
other; u64 each) collected from food, built into the body by growth, and burned in place of
energy (matter only; the energy entry is zero).
Without an owner life every field is zero.
**Cellular action.** Byte 37 (the v13 flags) adds bit 1 become (only with a bud: the player
+33 -9
View File
@@ -41,8 +41,13 @@ constexpr std::size_t cellular_perception_v13_prefix_bytes =
// (bit 0 Emerge open, bit 1 a choice can split now), growth per thousand (u16), payable energy
// and total mass (2 x u64) and twenty u16 traits.
constexpr std::size_t cellular_revamp_block_bytes = 2 + 2 + 1 + 1 + 2 + 8 + 8 + (20 * 2);
// Then the tick's flows: collected, built into the body and burned, five u64 channels each.
constexpr std::size_t cellular_flows_block_bytes = std::size_t{3} * 5 * 8;
constexpr std::size_t cellular_perception_v14_prefix_bytes =
cellular_perception_v13_prefix_bytes + cellular_revamp_block_bytes;
cellular_perception_v13_prefix_bytes + cellular_revamp_block_bytes + cellular_flows_block_bytes;
bool any_nonzero(const std::array<std::uint64_t, 5>& values) {
return std::ranges::any_of(values, [](std::uint64_t value) { return value != 0; });
}
constexpr std::size_t cellular_perceived_patch_bytes = 8 + 8 + (4 * 8);
// v11: id, centre, radius, shape, drained flag and five 16-bit amount codes.
constexpr std::size_t cellular_perceived_deposit_bytes = 4 + 4 + 4 + 2 + 1 + 1 + (5 * 2);
@@ -265,12 +270,14 @@ std::vector<std::uint8_t> encode_session(const SessionMessage& message, std::uin
const auto& body = perception->diagnostics;
if (version != session_protocol_v14 && body &&
(body->members || body->emerge_members || body->exclude || body->can_emerge ||
body->growth_per_thousand || body->split_ready || body->payable_energy_pj ||
body->total_mass_fg ||
body->growth_per_thousand || body->split_ready || body->growth_limit ||
any_nonzero(body->collected) || any_nonzero(body->into_growth) ||
any_nonzero(body->burned) || body->payable_energy_pj || body->total_mass_fg ||
std::ranges::any_of(body->traits, [](std::uint16_t value) { return value != 0; })))
return {};
if (version == session_protocol_v14 && body &&
(body->members == 0 || body->exclude > 0x0F || body->growth_per_thousand > 1000))
(body->members == 0 || body->exclude > 0x0F || body->growth_per_thousand > 1000 ||
body->growth_limit > 6 || body->burned[0] != 0))
return {};
if (!liquid && (perception->currents ||
(perception->diagnostics && (perception->diagnostics->velocity_x_q10 ||
@@ -503,13 +510,17 @@ std::vector<std::uint8_t> encode_session(const SessionMessage& message, std::uin
put(out, b.members, 2);
put(out, b.emerge_members, 2);
out.push_back(b.exclude);
out.push_back(static_cast<std::uint8_t>((b.can_emerge ? 1U : 0U) |
(b.split_ready ? 2U : 0U)));
out.push_back(static_cast<std::uint8_t>(
(b.can_emerge ? 1U : 0U) | (b.split_ready ? 2U : 0U) |
(static_cast<unsigned>(b.growth_limit) << 2U)));
put(out, b.growth_per_thousand, 2);
put(out, b.payable_energy_pj, 8);
put(out, b.total_mass_fg, 8);
for (const auto value : b.traits)
put(out, value, 2);
for (const auto* flow : {&b.collected, &b.into_growth, &b.burned})
for (const auto value : *flow)
put(out, value, 8);
}
} else {
put(out, 0, 5);
@@ -1008,6 +1019,13 @@ std::expected<SessionMessage, SessionCodecError> decode_session(std::span<const
b.exclude = payload[at + 4];
b.can_emerge = (payload[at + 5] & 1U) != 0;
b.split_ready = (payload[at + 5] & 2U) != 0;
b.growth_limit = static_cast<std::uint8_t>(payload[at + 5] >> 2U);
constexpr auto flows = at + cellular_revamp_block_bytes;
for (std::size_t i = 0; i < 5; ++i) {
b.collected.at(i) = get(payload, flows + i * 8, 8);
b.into_growth.at(i) = get(payload, flows + 40 + i * 8, 8);
b.burned.at(i) = get(payload, flows + 80 + i * 8, 8);
}
b.growth_per_thousand = static_cast<std::uint16_t>(get(payload, at + 6, 2));
b.payable_energy_pj = get(payload, at + 8, 8);
b.total_mass_fg = get(payload, at + 16, 8);
@@ -1015,10 +1033,12 @@ std::expected<SessionMessage, SessionCodecError> decode_session(std::span<const
b.traits.at(i) = static_cast<std::uint16_t>(get(payload, at + 24 + i * 2, 2));
const bool empty = b.members == 0 && b.emerge_members == 0 && b.exclude == 0 &&
payload[at + 5] == 0 && b.growth_per_thousand == 0 &&
b.payable_energy_pj == 0 && b.total_mass_fg == 0 &&
!any_nonzero(b.collected) && !any_nonzero(b.into_growth) &&
!any_nonzero(b.burned) && b.payable_energy_pj == 0 &&
b.total_mass_fg == 0 &&
std::ranges::all_of(b.traits, [](auto v) { return v == 0; });
if (b.exclude > 0x0F || payload[at + 5] > 3 || b.growth_per_thousand > 1000 ||
(m.diagnostics ? b.members == 0 : !empty))
if (b.exclude > 0x0F || b.growth_limit > 6 || b.growth_per_thousand > 1000 ||
b.burned[0] != 0 || (m.diagnostics ? b.members == 0 : !empty))
return std::unexpected(SessionCodecError::invalid_value);
if (m.diagnostics) {
auto& d = *m.diagnostics;
@@ -1027,6 +1047,10 @@ std::expected<SessionMessage, SessionCodecError> decode_session(std::span<const
d.exclude = b.exclude;
d.can_emerge = b.can_emerge;
d.split_ready = b.split_ready;
d.growth_limit = b.growth_limit;
d.collected = b.collected;
d.into_growth = b.into_growth;
d.burned = b.burned;
d.growth_per_thousand = b.growth_per_thousand;
d.payable_energy_pj = b.payable_energy_pj;
d.total_mass_fg = b.total_mass_fg;
+53 -8
View File
@@ -3268,6 +3268,8 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
// resuming from suspension did not take an active step and cannot grow here.
// Expansion holds the existing lower corner fixed; earlier IDs claim space first.
std::vector<CellularGrowthExecution> growth_results;
// Rules 13: what held each owned life's growth step back this tick (feedback only).
std::vector<std::pair<std::uint64_t, std::uint8_t>> growth_limits;
if (state_->rules_version >= cellular_lives_maturation_rules) {
for (auto& life : next_lives) {
const auto input = std::ranges::lower_bound(ordered, life.identity.life, {},
@@ -3303,16 +3305,42 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
if (!budget || budget->body != life.body)
return std::unexpected(CellularLivesError::biology);
const auto& move = budget->construction;
// Rules 13: an owned life learns which nutrient (or energy) narrowed its step: the
// one its reserve covers least of what an ample reserve's step needs.
std::optional<biology::MetabolicBudget> full;
if (revamp_rules && life.account != LifeAccount{}) {
accounting::Inventory ample{{1ULL << 50U}, {}};
for (auto& channel : ample.matter)
channel.value = 1ULL << 50U;
if (auto made = biology::metabolic_budget(
*genome, life.growth,
{state_->config.ambient_temperature_millikelvin, ample}, step,
state_->revamp.body))
full = *made;
if (full && move.after.realized_per_thousand <
full->construction.after.realized_per_thousand) {
const auto& need = full->construction.intake;
std::uint8_t limit = 0;
double least = 2.0;
for (std::size_t c = 0; c < 5; ++c) {
const auto wanted =
c == 0 ? need.energy.value : need.matter.at(c - 1).value;
const auto have = c == 0 ? life.reserve.energy.value
: life.reserve.matter.at(c - 1).value;
if (wanted == 0)
continue;
const auto share = static_cast<double>(have) / static_cast<double>(wanted);
if (share < least) {
least = share;
limit = static_cast<std::uint8_t>(c + 1);
}
}
growth_limits.emplace_back(life.identity.life, limit);
}
}
if (move.after == life.growth) {
if (revamp_rules && life.account != LifeAccount{}) {
// Which channels held the step back: what an ample reserve's step needs.
accounting::Inventory ample{{1ULL << 50U}, {}};
for (auto& channel : ample.matter)
channel.value = 1ULL << 50U;
const auto full = biology::metabolic_budget(
*genome, life.growth,
{state_->config.ambient_temperature_millikelvin, ample}, step,
state_->revamp.body);
if (full) {
using S = biology::CellularSignal;
constexpr std::array blocked{S::blocked_carbon, S::blocked_nitrogen,
@@ -3349,8 +3377,11 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
separated(life.position.y_um, other.position.y_um, extent,
obstacle->phenotype.extent);
}
if (!clear)
if (!clear) {
if (revamp_rules && life.account != LifeAccount{})
growth_limits.emplace_back(life.identity.life, std::uint8_t{6}); // No room.
continue; // No partial spatial retry, relocation or spending.
}
if (!subtract_inventory(life.reserve, move.intake) ||
!add_inventory(life.reserve, move.release) ||
!add_inventory(next_heat, accounting::Inventory{move.intake.energy, {}}))
@@ -3571,6 +3602,20 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
if (input == ordered.end() || input->life_id != result.life_id)
return std::unexpected{CellularLivesError::invalid_intents};
feedback.back().exclude = input->intent.exclude;
if (revamp_rules) {
auto& entry = feedback.back();
if (result.candidate.intake)
entry.collected = result.candidate.intake->transfer.acquired;
entry.burned = result.candidate.spent;
if (const auto grew = std::ranges::find(growth_results, result.life_id,
&CellularGrowthExecution::life_id);
grew != growth_results.end())
entry.into_growth = grew->intake;
if (const auto held = std::ranges::find(growth_limits, result.life_id,
&std::pair<std::uint64_t, std::uint8_t>::first);
held != growth_limits.end())
entry.growth_limit = held->second;
}
}
// ADR-0128: each surviving life reports its presence after the tick; a suspended life,
// which took no step, reports its unchanged reserve and any blocked resume.
+2
View File
@@ -976,6 +976,8 @@ bool RegionSessions::send_cellular_perception(const network::AccountId& account,
d.exclude = 0;
d.can_emerge = d.split_ready = false;
d.growth_per_thousand = 0;
d.growth_limit = 0;
d.collected = d.into_growth = d.burned = {};
d.payable_energy_pj = d.total_mass_fg = 0;
d.traits = {};
}
+9 -2
View File
@@ -619,13 +619,17 @@ void v14_carries_the_revamp() {
d.can_emerge = false;
d.split_ready = true;
d.growth_per_thousand = 620;
d.growth_limit = 4; // Phosphorus.
d.collected = {5, 4'000, 1'200, 90, 2'400};
d.into_growth = {7, 3'900, 1'100, 100, 2'300};
d.burned = {0, 0, 0, 0, 12};
d.payable_energy_pj = 12'000;
d.total_mass_fg = 24'000'000;
for (std::size_t i = 0; i < d.traits.size(); ++i)
d.traits.at(i) = static_cast<std::uint16_t>(100 + i);
CellularPerception view{77, 7, {}, d};
const auto bytes = encode_session(SessionMessage{view}, session_protocol_v14);
CHECK(bytes.size() == session_header_bytes + 18 + 64 + 40 + 16 + 56 + 64);
CHECK(bytes.size() == session_header_bytes + 18 + 64 + 40 + 16 + 56 + 64 + 120);
std::uint16_t version{};
const auto decoded = decode_session(bytes, &version);
CHECK(decoded && version == session_protocol_v14 &&
@@ -640,7 +644,10 @@ void v14_carries_the_revamp() {
bad[block + 4] = 0x10;
CHECK(!decode_session(bad));
bad = bytes;
bad[block + 5] = 4; // Flags: bit 0 Emerge open, bit 1 split ready.
bad[block + 5] = 7U << 2U; // Flags: bits 2-4 the growth limit, at most 6.
CHECK(!decode_session(bad));
bad = bytes;
bad[block + 64 + 80] = 1; // Energy is never burned.
CHECK(!decode_session(bad));
bad = bytes;
bad[block + 6] = 0xE9; // Growth 1,001 per thousand.
+19
View File
@@ -507,6 +507,25 @@ void cellular_revamp_actions() {
CellularLifeDiagnostics body;
body.members = 1;
play.observe({300, 800, {}, body});
// Flows add up over the last second of views (20 ticks) and scale up over missed ones.
{
CellularPlay flows;
flows.initialize(5);
flows.connected();
CellularLifeDiagnostics flowing = body;
flowing.has_tick_effects = true;
flowing.movement = CellularMovementResult::no_movement;
flowing.intake = CellularIntakeResult::acquired;
flowing.collected = {0, 0, 0, 100, 0};
flowing.into_growth = {0, 0, 0, 90, 0};
for (std::uint64_t tick = 1; tick <= 30; ++tick)
flows.observe({tick, 800, {}, flowing});
const auto second = flows.flows_per_second();
CHECK(second.collected[3] == 2'000 && second.into_growth[3] == 1'800);
for (std::uint64_t tick = 31; tick <= 40; tick += 2) // Every other view missed.
flows.observe({tick, 800, {}, flowing});
CHECK(flows.flows_per_second().collected[3] == 2'000);
}
CHECK(play.queue(CellAction::bud, 301, {}, true) && required(play.pending()).become);
play.sent();
play.outcome({required(play.pending()).id, ActionResult::committed, 301, 1});