feat(cellular): seed dev wildlife and tune budding playtests
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m27s
Foundation / postgres-tools (push) Successful in 30s
Foundation / server-image (push) Successful in 4m16s
Foundation / image (push) Successful in 4m54s

This commit is contained in:
dingo
2026-10-26 12:01:57 -04:00
parent 18a64a29cd
commit ff121c3ed1
32 changed files with 738 additions and 78 deletions
+89 -3
View File
@@ -1,3 +1,5 @@
#include "evo/biology/budding.hpp"
#include "evo/biology/founder.hpp"
#include "evo/server/lifecycle/cellular_batch.hpp"
#include "evo/server/lifecycle/cellular_play_summary.hpp"
#include "fixtures/cellular_ecology.hpp"
@@ -72,7 +74,10 @@ LifeAccount account(std::uint8_t last) {
}
// A rules-13 region with a founder 5 born before the upgrade and a founder 6 born after it.
Owner revamp_region(std::uint32_t essential = 250) {
Owner revamp_region(std::uint32_t essential = 250, std::uint64_t fee_pj = 0) {
auto rules = revamp(essential);
rules.bud_fee.energy.value = fee_pj;
rules.bud_fee_scale_percent = fee_pj == 0 ? 0 : 100;
auto state = opening(7, true, 2, false); // Funds two founders.
checked(state->advance_tick({}), "genesis tick");
state = checked(state->migration_upgrade_candidate(), "boundary upgrade");
@@ -84,10 +89,10 @@ Owner revamp_region(std::uint32_t essential = 250) {
state = checked(state->birth_candidate({account(1), 1}, {100, 100, 100, 100, {state->tick()}}),
"founder 5 birth");
require(!state->revamp_upgrade_candidate(revamp(1'001)), "an invalid essential share accepted");
state = checked(state->revamp_upgrade_candidate(revamp(essential)), "revamp upgrade");
state = checked(state->revamp_upgrade_candidate(rules), "revamp upgrade");
require(state->format_version() == cellular_lives_revamp_format &&
state->rules_version() == cellular_lives_revamp_rules &&
state->revamp_rules() == revamp(essential) && state->liquid_rules() == liquid() &&
state->revamp_rules() == rules && state->liquid_rules() == liquid() &&
state->flow_field() != nullptr && !state->revamp_upgrade_candidate(revamp()),
"revamp upgrade repeated, wrong versions or lost rules");
state = checked(state->birth_candidate({account(2), 1}, {101, 101, 101, 101, {state->tick()}}),
@@ -125,6 +130,85 @@ void closed(const CellularLives& state) {
require(state.current_total() == expected, "revamp region broke closure");
}
void starting_wildlife_is_a_funded_opening() {
auto source = opening(77, true, 64, false);
checked(source->advance_tick({}), "opening tick");
source = checked(source->migration_upgrade_candidate(), "boundary");
source = checked(source->maturation_upgrade_candidate(), "maturation");
source = checked(source->inheritance_upgrade_candidate(), "inheritance");
source = checked(source->photosynthesis_upgrade_candidate({0, 1, {0}}), "light");
source = checked(source->liquid_upgrade_candidate(liquid()), "liquid");
const auto before = source->snapshot();
auto seeded = checked(source->revamp_upgrade_candidate(revamp(), 32, 900'000), "wildlife");
require(source->snapshot() == before && seeded->lives().size() == 32,
"seeding changed source or count");
auto again = checked(source->revamp_upgrade_candidate(revamp(), 32, 900'000), "same seed");
require(again->snapshot() == seeded->snapshot(), "opening is not deterministic");
require(!seeded->revamp_upgrade_candidate(revamp(), 32, 900'000), "reseeded a region");
require(!source->revamp_upgrade_candidate(revamp(), 256, 900'000), "accepted excessive count");
require(!source->revamp_upgrade_candidate(revamp(), 1, 0), "accepted zero identity");
require(!source->revamp_upgrade_candidate(revamp(), 1, cellular_bud_namespace),
"accepted bud namespace for a root");
require(!source->revamp_upgrade_candidate(revamp(), 0, 900'000), "accepted unused identity");
require(restore(*seeded)->snapshot() == seeded->snapshot(), "fixture restore diverged");
bool varied = false;
for (const auto& life : seeded->lives()) {
const auto genome = seeded->archive().find(life.identity.genome);
require(genome && life.account == LifeAccount{} && life.parent_life == 0 &&
life.growth == biology::GrowthState{1000, 0} &&
life.reserve.matter == accounting::Inventory{}.matter,
"fixture changed founder starting rules");
const auto budget =
checked(biology::metabolic_budget(*genome, life.growth,
{seeded->ambient_temperature_millikelvin(), {}}, 1000,
seeded->revamp_rules().body),
"wildlife budget");
require(life.reserve.energy.value ==
budget.demand.value * biology::founder_reserve_seconds &&
life.body == budget.body && life.offspring_genome == genome->id(),
"wildlife endowment or inherited plan wrong");
varied = varied || genome->cellular_traits() != biology::founder_cellular_traits;
}
require(varied && seeded->nursery() != source->nursery(), "wildlife was free or unvaried");
closed(*seeded);
for (int tick = 0; tick < 5; ++tick) {
const auto intents =
checked(wildlife_intents(*seeded, seeded->tick() + 1), "wildlife intents");
checked(seeded->advance_tick(intents), "wildlife tick");
closed(*seeded);
}
require(restore(*seeded)->snapshot() == seeded->snapshot(), "running fixture restore");
auto poor = opening(77, true, 1, false);
checked(poor->advance_tick({}), "poor tick");
poor = checked(poor->migration_upgrade_candidate(), "poor boundary");
poor = checked(poor->maturation_upgrade_candidate(), "poor maturation");
poor = checked(poor->inheritance_upgrade_candidate(), "poor inheritance");
poor = checked(poor->photosynthesis_upgrade_candidate({0, 1, {0}}), "poor light");
poor = checked(poor->liquid_upgrade_candidate(liquid()), "poor liquid");
const auto poor_before = poor->snapshot();
require(!poor->revamp_upgrade_candidate(revamp(), 32, 900'000) &&
poor->snapshot() == poor_before,
"insufficient nursery was not atomic");
}
void shown_bud_charge_includes_the_fee() {
auto state = revamp_region();
const auto& life = state->lives().back();
const auto genome = state->archive().find(life.identity.genome);
require(genome.has_value(), "founder genome");
require(state->budding_cost(life.identity.life) ==
biology::bud_cost(*genome, state->ambient_temperature_millikelvin()),
"zero-fee founder charge changed");
require(!state->budding_cost(999'999), "cost for missing life");
auto paid = revamp_region(250, 250'000);
const auto shown = state->budding_cost(life.identity.life);
if (!shown)
throw std::runtime_error("missing shown cost");
auto expected = shown.value();
expected.energy.value += 250'000;
require(paid->budding_cost(life.identity.life) == expected, "shown charge omitted the fee");
}
void upgrade_and_restore() {
const auto state = revamp_region(400);
const auto copy = restore(*state);
@@ -680,6 +764,8 @@ void trace_replays() {
} // namespace
int main() try {
starting_wildlife_is_a_funded_opening();
shown_bud_charge_includes_the_fee();
upgrade_and_restore();
mixed_generations_tick_and_continue();
the_spent_pool_drips_back();