feat(cellular): energy cycles back through the spent pool (ADR-0182 section 14)
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m42s
Foundation / checks (checks) (push) Successful in 6s
Foundation / checks (client) (push) Successful in 5s
Foundation / postgres-tools (push) Successful in 31s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / server-image (push) Successful in 4m45s
Foundation / checks (network) (push) Successful in 4s
Foundation / image (push) Successful in 5m31s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m42s
Foundation / checks (checks) (push) Successful in 6s
Foundation / checks (client) (push) Successful in 5s
Foundation / postgres-tools (push) Successful in 31s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / server-image (push) Successful in 4m45s
Foundation / checks (network) (push) Successful in 4s
Foundation / image (push) Successful in 5m31s
Energy cells used went to the region's heat store and never returned, so a region without photosynthesizers drained: region 16's wildlife ate its energy and starved, and its matter-only drip filled the deposit limit. Two optional rules-13 tuning keys, adoptable live: spent.heat_recycle_per_mille moves that share of the heat store to the spent pool at the end of every tick, before the drip (1,000 closes the loop and returns heat built up before), and spent.drip_absorb lets a drip at the deposit limit join the first existing bubble at or after its spot. Both use the reserved word after the offer interval, so rules without them keep their bytes, digests, checkpoints and replays. The DEV revamp file turns both on. The region view reports heat and the cycle; the portal counts heat in the region's energy and ledger. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -48,6 +48,9 @@ constexpr std::array fields{
|
||||
Field{"spent.drip_interval_ticks", &CellularRevampTuning::spent_drip_interval_ticks, 0, 72'000},
|
||||
Field{"spent.drip_bubble_pj", &CellularRevampTuning::spent_drip_bubble_pj, 0, amount_limit},
|
||||
Field{"spent.drip_bubble_fg", &CellularRevampTuning::spent_drip_bubble_fg, 0, amount_limit},
|
||||
Field{"spent.heat_recycle_per_mille", &CellularRevampTuning::spent_heat_recycle_per_mille, 0,
|
||||
1'000},
|
||||
Field{"spent.drip_absorb", &CellularRevampTuning::spent_drip_absorb, 0, 1},
|
||||
Field{"mutation.options", &CellularRevampTuning::mutation_options, 1, 10},
|
||||
Field{"mutation.floor_ppm", &CellularRevampTuning::mutation_floor_ppm, 0, 1'000'000},
|
||||
Field{"mutation.cap_ppm", &CellularRevampTuning::mutation_cap_ppm, 1, 1'000'000},
|
||||
@@ -257,6 +260,8 @@ parse_cellular_revamp_tuning(std::string_view text) {
|
||||
if (!seen.at(index) && fields.at(index).key != "playtest.starting_wildlife_cells" &&
|
||||
fields.at(index).key != "feeding.collection_percent" &&
|
||||
fields.at(index).key != "feeding.split_evenly" &&
|
||||
fields.at(index).key != "spent.heat_recycle_per_mille" &&
|
||||
fields.at(index).key != "spent.drip_absorb" &&
|
||||
fields.at(index).key != "reproduction.safety_version" &&
|
||||
fields.at(index).key != "body.growth_reserve_seconds" &&
|
||||
fields.at(index).key != "reproduction.split_launch_um_per_s")
|
||||
|
||||
@@ -80,7 +80,8 @@ std::string render_cellular_admin_view(const CellularLives& state,
|
||||
append(out, state.area().height_um);
|
||||
out += "],\"spent\":[";
|
||||
append_inventory(out, state.spent());
|
||||
out.push_back(']');
|
||||
out += "],\"heat\":";
|
||||
append(out, state.heat().energy.value);
|
||||
if (state.rules_version() >= cellular_lives_revamp_rules) {
|
||||
const auto& rules = state.revamp_rules();
|
||||
out += ",\"drip\":[";
|
||||
@@ -89,7 +90,9 @@ std::string render_cellular_admin_view(const CellularLives& state,
|
||||
append(out, rules.drip_bubble_pj);
|
||||
out.push_back(',');
|
||||
append(out, rules.drip_bubble_fg);
|
||||
out.push_back(']');
|
||||
out.push_back(',');
|
||||
append(out, rules.heat_recycle_per_thousand);
|
||||
out += rules.drip_absorb ? ",1]" : ",0]";
|
||||
}
|
||||
out += ",\"cells_total\":";
|
||||
append(out, lives.size());
|
||||
|
||||
@@ -62,7 +62,9 @@ constexpr std::size_t cellular_life_motion_bytes = 20;
|
||||
// reserved zero, 32), the catalog bounds (five 4-byte fields, a reserved zero and the carbon
|
||||
// gate, 32), the offer interval and a reserved zero (8), and 49 mutation tunables of 80 bytes.
|
||||
// ADR-0181 uses the growth/offer/bounds reserved words for safety revision,
|
||||
// growth fuel seconds and split launch speed; historical zeros retain their law.
|
||||
// growth fuel seconds and split launch speed; ADR-0182 section 14 the offer interval's for the
|
||||
// heat recycle share (low 16 bits) and the absorbing drip (bit 16). Historical zeros retain
|
||||
// their law.
|
||||
constexpr std::size_t cellular_revamp_mutation_bytes = 80;
|
||||
// Then the reproduction tunables: split share, split growth, organism cap, fee scale (16) and
|
||||
// the bud fee (40).
|
||||
@@ -235,7 +237,8 @@ void write_revamp_offers(Writer& out, const CellularRevampRules& r) {
|
||||
out.put(r.split_launch_um_per_s, 4);
|
||||
out.put(b.carbon_for_light);
|
||||
out.put(r.offer_interval_ticks, 4);
|
||||
out.put(0, 4);
|
||||
// The offer interval's reserved word: the heat recycle share and the absorbing drip.
|
||||
out.put(r.heat_recycle_per_thousand | (r.drip_absorb ? 0x10000U : 0U), 4);
|
||||
for (const auto& m : r.mutations) {
|
||||
out.put(m.enabled ? 1 : 0, 1);
|
||||
out.zeros(3);
|
||||
@@ -282,7 +285,10 @@ bool read_revamp_offers(Reader& in, CellularRevampRules& r) {
|
||||
r.split_launch_um_per_s = u32();
|
||||
b.carbon_for_light = in.get();
|
||||
r.offer_interval_ticks = u32();
|
||||
zero = zero && in.get(4) == 0;
|
||||
const auto cycle = in.get(4);
|
||||
r.heat_recycle_per_thousand = static_cast<std::uint32_t>(cycle & 0xFFFFU);
|
||||
r.drip_absorb = (cycle & 0x10000U) != 0;
|
||||
zero = zero && (cycle & ~0x1FFFFULL) == 0;
|
||||
for (auto& m : r.mutations) {
|
||||
const auto enabled = in.get(1);
|
||||
zero = zero && enabled <= 1 && in.get(3) == 0;
|
||||
@@ -3988,6 +3994,17 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
|
||||
}
|
||||
habitat_config.patches.insert(at, made);
|
||||
}
|
||||
// ADR-0182 section 14: a share of the region's heat returns to the spent pool before the
|
||||
// drip, so the energy cells used cycles back like matter instead of draining away.
|
||||
if (revamp_rules && state_->revamp.heat_recycle_per_thousand != 0) {
|
||||
const auto heat = next_heat.energy.value;
|
||||
const auto share = state_->revamp.heat_recycle_per_thousand;
|
||||
const auto recycled = heat / 1'000 * share + heat % 1'000 * share / 1'000;
|
||||
if (recycled > std::numeric_limits<std::uint64_t>::max() - next_spent.energy.value)
|
||||
return std::unexpected{CellularLivesError::overflow};
|
||||
next_heat.energy.value -= recycled;
|
||||
next_spent.energy.value += recycled;
|
||||
}
|
||||
// Rules 13: the spent pool drips back as bubbles at seeded random spots.
|
||||
if (revamp_rules &&
|
||||
!cellular_drip_spent(habitat_config, next_spent, state_->revamp, state_->world,
|
||||
|
||||
@@ -52,6 +52,7 @@ bool cellular_revamp_valid(const CellularRevampRules& rules) noexcept {
|
||||
step.engulf_ratio_milli <= 1'000'000 && step.engulf_reserve_percent <= 100 &&
|
||||
step.kill_bubble_per_thousand <= 1'000 && rules.drip_interval_ticks <= 72'000 &&
|
||||
rules.drip_bubble_pj <= most && rules.drip_bubble_fg <= most &&
|
||||
rules.heat_recycle_per_thousand <= 1'000 &&
|
||||
(rules.drip_interval_ticks == 0 ||
|
||||
(rules.drip_bubble_pj != 0 && rules.drip_bubble_fg != 0)) &&
|
||||
rules.reserve_load_per_thousand <= 1'000 &&
|
||||
@@ -59,9 +60,8 @@ bool cellular_revamp_valid(const CellularRevampRules& rules) noexcept {
|
||||
rules.split_share_per_thousand < 1'000 && rules.split_min_growth != 0 &&
|
||||
rules.split_min_growth <= 1'000 && rules.bud_fee_scale_percent <= 100 &&
|
||||
rules.bud_fee.energy.value <= most &&
|
||||
std::ranges::all_of(
|
||||
rules.bud_fee.matter,
|
||||
[](const accounting::Femtograms& f) { return f.value <= most; }) &&
|
||||
std::ranges::all_of(rules.bud_fee.matter,
|
||||
[](const accounting::Femtograms& f) { return f.value <= most; }) &&
|
||||
rules.organism_cap != 0 && rules.organism_cap <= biology::max_cellular_tick_lives &&
|
||||
rules.organism_load_per_thousand <= 10'000 && rules.emerge_members >= 2 &&
|
||||
rules.emerge_members <= 10'000 && rules.emerge_mass_fg <= most &&
|
||||
@@ -105,10 +105,34 @@ bool cellular_drip_spent(biology::CellularHabitatConfig& config, accounting::Inv
|
||||
// Both draws happen for every channel, so a channel's spot never depends on another's.
|
||||
const auto x = random.next();
|
||||
const auto y = random.next();
|
||||
if (pool == 0 || config.patches.size() >= biology::max_cellular_liquid_deposits)
|
||||
if (pool == 0)
|
||||
continue;
|
||||
biology::CellularPatchAddress address{static_cast<std::uint32_t>(x % config.width_um),
|
||||
static_cast<std::uint32_t>(y % config.height_um)};
|
||||
if (config.patches.size() >= biology::max_cellular_liquid_deposits) {
|
||||
if (!rules.drip_absorb)
|
||||
continue;
|
||||
// At the limit an existing bubble takes the drip, as if absorbing it from the
|
||||
// water: the first bubble at or after the spot in address order, wrapping.
|
||||
const auto start = std::ranges::lower_bound(config.patches, address, {}, by_address);
|
||||
const auto is_bubble = [](const biology::CellularPatch& patch) {
|
||||
return patch.kind == biology::CellularDepositKind::mote;
|
||||
};
|
||||
auto host = std::ranges::find_if(start, config.patches.end(), is_bubble);
|
||||
if (host == config.patches.end()) {
|
||||
host = std::ranges::find_if(config.patches.begin(), start, is_bubble);
|
||||
if (host == start)
|
||||
continue; // No bubble at all: the drip waits.
|
||||
}
|
||||
const auto amount = std::min(pool, cap);
|
||||
auto& stock =
|
||||
channel == 0 ? host->stock.energy.value : host->stock.matter[channel - 1].value;
|
||||
if (amount > std::numeric_limits<std::uint64_t>::max() - stock)
|
||||
continue;
|
||||
stock += amount;
|
||||
pool -= amount;
|
||||
continue;
|
||||
}
|
||||
auto at = std::ranges::lower_bound(config.patches, address, {}, by_address);
|
||||
while (at != config.patches.end() && at->address == address) {
|
||||
address.x_um = address.x_um + 1 < config.width_um ? address.x_um + 1 : 0;
|
||||
@@ -301,6 +325,8 @@ CellularRevampRules cellular_revamp_rules(const biology::CellularRevampTuning& t
|
||||
.drip_interval_ticks = u32(t.spent_drip_interval_ticks),
|
||||
.drip_bubble_pj = u64(t.spent_drip_bubble_pj),
|
||||
.drip_bubble_fg = u64(t.spent_drip_bubble_fg),
|
||||
.heat_recycle_per_thousand = u32(t.spent_heat_recycle_per_mille),
|
||||
.drip_absorb = t.spent_drip_absorb != 0,
|
||||
.reserve_load_per_thousand = u32(t.body_reserve_load_per_mille),
|
||||
.growth_per_tick_centi_mille = u32(t.body_growth_per_tick_centi_mille),
|
||||
.offers = {.options = u32(t.mutation_options),
|
||||
|
||||
Reference in New Issue
Block a user