feat(cellular): session v14, bundle 15 and rules-13 wildlife
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m29s
Foundation / postgres-tools (push) Successful in 24s
Foundation / server-image (push) Successful in 4m33s
Foundation / image (push) Successful in 4m59s
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m29s
Foundation / postgres-tools (push) Successful in 24s
Foundation / server-image (push) Successful in 4m33s
Foundation / image (push) Successful in 4m59s
Session v14 carries the rules-13 revamp: a body block in the owner's view (members, emergence threshold, exclusions, Emerge open, payable energy, mass and the 20 traits), become, emerge and channel exclusions on actions, become on mutation choices, catalog offers (id, chance, cost) and the emerged ending. Older sessions never see a v14 field. The client shows Stay / Become offspring offers named from the shared catalog, continuing as a bud, the organism and its Emerge button, kept channels, the body and the emerged end screen. Bundle 15 (rules 13 on owner format 11) is durable: schema 60 admits it raw-only, stores become as bit 15 of the choice's operator, widens the action input and mutation results, and publishes the 14 -> 15 revamp profile migration. evo-world-clone opens cellular-v10 (cellular-v9 plus the revamp upgrade from --revamp-tuning), resumable and recoverable. Wildlife counts reserve matter as energy, waits for the bud fee, grows organisms one short of emerging, and hunts by the region step's rules-13 engulf test. The play summary adds organisms, offers and the spent pool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,9 @@ namespace evo::client_app {
|
||||
struct CellularControls {
|
||||
bool auto_feed{true}, slow_near_food{true}, precision{};
|
||||
int speed_percent{100};
|
||||
// Rules 13 (v14): matter channels kept from burning as energy (bit 0 carbon .. bit 3
|
||||
// other). Upkeep still burns them when nothing else can pay.
|
||||
std::uint8_t exclude{};
|
||||
};
|
||||
struct CellularSteering {
|
||||
client::Intention intention;
|
||||
|
||||
@@ -14,9 +14,10 @@ namespace evo::client_app {
|
||||
struct MutationChoice {
|
||||
std::uint64_t life{}, event{}, offer_tick{};
|
||||
std::uint16_t operator_id{};
|
||||
bool become{}; // Rules 13 (v14): continue as the offspring the choice splits off.
|
||||
friend bool operator==(const MutationChoice&, const MutationChoice&) = default;
|
||||
};
|
||||
enum class CellAction : std::uint8_t { engulf, bud, mutation };
|
||||
enum class CellAction : std::uint8_t { engulf, bud, mutation, emerge };
|
||||
enum class CellActionState : std::uint8_t {
|
||||
queued,
|
||||
sent,
|
||||
@@ -35,6 +36,7 @@ struct CellActionRecord {
|
||||
// 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;
|
||||
bool become{}; // A bud the player continues as (v14).
|
||||
};
|
||||
struct CellEnergyChange {
|
||||
std::uint64_t from_tick{}, to_tick{}, amount{};
|
||||
@@ -149,7 +151,8 @@ class CellularPlay {
|
||||
[[nodiscard]] bool can_act() const {
|
||||
return connected_ && fresh_ && life_ != 0 && !ended_ && !pending_ && !birth_pending_;
|
||||
}
|
||||
[[nodiscard]] bool queue(CellAction kind, std::uint64_t tick, MutationChoice choice = {}) {
|
||||
[[nodiscard]] bool queue(CellAction kind, std::uint64_t tick, MutationChoice choice = {},
|
||||
bool become = false) {
|
||||
if (!can_act() || tick == 0)
|
||||
return false;
|
||||
if (kind == CellAction::mutation &&
|
||||
@@ -163,9 +166,16 @@ class CellularPlay {
|
||||
const auto id = allocate_id();
|
||||
if (id == 0)
|
||||
return false;
|
||||
pending_ = CellActionRecord{
|
||||
kind, CellActionState::queued, id, life_, tick,
|
||||
choice, network::AdmitStatus::admitted, std::nullopt, std::nullopt};
|
||||
pending_ = CellActionRecord{kind,
|
||||
CellActionState::queued,
|
||||
id,
|
||||
life_,
|
||||
tick,
|
||||
choice,
|
||||
network::AdmitStatus::admitted,
|
||||
std::nullopt,
|
||||
std::nullopt,
|
||||
kind == CellAction::bud && become};
|
||||
return true;
|
||||
}
|
||||
void sent() {
|
||||
|
||||
@@ -573,7 +573,8 @@ int main(int argc, char** argv) try {
|
||||
buffers.cellular_controls.auto_feed = false;
|
||||
}
|
||||
if (auto* remote = host.session(); remote && mode() == Mode::remote) {
|
||||
if (actions.cell_action && remote->request_cellular(*actions.cell_action))
|
||||
if (actions.cell_action &&
|
||||
remote->request_cellular(*actions.cell_action, {}, actions.cell_become))
|
||||
cellular_feed_target.reset();
|
||||
if (actions.mutation)
|
||||
static_cast<void>(remote->request_cellular(evo::client_app::CellAction::mutation,
|
||||
|
||||
+135
-3
@@ -1,4 +1,5 @@
|
||||
#include "panels.hpp"
|
||||
#include "evo/biology/cellular_catalog.hpp"
|
||||
#include "evo/client/labels.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@@ -565,6 +566,8 @@ const char* cell_action_name(CellAction kind) {
|
||||
return "Bud";
|
||||
case CellAction::mutation:
|
||||
return "Mutation";
|
||||
case CellAction::emerge:
|
||||
return "Emerge";
|
||||
}
|
||||
return "Action";
|
||||
}
|
||||
@@ -1275,9 +1278,28 @@ void hud_dock(const PanelView& v, FormBuffers& form, PanelActions& a, bool compa
|
||||
if (action_button("Engulf", {each, px(44)}, {0.38F, 0.68F, 1.0F, 1}))
|
||||
a.cell_action = CellAction::engulf;
|
||||
ImGui::SameLine();
|
||||
if (action_button("Bud", {each, px(44)}, {0.82F, 0.53F, 0.96F, 1}))
|
||||
if (action_button("Bud", {each, px(44)}, {0.82F, 0.53F, 0.96F, 1})) {
|
||||
a.cell_action = CellAction::bud;
|
||||
a.cell_become = form.bud_become && d && d->members == 1;
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
// Rules 13 (v14): continue as the bud, or grow the organism toward Emerge.
|
||||
if (d && d->members != 0 && play && play->life() != 0) {
|
||||
if (d->members == 1) {
|
||||
ImGui::Checkbox("Continue as the bud", &form.bud_become);
|
||||
} else {
|
||||
ImGui::TextColored(lavender, "Organism of %u cells (Emerge at %u)",
|
||||
static_cast<unsigned>(d->members),
|
||||
static_cast<unsigned>(d->emerge_members));
|
||||
ImGui::BeginDisabled(!play->can_act() || !d->can_emerge);
|
||||
if (action_button("Emerge", {-1, px(40)}, {0.98F, 0.82F, 0.35F, 1}))
|
||||
a.cell_action = CellAction::emerge;
|
||||
ImGui::EndDisabled();
|
||||
if (!d->can_emerge)
|
||||
disabled_wrapped("Emerge opens at the threshold of cells, mass and reserve. Buds "
|
||||
"add cells to the organism.");
|
||||
}
|
||||
}
|
||||
// What a bud needs, by nutrient (ADR-0129 amendment).
|
||||
if (d && play && play->life() != 0) {
|
||||
if (!bud_known(*d)) {
|
||||
@@ -1386,6 +1408,35 @@ void hud_notes(const PanelView& v, FormBuffers& form, PanelActions& a, bool comp
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
// Rules 13 (v14): which reserve matter may stand in for energy, and the heritable body.
|
||||
if (const auto* d = diagnostics(v); d && d->members != 0) {
|
||||
if (ImGui::CollapsingHeader("Burning reserve matter")) {
|
||||
for (std::size_t c = 0; c < 4; ++c) {
|
||||
const auto bit = static_cast<std::uint8_t>(1U << c);
|
||||
bool keep = (form.cellular_controls.exclude & bit) != 0;
|
||||
const std::string label = std::string{"Keep "} + nutrient_names.at(c + 1);
|
||||
if (ImGui::Checkbox(label.c_str(), &keep))
|
||||
form.cellular_controls.exclude =
|
||||
static_cast<std::uint8_t>(keep ? form.cellular_controls.exclude | bit
|
||||
: form.cellular_controls.exclude & ~bit);
|
||||
}
|
||||
ImGui::TextDisabled("Can pay %s now", energy_text(d->payable_energy_pj).c_str());
|
||||
disabled_wrapped("Matter you keep is never burned for movement or mutations; upkeep "
|
||||
"still burns it when nothing else can pay.");
|
||||
}
|
||||
if (ImGui::CollapsingHeader("Body")) {
|
||||
const auto& t = d->traits;
|
||||
ImGui::Text("Mass %s", mass_text(d->total_mass_fg).c_str());
|
||||
ImGui::TextDisabled("Density %u Upkeep efficiency %u Growth %u", unsigned{t[0]},
|
||||
unsigned{t[1]}, unsigned{t[2]});
|
||||
ImGui::TextDisabled("Engulf capacity %u Kill absorption %u", unsigned{t[12]},
|
||||
unsigned{t[13]});
|
||||
ImGui::TextDisabled("Litter %u Recipe C%u N%u P%u O%u", unsigned{t[14]},
|
||||
unsigned{t[15]}, unsigned{t[16]}, unsigned{t[17]}, unsigned{t[18]});
|
||||
if (t[19] != 0)
|
||||
ImGui::TextColored(lavender, "Adhesive: a multicellular organism");
|
||||
}
|
||||
}
|
||||
if (ImGui::CollapsingHeader("Steering")) {
|
||||
ImGui::Checkbox("Slow near food", &form.cellular_controls.slow_near_food);
|
||||
ImGui::Checkbox("Precision steering (20%)", &form.cellular_controls.precision);
|
||||
@@ -1494,10 +1545,83 @@ void candidate_glyph(const network::CellularOfferedCandidate& c, float width) {
|
||||
IM_COL32(173, 164, 184, 255), "->");
|
||||
ImGui::Dummy({width, height});
|
||||
}
|
||||
// Rules 13 (v14): a named catalog mutation, with its pro, con, chance and tuned cost. The
|
||||
// choice splits a single cell (stay as the founder or become the offspring that expresses it);
|
||||
// an organism expresses it as a whole.
|
||||
const biology::CellularMutationSpec* named_mutation(const network::CellularLifeDiagnostics* d,
|
||||
const network::CellularOfferedCandidate& c) {
|
||||
if (!d || d->members == 0 || c.capability != 0 || c.effect != 0)
|
||||
return nullptr;
|
||||
return biology::cellular_mutation(c.operator_id);
|
||||
}
|
||||
void named_offer_card(const PanelView& v, const network::CellularMutationOffer& offer,
|
||||
const network::CellularOfferedCandidate& c,
|
||||
const biology::CellularMutationSpec& spec, PanelActions& a) {
|
||||
const auto* play = v.cellular_play;
|
||||
const auto* d = diagnostics(v);
|
||||
ImGui::TextDisabled("%.1f%% chance", static_cast<double>(c.parameter) / 10'000.0);
|
||||
ImGui::PushFont(nullptr, px(18));
|
||||
ImGui::TextWrapped("%.*s", static_cast<int>(spec.name.size()), spec.name.data());
|
||||
ImGui::PopFont();
|
||||
ImGui::TextColored({0.32F, 0.90F, 0.73F, 1}, "+ %.*s", static_cast<int>(spec.pro.size()),
|
||||
spec.pro.data());
|
||||
ImGui::TextColored(amber, "- %.*s", static_cast<int>(spec.con.size()), spec.con.data());
|
||||
bool affordable = d != nullptr;
|
||||
const bool table = begin_nutrient_table("cost");
|
||||
for (std::size_t channel = 0; channel < 5; ++channel) {
|
||||
const auto need = channel == 0 ? c.cost_energy_pj : c.cost_matter_fg.at(channel - 1);
|
||||
if (need == 0)
|
||||
continue;
|
||||
// Energy may be paid with burnable matter standing in.
|
||||
const auto have =
|
||||
d ? (channel == 0 ? d->payable_energy_pj : d->reserve_matter_fg.at(channel - 1)) : 0;
|
||||
affordable = affordable && have >= need;
|
||||
if (table)
|
||||
nutrient_row(channel, nutrient_names.at(channel),
|
||||
static_cast<float>(static_cast<double>(have) / static_cast<double>(need)),
|
||||
channel == 0 ? energy_text(need) : mass_text(need));
|
||||
}
|
||||
if (table)
|
||||
ImGui::EndTable();
|
||||
const bool organism = d && d->members > 1;
|
||||
const bool adhesion = spec.effect == biology::CellularEffect::acquire_adhesion;
|
||||
if (adhesion)
|
||||
disabled_wrapped("Your cell and its split-off offspring stay joined: one organism with "
|
||||
"one genome and one reserve, growing toward Emerge.");
|
||||
else if (organism)
|
||||
disabled_wrapped("Your whole organism changes, paid from its reserve.");
|
||||
else
|
||||
disabled_wrapped("Your cell splits: both keep the change in their plan; only the "
|
||||
"offspring expresses it.");
|
||||
const bool ready =
|
||||
play && play->can_act() && v.remote && v.remote->server_tick > offer.offer_tick;
|
||||
ImGui::BeginDisabled(!affordable || !ready);
|
||||
const MutationChoice stay{offer.life_identity, offer.event_index, offer.offer_tick,
|
||||
c.operator_id, false};
|
||||
if (organism || adhesion) {
|
||||
if (ImGui::Button(affordable ? "Choose" : "Feed first", {-1, px(40)}))
|
||||
a.mutation = stay;
|
||||
} else {
|
||||
const float half = (ImGui::GetContentRegionAvail().x - ImGui::GetStyle().ItemSpacing.x) / 2;
|
||||
if (ImGui::Button(affordable ? "Stay" : "Feed first", {half, px(40)}))
|
||||
a.mutation = stay;
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Become offspring", {half, px(40)})) {
|
||||
auto become = stay;
|
||||
become.become = true;
|
||||
a.mutation = become;
|
||||
}
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
void offer_card(const PanelView& v, const network::CellularMutationOffer& offer,
|
||||
const network::CellularOfferedCandidate& c, PanelActions& a) {
|
||||
const auto* play = v.cellular_play;
|
||||
const auto* d = diagnostics(v);
|
||||
if (const auto* spec = named_mutation(d, c)) {
|
||||
named_offer_card(v, offer, c, *spec, a);
|
||||
return;
|
||||
}
|
||||
ImGui::TextDisabled("%s", capability_kinds.at(c.capability));
|
||||
const float width = ImGui::GetContentRegionAvail().x;
|
||||
candidate_glyph(c, width);
|
||||
@@ -1573,10 +1697,14 @@ void evolution_window(const PanelView& v, FormBuffers& form, PanelActions& a, bo
|
||||
ImGui::TextWrapped(
|
||||
"%s", cause == network::CellularDeathReason::starved ? "Your cell starved"
|
||||
: cause == network::CellularDeathReason::engulfed ? "Your cell was engulfed"
|
||||
: cause == network::CellularDeathReason::emerged ? "Your organism emerged"
|
||||
: "Your cell died");
|
||||
ImGui::PopFont();
|
||||
disabled_wrapped(cause == network::CellularDeathReason::starved
|
||||
? "Its reserve could not pay upkeep. Its body became food."
|
||||
: cause == network::CellularDeathReason::emerged
|
||||
? "It left the cellular region for the world, taking all its "
|
||||
"matter with it. This cellular life is complete."
|
||||
: "Its body became food for another cell.");
|
||||
ImGui::TextWrapped("Your descendants live on as wildlife. You return as a new "
|
||||
"primitive cell.");
|
||||
@@ -1602,8 +1730,12 @@ void evolution_window(const PanelView& v, FormBuffers& form, PanelActions& a, bo
|
||||
ImGui::PushFont(nullptr, px(24));
|
||||
ImGui::TextUnformatted("Shape this life");
|
||||
ImGui::PopFont();
|
||||
disabled_wrapped("Your feeding earned one change. Each trades a capability against upkeep "
|
||||
"and body mass. Buds inherit what you choose.");
|
||||
const bool named = !offer->candidates.empty() &&
|
||||
named_mutation(diagnostics(v), offer->candidates.front()) != nullptr;
|
||||
disabled_wrapped(named ? "Your play earned one change. Each has a benefit and a cost; what "
|
||||
"you do makes some more likely to appear."
|
||||
: "Your feeding earned one change. Each trades a capability against "
|
||||
"upkeep and body mass. Buds inherit what you choose.");
|
||||
const auto count = static_cast<int>(offer->candidates.size());
|
||||
const int columns = compact ? 1 : std::max(1, count);
|
||||
if (ImGui::BeginTable("offers", columns, ImGuiTableFlags_SizingStretchSame)) {
|
||||
|
||||
@@ -80,6 +80,7 @@ struct FormBuffers {
|
||||
bool engineering{};
|
||||
bool evolution_open{}; // The mutation window (E or the callout opens it).
|
||||
bool notes_minimized{}, vitals_minimized{}, map_minimized{};
|
||||
bool bud_become{}; // Rules 13: the next bud is the player's cell.
|
||||
CellularControls cellular_controls;
|
||||
std::array<char, client::max_field_bytes> endpoint{}, server_name{}, authority{}, grants{};
|
||||
void load(const client::ConnectForm& form);
|
||||
@@ -126,6 +127,7 @@ struct PanelActions {
|
||||
std::optional<std::pair<std::uint32_t, std::uint32_t>> feed_patch;
|
||||
bool stop_feeding{};
|
||||
std::optional<CellAction> cell_action;
|
||||
bool cell_become{}; // With a bud: continue as it (v14).
|
||||
std::optional<MutationChoice> mutation;
|
||||
bool restart_life{}, keep_unknown{};
|
||||
};
|
||||
|
||||
@@ -262,13 +262,14 @@ class RemoteSession {
|
||||
[[nodiscard]] const CellularPlay& cellular_play() const noexcept {
|
||||
return cellular_play_;
|
||||
}
|
||||
[[nodiscard]] bool request_cellular(CellAction kind, MutationChoice choice = {}) {
|
||||
[[nodiscard]] bool request_cellular(CellAction kind, MutationChoice choice = {},
|
||||
bool become = false) {
|
||||
const auto lead = cellular_lead_.lead();
|
||||
const auto tick =
|
||||
kind == CellAction::mutation
|
||||
? server_tick_
|
||||
: server_tick_ + lead + (sent_tick_ && *sent_tick_ == server_tick_ ? 1 : 0);
|
||||
if (!cellular_trial_ || !cellular_play_.queue(kind, tick, choice))
|
||||
if (!cellular_trial_ || !cellular_play_.queue(kind, tick, choice, become))
|
||||
return false;
|
||||
action_check_at_ = {};
|
||||
if (kind != CellAction::mutation)
|
||||
@@ -501,8 +502,9 @@ class RemoteSession {
|
||||
return false;
|
||||
client::RegionSessionClientConfig config;
|
||||
if (cellular_trial_)
|
||||
// Rules 12: v13 is v12 (deposits, light, producers) plus liquid motion and brake.
|
||||
config.protocol_version = network::session_protocol_v13;
|
||||
// Rules 13: v14 is v13 (deposits, light, producers, liquid motion and brake) plus the
|
||||
// revamp: become, emerge, exclusions, catalog offers and the body block.
|
||||
config.protocol_version = network::session_protocol_v14;
|
||||
const auto route = routes_.find(target_region_);
|
||||
config.transport = route != routes_.end() ? route->second : transport_;
|
||||
if (ticket_) { // A handoff: the ticket replaces a grant, once.
|
||||
@@ -634,7 +636,8 @@ class RemoteSession {
|
||||
const auto id = cellular_play_.allocate_id();
|
||||
if (id == 0 || !client_->send_cellular_action(
|
||||
id, tick, steering.intention.move_x, steering.intention.move_y,
|
||||
cellular_feed_target_, false, false, steering.intention.brake))
|
||||
cellular_feed_target_, false, false, steering.intention.brake, false,
|
||||
false, cellular_controls_.exclude))
|
||||
return;
|
||||
sent_tick_ = server_tick_;
|
||||
cellular_sent_tick_ = tick;
|
||||
@@ -652,12 +655,14 @@ class RemoteSession {
|
||||
bool sent = false;
|
||||
if (p.kind == CellAction::mutation) {
|
||||
sent = client_->send_cellular_mutation(p.id, p.tick, p.choice.life, p.choice.event,
|
||||
p.choice.offer_tick, p.choice.operator_id);
|
||||
p.choice.offer_tick, p.choice.operator_id,
|
||||
p.choice.become);
|
||||
} else if (p.state == CellActionState::queued) {
|
||||
if (p.tick > server_tick_ + cellular_lead_.lead())
|
||||
return; // Do not replace a movement/feeding intention already sent this tick.
|
||||
sent = client_->send_cellular_action(
|
||||
p.id, p.tick, 0, 0, {}, p.kind == CellAction::engulf, p.kind == CellAction::bud);
|
||||
p.id, p.tick, 0, 0, {}, p.kind == CellAction::engulf, p.kind == CellAction::bud,
|
||||
false, p.become, p.kind == CellAction::emerge, cellular_controls_.exclude);
|
||||
if (sent) {
|
||||
sent_tick_ = server_tick_; // The discrete intention owns this tick's target.
|
||||
cellular_sent_tick_ = std::max(cellular_sent_tick_, p.tick);
|
||||
@@ -1010,7 +1015,7 @@ class RemoteSession {
|
||||
[[nodiscard]] const CellularPlay& cellular_play() const noexcept {
|
||||
return cellular_play_;
|
||||
}
|
||||
[[nodiscard]] bool request_cellular(CellAction, MutationChoice = {}) {
|
||||
[[nodiscard]] bool request_cellular(CellAction, MutationChoice = {}, bool = false) {
|
||||
return false;
|
||||
}
|
||||
[[nodiscard]] bool restart_cellular() {
|
||||
|
||||
@@ -110,9 +110,9 @@ class CellularBridge {
|
||||
config.select_cellular_mutation = [&host](const network::AccountId& account,
|
||||
std::uint64_t generation,
|
||||
const network::CellularMutationAction& m) {
|
||||
const auto reply =
|
||||
host.select_mutation(account.bytes, generation, m.action_id,
|
||||
{m.life_identity, m.event_index, m.offer_tick, m.operator_id});
|
||||
const auto reply = host.select_mutation(
|
||||
account.bytes, generation, m.action_id,
|
||||
{m.life_identity, m.event_index, m.offer_tick, m.operator_id, m.become});
|
||||
server::CellularMutationAnswer answer{
|
||||
server::admit_status(reply.status), reply.tick, {}};
|
||||
if (reply.outcome)
|
||||
@@ -284,6 +284,40 @@ class CellularBridge {
|
||||
c.min_speed_um_per_s,
|
||||
c.max_speed_um_per_s};
|
||||
}
|
||||
// Rules 13 (v14): the body block. Older sessions never see it.
|
||||
diagnostics.members = life.revamp.members;
|
||||
if (const auto genome = state.archive().find(life.identity.genome)) {
|
||||
const auto& traits = genome->cellular_traits();
|
||||
const auto t = traits.value_or(biology::CellularTraits{});
|
||||
const std::array<std::uint16_t, 20> fields{
|
||||
t.density, t.upkeep_efficiency, t.growth_speed, t.collection[0],
|
||||
t.collection[1], t.collection[2], t.collection[3], t.collection[4],
|
||||
t.burn[0], t.burn[1], t.burn[2], t.burn[3],
|
||||
t.engulf_capacity, t.kill_absorption, t.litter, t.recipe[0],
|
||||
t.recipe[1], t.recipe[2], t.recipe[3], t.adhesion};
|
||||
if (traits)
|
||||
diagnostics.traits = fields;
|
||||
if (state.rules_version() >= server::cellular_lives_revamp_rules) {
|
||||
const auto& rules = state.revamp_rules();
|
||||
diagnostics.emerge_members = static_cast<std::uint16_t>(
|
||||
std::min<std::uint32_t>(rules.emerge_members, 0xFFFF));
|
||||
diagnostics.can_emerge = server::cellular_can_emerge(life, rules);
|
||||
if (feedback != state.last_tick_feedback().end() &&
|
||||
feedback->life_id == life.identity.life && feedback->tick == tick)
|
||||
diagnostics.exclude = feedback->exclude;
|
||||
const auto burn = biology::cellular_burn(
|
||||
rules.burn_pj_per_kfg,
|
||||
traits ? t.burn : std::array<std::uint16_t, 4>{100, 100, 100, 100},
|
||||
diagnostics.exclude);
|
||||
diagnostics.payable_energy_pj =
|
||||
biology::cellular_payable_energy(life.reserve, burn, false);
|
||||
} else {
|
||||
diagnostics.payable_energy_pj = life.reserve.energy.value;
|
||||
}
|
||||
}
|
||||
for (std::size_t c = 0; c < life.body.matter.size(); ++c)
|
||||
diagnostics.total_mass_fg +=
|
||||
life.body.matter[c].value + life.reserve.matter[c].value;
|
||||
view.diagnostics = diagnostics;
|
||||
view.patches.reserve(perceived->size());
|
||||
// ADR-0136 (rules 8): pools and bubbles go out as v11 deposits, the nearest 512 to
|
||||
@@ -462,6 +496,8 @@ class CellularBridge {
|
||||
? network::CellularDeathReason::starved
|
||||
: corpse->cause == biology::CellularDeathCause::engulfed
|
||||
? network::CellularDeathReason::engulfed
|
||||
: corpse->cause == biology::CellularDeathCause::emerged
|
||||
? network::CellularDeathReason::emerged
|
||||
: network::CellularDeathReason::unrecorded;
|
||||
static_cast<void>(sessions_->send_life_ended(network::AccountId{account},
|
||||
{corpse->died_tick, life_id, cause}));
|
||||
@@ -510,17 +546,23 @@ class CellularBridge {
|
||||
std::uint64_t tick) {
|
||||
const network::AccountId account{life.account};
|
||||
const auto session = sessions_->holder(account);
|
||||
const auto& progress = life.mutation;
|
||||
// Rules 13 offers are catalog offers (v14 only); earlier rules use the operator offer.
|
||||
const bool named = state.rules_version() >= server::cellular_lives_revamp_rules;
|
||||
const bool pending = named ? life.revamp.offer.count != 0 : life.mutation.offer.has_value();
|
||||
const SentOffer current{life.account, session.value_or(0), life.identity.life,
|
||||
progress.offer ? progress.event_index : 0,
|
||||
progress.offer ? progress.offer_tick : 0};
|
||||
!pending ? 0
|
||||
: named ? life.revamp.offer.event_index
|
||||
: life.mutation.event_index,
|
||||
!pending ? 0
|
||||
: named ? life.revamp.offer.offer_tick
|
||||
: life.mutation.offer_tick};
|
||||
auto sent = std::ranges::find(offers_, life.account, &SentOffer::account);
|
||||
if (sent != offers_.end() && *sent == current)
|
||||
return;
|
||||
if (!session || (!progress.offer && sent == offers_.end()))
|
||||
if (!session || (!pending && sent == offers_.end()))
|
||||
return; // Nothing to show, or no one to show it to.
|
||||
if (!sessions_->send_mutation_offer(account, server::offer_view(state, life, tick)))
|
||||
return; // Not a v10 owner (or the stream refused): retried on a later tick.
|
||||
if (!sessions_->send_mutation_offer(account, server::offer_view(state, life, tick), named))
|
||||
return; // Not a v10 (v14) owner (or the stream refused): retried on a later tick.
|
||||
if (sent != offers_.end())
|
||||
*sent = current;
|
||||
else
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
// evo-world-clone check-store --world W --region R --pg-* ... --objects DIR
|
||||
// [--reserve-mib N]
|
||||
// evo-world-clone provision --world W --region R --opening
|
||||
// development-v1|primitive-v1|cellular-v1 to cellular-v9
|
||||
// development-v1|primitive-v1|cellular-v1 to cellular-v10
|
||||
// --pg-* ... --objects DIR --build HEX [--commit HEX32] [--retain-build]
|
||||
// primitive-v1 also requires --frame N --source-id N, every --funding-*-* channel,
|
||||
// and one or more ordered --site X,Y values.
|
||||
@@ -28,7 +28,9 @@
|
||||
// cellular-v8 (ADR-0176) also requires --light-pj N. cellular-v9 (rules 12, ADR-0177)
|
||||
// is cellular-v8 followed by the liquid upgrade: it also requires --tuning FILE (the Git
|
||||
// tuning file, whose region size must match --width-um/--height-um) and accepts
|
||||
// --current-seed N (default: derived from the --commit bytes).
|
||||
// --current-seed N (default: derived from the --commit bytes). cellular-v10 (rules 13,
|
||||
// ADR-0179) is cellular-v9 followed by the revamp upgrade: it also requires
|
||||
// --revamp-tuning FILE (the Git revamp tuning file).
|
||||
// primitive-v1 and cellular-v1/v2/v3 accept --life-allocator-start N
|
||||
// (ADR-0123): the world's life-identity allocator is created once at the operator-audited
|
||||
// start N; a later run leaves it untouched and refuses one that is below N.
|
||||
@@ -74,6 +76,7 @@
|
||||
// Exit: 0 done, 2 usage, 3 source/history/database failure, 4 target/objects refused,
|
||||
// 5 target unknown, 6 compared histories differ.
|
||||
#include "evo/biology/cellular_habitat.hpp"
|
||||
#include "evo/biology/cellular_revamp_tuning.hpp"
|
||||
#include "evo/persistence/checkpoint_store.hpp"
|
||||
#include "evo/persistence/region_clone.hpp"
|
||||
#include "evo/persistence/sha256.hpp"
|
||||
@@ -127,16 +130,22 @@ struct Options {
|
||||
std::optional<std::uint64_t> light_pj; // cellular-v8/v9: pJ per square um per tick
|
||||
std::optional<std::string> tuning_path; // cellular-v9: the Git tuning file
|
||||
std::optional<std::uint64_t> current_seed;
|
||||
std::optional<biology::CellularTuning> tuning; // Parsed from tuning_path.
|
||||
std::optional<biology::CellularTuning> tuning; // Parsed from tuning_path.
|
||||
std::optional<std::string> revamp_tuning_path; // cellular-v10
|
||||
std::optional<biology::CellularRevampTuning> revamp_tuning; // Parsed from it.
|
||||
std::optional<std::uint64_t> life_allocator_start;
|
||||
std::optional<persistence::Sha256Digest> build;
|
||||
bool retain_build{};
|
||||
bool crash{};
|
||||
};
|
||||
|
||||
// The openings that declare light: cellular-v8, and cellular-v9 which adds the liquid upgrade.
|
||||
// The openings that declare light: cellular-v8, cellular-v9 which adds the liquid upgrade, and
|
||||
// cellular-v10 which adds the revamp upgrade after it.
|
||||
bool lit_opening(std::string_view opening) {
|
||||
return opening == "cellular-v8" || opening == "cellular-v9";
|
||||
return opening == "cellular-v8" || opening == "cellular-v9" || opening == "cellular-v10";
|
||||
}
|
||||
bool liquid_opening(std::string_view opening) {
|
||||
return opening == "cellular-v9" || opening == "cellular-v10";
|
||||
}
|
||||
std::optional<std::uint64_t> number(std::string_view text) {
|
||||
std::uint64_t value{};
|
||||
@@ -349,8 +358,10 @@ std::optional<Options> parse(int argc, char** argv) {
|
||||
(value == "development-v1" || value == "primitive-v1" || value == "cellular-v1" ||
|
||||
value == "cellular-v2" || value == "cellular-v3" || value == "cellular-v4" ||
|
||||
value == "cellular-v5" || value == "cellular-v6" || value == "cellular-v7" ||
|
||||
value == "cellular-v8" || value == "cellular-v9"))
|
||||
value == "cellular-v8" || value == "cellular-v9" || value == "cellular-v10"))
|
||||
o.opening = value;
|
||||
else if (o.command == "provision" && flag == "--revamp-tuning" && !value.empty())
|
||||
o.revamp_tuning_path = std::string{value};
|
||||
else if (o.command == "provision" && flag == "--light-pj" && n && *n > 0)
|
||||
o.light_pj = n;
|
||||
else if (o.command == "provision" && flag == "--tuning" && !value.empty())
|
||||
@@ -442,11 +453,31 @@ std::optional<Options> parse(int argc, char** argv) {
|
||||
return std::nullopt;
|
||||
} else if (o.opening == "cellular-v7" || lit_opening(o.opening)) {
|
||||
// Pools and bubbles only: square patches belong to the earlier openings. Only
|
||||
// cellular-v8 and v9 (ADR-0176) declare light; only v9 takes a tuning file.
|
||||
// cellular-v8 to v10 (ADR-0176) declare light; v9 and v10 take a tuning file, and
|
||||
// v10 the revamp tuning file.
|
||||
if (lit_opening(o.opening) != o.light_pj.has_value() ||
|
||||
(o.opening == "cellular-v9") != o.tuning_path.has_value() ||
|
||||
(o.current_seed && o.opening != "cellular-v9"))
|
||||
liquid_opening(o.opening) != o.tuning_path.has_value() ||
|
||||
(o.opening == "cellular-v10") != o.revamp_tuning_path.has_value() ||
|
||||
(o.current_seed && !liquid_opening(o.opening)))
|
||||
return std::nullopt;
|
||||
if (o.revamp_tuning_path) {
|
||||
std::ifstream file(*o.revamp_tuning_path, std::ios::binary);
|
||||
const std::string text{std::istreambuf_iterator<char>(file),
|
||||
std::istreambuf_iterator<char>()};
|
||||
if (!file.good() && !file.eof()) {
|
||||
std::printf("revamp tuning file unreadable: %s\n",
|
||||
o.revamp_tuning_path->c_str());
|
||||
return std::nullopt;
|
||||
}
|
||||
auto parsed = biology::parse_cellular_revamp_tuning(text);
|
||||
if (!parsed) {
|
||||
std::printf("revamp tuning file refused at line %zu (%s): %s\n",
|
||||
parsed.error().line, parsed.error().key.c_str(),
|
||||
std::string{biology::describe(parsed.error().kind)}.c_str());
|
||||
return std::nullopt;
|
||||
}
|
||||
o.revamp_tuning = *parsed;
|
||||
}
|
||||
if (o.tuning_path) {
|
||||
std::ifstream file(*o.tuning_path, std::ios::binary);
|
||||
const std::string text{std::istreambuf_iterator<char>(file),
|
||||
@@ -593,7 +624,7 @@ std::vector<std::uint8_t> probe_bytes() {
|
||||
// cellular-v9 (rules 12): the liquid rules from the tuning file, for the opening's area and
|
||||
// a current seed (given, or derived from the genesis commit's bytes 8-15).
|
||||
std::optional<server::CellularLiquidRules> liquid_rules(const Options& o) {
|
||||
if (o.opening != "cellular-v9" || !o.tuning || !o.cellular_width_um || !o.cellular_height_um)
|
||||
if (!liquid_opening(o.opening) || !o.tuning || !o.cellular_width_um || !o.cellular_height_um)
|
||||
return std::nullopt;
|
||||
std::uint64_t seed = o.current_seed.value_or(0);
|
||||
if (!o.current_seed) {
|
||||
@@ -605,18 +636,27 @@ std::optional<server::CellularLiquidRules> liquid_rules(const Options& o) {
|
||||
seed);
|
||||
}
|
||||
|
||||
// cellular-v10 (rules 13): the revamp rules from the revamp tuning file.
|
||||
std::optional<server::CellularRevampRules> revamp_rules(const Options& o) {
|
||||
if (o.opening != "cellular-v10" || !o.revamp_tuning)
|
||||
return std::nullopt;
|
||||
return server::cellular_revamp_rules(*o.revamp_tuning);
|
||||
}
|
||||
|
||||
// ADR-0176 cellular-v8: a cellular-v7 genesis taken through one empty tick and the durable
|
||||
// bundle 9 -> 10 -> 11 -> 12 -> 13 upgrades, declaring the region's light. cellular-v9 adds the
|
||||
// 13 -> 14 liquid upgrade. Resumable: it continues from whichever bundle the head has reached,
|
||||
// and does nothing at its target bundle.
|
||||
// 13 -> 14 liquid upgrade and cellular-v10 the 14 -> 15 revamp upgrade. Resumable: it continues
|
||||
// from whichever bundle the head has reached, and does nothing at its target bundle.
|
||||
int finish_photosynthesis_opening(const Options& o, persistence::Postgres& db,
|
||||
const persistence::FilesystemObjectStore& store,
|
||||
std::uint64_t frame, const persistence::Sha256Digest& build,
|
||||
std::uint64_t light_pj,
|
||||
const std::optional<server::CellularLiquidRules>& liquid) {
|
||||
const std::optional<server::CellularLiquidRules>& liquid,
|
||||
const std::optional<server::CellularRevampRules>& revamp) {
|
||||
const auto& key = o.source.key;
|
||||
const auto target =
|
||||
liquid ? persistence::cellular_v14_versions : persistence::cellular_v13_versions;
|
||||
const auto target = revamp ? persistence::cellular_v15_versions
|
||||
: liquid ? persistence::cellular_v14_versions
|
||||
: persistence::cellular_v13_versions;
|
||||
// A finished opening needs no lease: a rerun (every Argo sync's provision hook) runs
|
||||
// while the region server holds it, and must report the region rather than fail.
|
||||
if (const auto current = persistence::load_region_checkpoint(db, key, timeout); current) {
|
||||
@@ -640,7 +680,7 @@ int finish_photosynthesis_opening(const Options& o, persistence::Postgres& db,
|
||||
auto head = persistence::load_region_checkpoint(db, key, timeout);
|
||||
if (!head)
|
||||
return finish(3);
|
||||
for (unsigned step = 0; step < 7; ++step) {
|
||||
for (unsigned step = 0; step < 8; ++step) {
|
||||
const auto manifest = persistence::decode_manifest(head->manifest);
|
||||
if (!manifest || manifest->profile != persistence::CheckpointProfile::cellular_lives_v1 ||
|
||||
manifest->frame != frame)
|
||||
@@ -700,6 +740,9 @@ int finish_photosynthesis_opening(const Options& o, persistence::Postgres& db,
|
||||
else if (versions == persistence::cellular_v13_versions && liquid)
|
||||
upgraded = persistence::migrate_cellular_liquid_profile(db, store, *lease, *head, id,
|
||||
build, *liquid, timeout);
|
||||
else if (versions == persistence::cellular_v14_versions && liquid && revamp)
|
||||
upgraded = persistence::migrate_cellular_revamp_profile(db, store, *lease, *head, id,
|
||||
build, *revamp, timeout);
|
||||
else
|
||||
return finish(4);
|
||||
if (!upgraded) {
|
||||
@@ -887,9 +930,9 @@ int provision(const Options& o) {
|
||||
"--commit to resolve genesis");
|
||||
return 4;
|
||||
}
|
||||
if (const auto finished =
|
||||
finish_photosynthesis_opening(o, *db, *store, primitive_frame, build,
|
||||
o.light_pj.value_or(0), liquid_rules(o));
|
||||
if (const auto finished = finish_photosynthesis_opening(
|
||||
o, *db, *store, primitive_frame, build, o.light_pj.value_or(0),
|
||||
liquid_rules(o), revamp_rules(o));
|
||||
finished != 0)
|
||||
return finished;
|
||||
auto head = persistence::load_region_checkpoint(*db, o.source.key, timeout);
|
||||
@@ -942,9 +985,9 @@ int provision(const Options& o) {
|
||||
return 4;
|
||||
}
|
||||
if (lit_opening(o.opening)) {
|
||||
if (const auto finished =
|
||||
finish_photosynthesis_opening(o, *db, *store, primitive_frame, build,
|
||||
o.light_pj.value_or(0), liquid_rules(o));
|
||||
if (const auto finished = finish_photosynthesis_opening(
|
||||
o, *db, *store, primitive_frame, build, o.light_pj.value_or(0), liquid_rules(o),
|
||||
revamp_rules(o));
|
||||
finished != 0)
|
||||
return finished;
|
||||
auto head = persistence::load_region_checkpoint(*db, o.source.key, timeout);
|
||||
@@ -1091,6 +1134,15 @@ int summary(const Options& o) {
|
||||
static_cast<unsigned long long>(play->unrecorded),
|
||||
static_cast<unsigned long long>(play->owned_deaths),
|
||||
static_cast<unsigned long long>(play->wildlife_deaths));
|
||||
std::printf("revamp merged=%llu emerged=%llu organisms=%llu largest=%llu offers_pending=%llu "
|
||||
"offers_earned=%llu spent_fg=%llu\n",
|
||||
static_cast<unsigned long long>(play->merged),
|
||||
static_cast<unsigned long long>(play->emerged),
|
||||
static_cast<unsigned long long>(play->organisms),
|
||||
static_cast<unsigned long long>(play->largest_organism),
|
||||
static_cast<unsigned long long>(play->offers_pending),
|
||||
static_cast<unsigned long long>(play->offers_earned),
|
||||
static_cast<unsigned long long>(play->spent_matter_fg));
|
||||
std::printf("lifespan_ticks min=%llu median=%llu max=%llu\n",
|
||||
static_cast<unsigned long long>(play->lifespan_min),
|
||||
static_cast<unsigned long long>(play->lifespan_median),
|
||||
|
||||
Reference in New Issue
Block a user