Show what a bud costs (ADR-0129 amendment)
Foundation / checks (ecs) (push) Successful in 2m20s
Foundation / checks (deploy) (push) Successful in 4m4s
Foundation / checks (tsan) (push) Successful in 9m59s
Foundation / checks (client) (push) Successful in 19m19s
Foundation / checks (network) (push) Successful in 19m24s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 32m13s
Foundation / checks (checks) (push) Canceled after 32m19s
Foundation / checks (ecs) (push) Successful in 2m20s
Foundation / checks (deploy) (push) Successful in 4m4s
Foundation / checks (tsan) (push) Successful in 9m59s
Foundation / checks (client) (push) Successful in 19m19s
Foundation / checks (network) (push) Successful in 19m24s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 32m13s
Foundation / checks (checks) (push) Canceled after 32m19s
The v10 cellular perception carries the bud cost after the diagnostics block: the energy (construction plus the bud's provision) and matter per channel one bud takes from a fully grown cell's reserve. biology::bud_cost reads it from fund_bud itself, so the shown cost is exactly the charge; the server caches it per genome. The client shows it and names the channels the reserve is short on. v10 clients must be rebuilt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "evo/biology/budding.hpp"
|
||||
#include "evo/client/organism_view.hpp"
|
||||
#include "evo/network/session_grant.hpp"
|
||||
#include "evo/server/cellular_region_host.hpp"
|
||||
@@ -18,6 +19,7 @@
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@@ -209,6 +211,11 @@ class CellularBridge {
|
||||
diagnostics.reserve_energy_pj = life.reserve.energy.value;
|
||||
for (std::size_t i = 0; i < diagnostics.reserve_matter_fg.size(); ++i)
|
||||
diagnostics.reserve_matter_fg[i] = life.reserve.matter[i].value;
|
||||
if (const auto cost = bud_cost_for(state, life.identity.genome)) {
|
||||
diagnostics.bud_cost_energy_pj = cost->energy.value;
|
||||
for (std::size_t i = 0; i < diagnostics.bud_cost_matter_fg.size(); ++i)
|
||||
diagnostics.bud_cost_matter_fg[i] = cost->matter[i].value;
|
||||
}
|
||||
const auto feedback =
|
||||
std::ranges::lower_bound(state.last_tick_feedback(), life.identity.life, {},
|
||||
&server::CellularLifeTickFeedback::life_id);
|
||||
@@ -356,6 +363,20 @@ class CellularBridge {
|
||||
}
|
||||
|
||||
private:
|
||||
// ADR-0129 amendment: a genome's bud cost is pure for this region's temperature, and
|
||||
// deriving it scans up to a thousand bodies, so it is computed once per genome.
|
||||
std::optional<accounting::Inventory> bud_cost_for(const server::CellularLives& state,
|
||||
std::uint64_t genome_id) {
|
||||
if (const auto known = bud_costs_.find(genome_id); known != bud_costs_.end())
|
||||
return known->second;
|
||||
const auto genome = state.archive().find(genome_id);
|
||||
if (!genome)
|
||||
return std::nullopt;
|
||||
if (bud_costs_.size() >= 4096)
|
||||
bud_costs_.clear(); // Bounded: recomputing is only slower.
|
||||
return bud_costs_[genome_id] =
|
||||
biology::bud_cost(*genome, state.ambient_temperature_millikelvin());
|
||||
}
|
||||
static std::uint64_t wall_seconds() {
|
||||
return static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch())
|
||||
@@ -382,6 +403,7 @@ class CellularBridge {
|
||||
friend bool operator==(const SentOffer&, const SentOffer&) = default;
|
||||
};
|
||||
std::vector<SentOffer> offers_; // Last offer view sent to each owner.
|
||||
std::map<std::uint64_t, std::optional<accounting::Inventory>> bud_costs_; // By genome.
|
||||
std::vector<std::pair<server::LifeAccount, std::uint64_t>> owned_; // At last replication.
|
||||
bool shutdown_{};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user