feat(admin): take reserve, cull wildlife, wildlife cap, fresh bud costs (schema 67)
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m34s
Foundation / postgres-tools (push) Successful in 26s
Foundation / server-image (push) Successful in 4m30s
Foundation / image (push) Successful in 5m46s
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m34s
Foundation / postgres-tools (push) Successful in 26s
Foundation / server-image (push) Successful in 4m30s
Foundation / image (push) Successful in 5m46s
ADR-0182 section 16, from playtesting region 16 at its 256-life cap. - Bud costs: the region host's cache of each genome's bud cost was keyed by genome only, so after a tuning adoption the client kept the old cost (or "cannot bud"). It now clears when the rules' encoding changes. - Wildlife cap: reproduction.wildlife_cap (optional, 0..organism cap, 0 = the organism cap) refuses buds of parents without an account at that many lives, keeping the slots above it for players. Bits 17-31 of the energy-cycle word, so older rules keep their bytes. DEV file: 200. - Schema 67: admin command kinds take_reserve (8: up to the amounts from a life's reserve to the spent pool) and remove_wildlife (9: every life without an account, as remove_cell). - Region view: caps; the portal shows lives against the cap. - Portal: Take reserve in the inspector, Remove all wildlife, and marking cells on the map (shift+click, shift+drag) for bulk removal; the guided editor lists optional keys the base revision lacks. - Client: a refused bud says the region may be full. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -237,8 +237,10 @@ 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);
|
||||
// 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);
|
||||
// The offer interval's reserved word: the heat recycle share (bits 0-15), the absorbing
|
||||
// drip (bit 16) and the wildlife cap (bits 17-31).
|
||||
out.put(r.heat_recycle_per_thousand | (r.drip_absorb ? 0x10000U : 0U) | (r.wildlife_cap << 17U),
|
||||
4);
|
||||
for (const auto& m : r.mutations) {
|
||||
out.put(m.enabled ? 1 : 0, 1);
|
||||
out.zeros(3);
|
||||
@@ -288,7 +290,8 @@ bool read_revamp_offers(Reader& in, CellularRevampRules& r) {
|
||||
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;
|
||||
r.wildlife_cap = static_cast<std::uint32_t>(cycle >> 17U);
|
||||
zero = zero && (cycle >> 32U) == 0;
|
||||
for (auto& m : r.mutations) {
|
||||
const auto enabled = in.get(1);
|
||||
zero = zero && enabled <= 1 && in.get(3) == 0;
|
||||
@@ -1537,6 +1540,10 @@ bool cellular_admin_command_valid(const CellularAdminCommand& c) noexcept {
|
||||
c.target <= cellular_bud_namespace - c.count;
|
||||
case CellularAdminKind::adopt_tuning:
|
||||
return c.id != 0 && c.count == 0 && c.target != 0 && some && c.amount.matter[3].value == 0;
|
||||
case CellularAdminKind::take_reserve:
|
||||
return c.id != 0 && c.target != 0 && c.count == 0 && some;
|
||||
case CellularAdminKind::remove_wildlife:
|
||||
return c.id != 0 && c.target == 0 && c.count == 0 && !some;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1556,6 +1563,35 @@ CellularLives::admin_candidate(std::span<const CellularAdminCommand> commands,
|
||||
if (!candidate)
|
||||
return std::unexpected(candidate.error());
|
||||
std::vector<CellularAdminResult> report;
|
||||
// A removed life's body and reserve go to the spent pool, and it leaves a corpse.
|
||||
const auto remove_life = [&](State& next, std::vector<CellularOwnedLife>::iterator life) {
|
||||
if (!next.archive.record_death(life->identity.organism, {tick()}))
|
||||
return false;
|
||||
auto single = *life;
|
||||
single.revamp.members = 1; // A corpse records the single-cell extent.
|
||||
const auto extent = budget_for(
|
||||
next.archive, single, next.config.ambient_temperature_millikelvin, next.revamp.body);
|
||||
if (!extent || !add_inventory(next.spent, life->body) ||
|
||||
!add_inventory(next.spent, life->reserve))
|
||||
return false;
|
||||
CellularOwnedCorpse corpse{life->identity.life,
|
||||
life->identity.organism,
|
||||
life->source,
|
||||
tick(),
|
||||
life->position,
|
||||
life->growth,
|
||||
extent->phenotype.extent,
|
||||
{},
|
||||
biology::CellularDeathCause::removed,
|
||||
0,
|
||||
life->parent_life,
|
||||
life->offspring_genome};
|
||||
const auto at = std::ranges::lower_bound(next.corpses, corpse.organism, {},
|
||||
&CellularOwnedCorpse::organism);
|
||||
next.corpses.insert(at, corpse);
|
||||
next.lives.erase(life);
|
||||
return true;
|
||||
};
|
||||
for (const auto& command : commands) {
|
||||
// Each command works on a copy, kept only when it applies and still closes.
|
||||
auto attempt = restore((*candidate)->snapshot(), world(), region(), frame(), tick());
|
||||
@@ -1568,34 +1604,36 @@ CellularLives::admin_candidate(std::span<const CellularAdminCommand> commands,
|
||||
const bool found = life != next.lives.end() && life->identity.life == command.target;
|
||||
switch (command.kind) {
|
||||
case CellularAdminKind::remove_cell:
|
||||
if (found && next.archive.record_death(life->identity.organism, {tick()})) {
|
||||
auto single = *life;
|
||||
single.revamp.members = 1; // A corpse records the single-cell extent.
|
||||
const auto extent =
|
||||
budget_for(next.archive, single, next.config.ambient_temperature_millikelvin,
|
||||
next.revamp.body);
|
||||
if (extent && add_inventory(next.spent, life->body) &&
|
||||
add_inventory(next.spent, life->reserve)) {
|
||||
CellularOwnedCorpse corpse{life->identity.life,
|
||||
life->identity.organism,
|
||||
life->source,
|
||||
tick(),
|
||||
life->position,
|
||||
life->growth,
|
||||
extent->phenotype.extent,
|
||||
{},
|
||||
biology::CellularDeathCause::removed,
|
||||
0,
|
||||
life->parent_life,
|
||||
life->offspring_genome};
|
||||
const auto at = std::ranges::lower_bound(next.corpses, corpse.organism, {},
|
||||
&CellularOwnedCorpse::organism);
|
||||
next.corpses.insert(at, corpse);
|
||||
next.lives.erase(life);
|
||||
applied = true;
|
||||
}
|
||||
applied = found && remove_life(next, life);
|
||||
break;
|
||||
case CellularAdminKind::remove_wildlife: {
|
||||
std::vector<std::uint64_t> wild;
|
||||
for (const auto& each : next.lives)
|
||||
if (each.account == LifeAccount{})
|
||||
wild.push_back(each.identity.life);
|
||||
applied = !wild.empty();
|
||||
for (const auto id : wild) {
|
||||
const auto at = std::ranges::lower_bound(
|
||||
next.lives, id, {}, [](const auto& v) { return v.identity.life; });
|
||||
applied = applied && remove_life(next, at);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CellularAdminKind::take_reserve: {
|
||||
if (!found)
|
||||
break;
|
||||
auto amount = command.amount; // Never more than the reserve holds.
|
||||
for (std::size_t c = 0; c < 5; ++c) {
|
||||
auto& want = c == 0 ? amount.energy.value : amount.matter[c - 1].value;
|
||||
const auto have =
|
||||
c == 0 ? life->reserve.energy.value : life->reserve.matter[c - 1].value;
|
||||
want = std::min(want, have);
|
||||
}
|
||||
applied = amount != accounting::Inventory{} &&
|
||||
subtract_inventory(life->reserve, amount) &&
|
||||
add_inventory(next.spent, amount);
|
||||
break;
|
||||
}
|
||||
case CellularAdminKind::grant_reserve:
|
||||
applied = found && add_inventory(life->reserve, command.amount) &&
|
||||
add_inventory(next.boundary.incoming, command.amount);
|
||||
@@ -3604,6 +3642,9 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
|
||||
if (identity == 0 || !*position ||
|
||||
next_lives.size() >= biology::max_cellular_tick_lives ||
|
||||
(revamp_rules && next_lives.size() >= state_->revamp.organism_cap) ||
|
||||
(revamp_rules && parent->account == LifeAccount{} &&
|
||||
state_->revamp.wildlife_cap != 0 &&
|
||||
next_lives.size() >= state_->revamp.wildlife_cap) ||
|
||||
next_archive.organism(identity)) {
|
||||
if (!twin)
|
||||
bud_results.push_back({request.life_id, 0, CellularBudResult::no_placement});
|
||||
|
||||
Reference in New Issue
Block a user