feat(client): recent actions show what each engulf or bud did
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (ecs) (push) Canceled after 45s
Foundation / checks (checks) (push) Canceled after 49s
Foundation / checks (client) (push) Canceled after 49s
Foundation / checks (postgres) (push) Canceled after 48s
Foundation / checks (deploy) (push) Canceled after 54s
Foundation / checks (network) (push) Canceled after 53s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (ecs) (push) Canceled after 45s
Foundation / checks (checks) (push) Canceled after 49s
Foundation / checks (client) (push) Canceled after 49s
Foundation / checks (postgres) (push) Canceled after 48s
Foundation / checks (deploy) (push) Canceled after 54s
Foundation / checks (network) (push) Canceled after 53s
A history entry only said "Committed", so a refused engulf (membrane too thick) looked like a success. The engulf or bud result reported in the action's tick view is now attached to that entry: Recent actions shows the action, its tick and the region's result, green only when it took effect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,9 @@ struct CellActionRecord {
|
||||
std::uint64_t id{}, life{}, tick{};
|
||||
MutationChoice choice{};
|
||||
network::AdmitStatus refusal{network::AdmitStatus::admitted};
|
||||
// The region's reported effect of this engulf or bud, once a view carries it.
|
||||
std::optional<network::CellularEngulfResult> engulf;
|
||||
std::optional<network::CellularBudOutcome> bud;
|
||||
};
|
||||
struct CellEnergyChange {
|
||||
std::uint64_t from_tick{}, to_tick{}, amount{};
|
||||
@@ -107,11 +110,17 @@ class CellularPlay {
|
||||
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)
|
||||
d.engulf != network::CellularEngulfResult::not_requested) {
|
||||
engulf_feedback_ = std::pair{view.tick, d.engulf};
|
||||
if (auto* record = awaiting_effect(CellAction::engulf, view.tick))
|
||||
record->engulf = d.engulf;
|
||||
}
|
||||
if (d.bud != network::CellularBudOutcome::not_reported &&
|
||||
d.bud != network::CellularBudOutcome::not_requested)
|
||||
d.bud != network::CellularBudOutcome::not_requested) {
|
||||
bud_feedback_ = std::pair{view.tick, d.bud};
|
||||
if (auto* record = awaiting_effect(CellAction::bud, view.tick))
|
||||
record->bud = d.bud;
|
||||
}
|
||||
}
|
||||
if (life_ != 0) {
|
||||
birth_pending_ = false;
|
||||
@@ -154,7 +163,9 @@ class CellularPlay {
|
||||
const auto id = allocate_id();
|
||||
if (id == 0)
|
||||
return false;
|
||||
pending_ = CellActionRecord{kind, CellActionState::queued, id, life_, tick, choice};
|
||||
pending_ = CellActionRecord{
|
||||
kind, CellActionState::queued, id, life_, tick,
|
||||
choice, network::AdmitStatus::admitted, std::nullopt, std::nullopt};
|
||||
return true;
|
||||
}
|
||||
void sent() {
|
||||
@@ -298,6 +309,20 @@ class CellularPlay {
|
||||
history_.push_back(*pending_);
|
||||
pending_.reset();
|
||||
}
|
||||
// The newest engulf/bud of this life, at or before `tick`, still without a reported
|
||||
// effect: the view for its tick carries what the region did with it.
|
||||
CellActionRecord* awaiting_effect(CellAction kind, std::uint64_t tick) {
|
||||
const auto waiting = [&](const CellActionRecord& r) {
|
||||
return r.kind == kind && r.life == life_ && r.tick <= tick &&
|
||||
!(kind == CellAction::engulf ? r.engulf.has_value() : r.bud.has_value());
|
||||
};
|
||||
if (pending_ && waiting(*pending_))
|
||||
return &*pending_;
|
||||
for (auto it = history_.rbegin(); it != history_.rend(); ++it)
|
||||
if (waiting(*it))
|
||||
return &*it;
|
||||
return nullptr;
|
||||
}
|
||||
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};
|
||||
|
||||
+37
-23
@@ -587,10 +587,40 @@ const char* cell_action_state(CellActionState state) {
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
// What the region did with an engulf or bud, as its tick's view reports it ("" when none).
|
||||
const char* engulf_text(network::CellularEngulfResult result) {
|
||||
constexpr std::array text{"",
|
||||
"",
|
||||
"Prey engulfed",
|
||||
"No prey in contact",
|
||||
"Engulf unsupported here",
|
||||
"Engulf failed: no cell touching yours",
|
||||
"Engulf failed: prey too large",
|
||||
"Engulf failed: prey's membrane too thick"};
|
||||
const auto index = static_cast<std::size_t>(result);
|
||||
return index < text.size() ? text.at(index) : "";
|
||||
}
|
||||
const char* bud_text(network::CellularBudOutcome outcome) {
|
||||
constexpr std::array text{"",
|
||||
"",
|
||||
"Bud created: a descendant split off",
|
||||
"Bud failed: not fully grown",
|
||||
"Bud failed: not enough resources",
|
||||
"Bud failed: no space beside you"};
|
||||
const auto index = static_cast<std::size_t>(outcome);
|
||||
return index < text.size() ? text.at(index) : "";
|
||||
}
|
||||
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));
|
||||
const char* effect = record.engulf ? engulf_text(*record.engulf)
|
||||
: record.bud ? bud_text(*record.bud)
|
||||
: "";
|
||||
const bool succeeded =
|
||||
record.state == CellActionState::committed &&
|
||||
(!record.engulf || *record.engulf == network::CellularEngulfResult::engulfed) &&
|
||||
(!record.bud || *record.bud == network::CellularBudOutcome::budded);
|
||||
ImGui::TextColored(succeeded ? green : amber, "%s (tick %llu)", cell_action_name(record.kind),
|
||||
static_cast<unsigned long long>(record.tick));
|
||||
ImGui::TextWrapped("%s", *effect != '\0' ? effect : 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());
|
||||
@@ -1129,26 +1159,10 @@ void hud_dock(const PanelView& v, FormBuffers& form, PanelActions& a, bool compa
|
||||
}
|
||||
}
|
||||
if (play) {
|
||||
constexpr std::array engulf{"",
|
||||
"",
|
||||
"Prey engulfed",
|
||||
"No prey in contact",
|
||||
"Engulf unsupported here",
|
||||
"Engulf failed: no cell touching yours",
|
||||
"Engulf failed: prey too large",
|
||||
"Engulf failed: prey's membrane too thick"};
|
||||
constexpr std::array bud{"",
|
||||
"",
|
||||
"Bud created: a descendant split off",
|
||||
"Bud failed: not fully grown",
|
||||
"Bud failed: not enough resources",
|
||||
"Bud failed: no space beside you"};
|
||||
if (const auto& f = play->engulf_feedback();
|
||||
f && !std::string_view{engulf.at(static_cast<std::size_t>(f->second))}.empty())
|
||||
ImGui::TextWrapped("%s", engulf.at(static_cast<std::size_t>(f->second)));
|
||||
if (const auto& f = play->bud_feedback();
|
||||
f && !std::string_view{bud.at(static_cast<std::size_t>(f->second))}.empty())
|
||||
ImGui::TextWrapped("%s", bud.at(static_cast<std::size_t>(f->second)));
|
||||
if (const auto& f = play->engulf_feedback(); f && *engulf_text(f->second) != '\0')
|
||||
ImGui::TextWrapped("%s", engulf_text(f->second));
|
||||
if (const auto& f = play->bud_feedback(); f && *bud_text(f->second) != '\0')
|
||||
ImGui::TextWrapped("%s", bud_text(f->second));
|
||||
if (const auto& pending = play->pending(); pending) {
|
||||
cell_record(*pending);
|
||||
if (pending->state == CellActionState::unresolved) {
|
||||
|
||||
@@ -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-20261021T125059-4a2c275e:1792601459"}
|
||||
- {name: REGION_SESSION_WINDOW, value: "dev-20261021T145645-22cbb2ac:1792609005"}
|
||||
- {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"}
|
||||
ports:
|
||||
# QUIC (ADR-0090): UDP only; nothing listens on TCP 7400.
|
||||
|
||||
@@ -472,6 +472,30 @@ void cellular_play() {
|
||||
exhausted.initialize(std::numeric_limits<std::uint64_t>::max());
|
||||
CHECK(exhausted.allocate_id() == 0 && exhausted.allocate_id() == 0);
|
||||
}
|
||||
// Recent actions keep what the region did: the effect reported in the action's tick view
|
||||
// is attached to that engulf, even after its committed outcome moved it to the history.
|
||||
void cellular_action_effects() {
|
||||
using namespace evo::client_app;
|
||||
using namespace evo::network;
|
||||
CellularPlay play;
|
||||
play.initialize(50);
|
||||
play.connected();
|
||||
play.observe({200, 700, {}, CellularLifeDiagnostics{}});
|
||||
CHECK(play.queue(CellAction::engulf, 203));
|
||||
const auto id = required(play.pending()).id;
|
||||
play.sent();
|
||||
play.outcome({id, ActionResult::committed, 203, 1});
|
||||
CHECK(!play.pending() && !play.history().back().engulf);
|
||||
CellularLifeDiagnostics effect;
|
||||
effect.has_tick_effects = true;
|
||||
effect.engulf = CellularEngulfResult::membrane_too_thick;
|
||||
play.observe({203, 700, {}, effect});
|
||||
CHECK(play.history().back().engulf == CellularEngulfResult::membrane_too_thick);
|
||||
// A later engulf result does not overwrite the reported one.
|
||||
effect.engulf = CellularEngulfResult::engulfed;
|
||||
play.observe({204, 700, {}, effect});
|
||||
CHECK(play.history().back().engulf == CellularEngulfResult::membrane_too_thick);
|
||||
}
|
||||
void cellular_energy_and_birth_wait() {
|
||||
using namespace evo::client_app;
|
||||
using namespace evo::network;
|
||||
@@ -551,6 +575,7 @@ int main() try {
|
||||
outcome_log();
|
||||
session_host();
|
||||
cellular_play();
|
||||
cellular_action_effects();
|
||||
cellular_energy_and_birth_wait();
|
||||
cellular_assistance();
|
||||
cell_headings();
|
||||
|
||||
Reference in New Issue
Block a user