M12.2: select and qualify exact cellular local cohorts
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m19s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (tsan) (push) Canceled after 6m24s
Foundation / checks (network) (push) Canceled after 6m33s
Foundation / checks (postgres) (push) Canceled after 6m34s
Foundation / checks (checks) (push) Canceled after 6m44s
Foundation / checks (client) (push) Canceled after 6m44s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m19s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (tsan) (push) Canceled after 6m24s
Foundation / checks (network) (push) Canceled after 6m33s
Foundation / checks (postgres) (push) Canceled after 6m34s
Foundation / checks (checks) (push) Canceled after 6m44s
Foundation / checks (client) (push) Canceled after 6m44s
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
// ADR-0138: current cellular exact control; no aggregate model or runtime policy.
|
||||
#include "../../tests/fixtures/cellular_ecology.hpp"
|
||||
#include "evo/server/lifecycle/cellular_batch.hpp"
|
||||
#include "evo/server/lifecycle/cellular_play_summary.hpp"
|
||||
#include "evo/server/lifecycle/wildlife_controller.hpp"
|
||||
@@ -23,26 +24,9 @@ namespace {
|
||||
using namespace evo;
|
||||
using namespace evo::server;
|
||||
using accounting::Inventory;
|
||||
using Owner = std::unique_ptr<CellularLives>;
|
||||
using namespace evo::fixture;
|
||||
using Clock = std::chrono::steady_clock;
|
||||
|
||||
void require(bool condition, const char* message) {
|
||||
if (!condition)
|
||||
throw std::runtime_error(message);
|
||||
}
|
||||
template <typename T, typename E> T checked(std::expected<T, E> result, const char* message) {
|
||||
if (!result)
|
||||
throw std::runtime_error(std::string{message} + ": " +
|
||||
std::to_string(static_cast<unsigned>(result.error())));
|
||||
return std::move(*result);
|
||||
}
|
||||
|
||||
Owner restore(const CellularLives& state) {
|
||||
return checked(CellularLives::restore(state.snapshot(), state.world(), state.region(),
|
||||
state.frame(), state.tick()),
|
||||
"reference restore");
|
||||
}
|
||||
|
||||
std::uint64_t fingerprint(const CellularLives& state) {
|
||||
std::uint64_t value = 14695981039346656037ULL;
|
||||
for (const auto byte : state.snapshot())
|
||||
@@ -50,133 +34,6 @@ std::uint64_t fingerprint(const CellularLives& state) {
|
||||
return value; // Reproducibility fingerprint only, never an authenticity proof.
|
||||
}
|
||||
|
||||
Owner opening(std::uint64_t seed, bool rich) {
|
||||
constexpr std::uint32_t side = 6'000;
|
||||
const auto world = 200 + seed;
|
||||
const auto endowment = checked(biology::primitive_endowment(biology::primitive_founder_v3),
|
||||
"reference founder endowment");
|
||||
auto funding = endowment.body;
|
||||
funding.energy.value = 4 * (endowment.reserve.energy.value + endowment.construction.value);
|
||||
for (auto& channel : funding.matter)
|
||||
channel.value *= 4;
|
||||
const std::vector<SpawnSite> sites{
|
||||
{1'000, 1'000}, {1'000, 4'000}, {4'000, 1'000}, {4'000, 4'000}};
|
||||
auto primitive =
|
||||
checked(PrimitiveLives::create({world, 1, 1, 17, funding, sites}), "reference nursery");
|
||||
std::vector<biology::CellularPatch> pools;
|
||||
for (const auto& site : sites) {
|
||||
biology::CellularPatch pool;
|
||||
pool.address = {static_cast<std::uint32_t>(site.x_um),
|
||||
static_cast<std::uint32_t>(site.y_um)};
|
||||
pool.radius_um = 500;
|
||||
pool.source = 18;
|
||||
pool.stock.energy.value = rich ? 1'000'000'000'000ULL : 0;
|
||||
for (auto& channel : pool.stock.matter)
|
||||
channel.value = rich ? 1'000'000'000'000ULL : 1'000;
|
||||
pools.push_back(pool);
|
||||
}
|
||||
Inventory amount{{rich ? 1'000'000ULL : 10'000ULL}, {}};
|
||||
for (auto& channel : amount.matter)
|
||||
channel.value = rich ? 100'000 : 10;
|
||||
auto config = checked(
|
||||
biology::scatter_deposits({world, 1, 1, side, side, {}}, pools, {64, 19, amount, seed}),
|
||||
"reference deposits");
|
||||
if (rich) {
|
||||
// Explicit finite contact food on each founding site. It is not a reserve grant
|
||||
// or replenishment; the owner must acquire and spend it through real biology.
|
||||
for (const auto& site : sites)
|
||||
for (std::uint32_t channel = 0; channel < 5; ++channel) {
|
||||
biology::CellularPatch mote;
|
||||
mote.address = {static_cast<std::uint32_t>(site.x_um) + 10 + channel * 2,
|
||||
static_cast<std::uint32_t>(site.y_um) + 10};
|
||||
mote.source = 20;
|
||||
mote.id = config.next_deposit++;
|
||||
mote.radius_um = biology::cellular_mote_radius_um;
|
||||
mote.kind = biology::CellularDepositKind::mote;
|
||||
if (channel == 0)
|
||||
mote.stock.energy.value = 1'000'000'000'000ULL;
|
||||
else
|
||||
mote.stock.matter[channel - 1].value = 1'000'000'000'000ULL;
|
||||
config.patches.push_back(mote);
|
||||
}
|
||||
std::ranges::sort(config.patches, {}, &biology::CellularPatch::address);
|
||||
}
|
||||
auto habitat =
|
||||
checked(biology::CellularHabitat::create(std::move(config)), "reference habitat");
|
||||
auto state =
|
||||
checked(CellularLives::create(*primitive, std::move(habitat), {{side, side}, 0, 293'150},
|
||||
CellularLivesProfile::foraging),
|
||||
"reference cellular owner");
|
||||
require(state->advance_tick(std::span<const CellularLifeIntent>{}).has_value(),
|
||||
"reference genesis tick");
|
||||
for (std::uint64_t index = 0; index < 4; ++index) {
|
||||
LifeRequest request{};
|
||||
request.account.back() = static_cast<std::uint8_t>(index + 1);
|
||||
request.action = 1;
|
||||
const auto identity = 100 + index;
|
||||
state = checked(state->birth_candidate(
|
||||
request, {identity, identity, identity, identity, {state->tick()}}),
|
||||
"reference funded birth");
|
||||
}
|
||||
require(state->rules_version() == cellular_lives_foraging_rules &&
|
||||
state->habitat().config().format == biology::cellular_habitat_deposit_format,
|
||||
"reference version bundle");
|
||||
return state;
|
||||
}
|
||||
|
||||
CellularTickIntents inputs(const CellularLives& state, std::uint64_t seed,
|
||||
const std::set<std::uint64_t>& mutated) {
|
||||
CellularTickIntents tick;
|
||||
const auto wildlife = checked(wildlife_intents(state, state.tick() + 1), "reference wildlife");
|
||||
for (const auto& life : state.lives()) {
|
||||
CellularLifeIntent intent{life.identity.life, {}};
|
||||
if (life.account == LifeAccount{}) {
|
||||
const auto found =
|
||||
std::ranges::find(wildlife, life.identity.life, &CellularLifeIntent::life_id);
|
||||
require(found != wildlife.end(), "reference missing wildlife intention");
|
||||
intent = *found;
|
||||
} else {
|
||||
const auto phase = (state.tick() + 1) % 1024;
|
||||
intent.intent.frozen = life.identity.life == 100 && phase >= 128 && phase < 384;
|
||||
if (!intent.intent.frozen) {
|
||||
// Fixture players request real actions; the owner alone admits/funds them.
|
||||
if ((state.tick() + 1 + life.identity.life) % 100 == 0)
|
||||
intent.intent.bud = true;
|
||||
else if ((state.tick() + 1) % 197 == 0)
|
||||
intent.intent.engulf = true;
|
||||
else if (state.tick() >= 4096) {
|
||||
const auto direction = (state.tick() / 64 + life.identity.life + seed) % 4;
|
||||
constexpr std::array<biology::CellularIntent, 4> directions{
|
||||
{{1'000, 0}, {0, 1'000}, {-1'000, 0}, {0, -1'000}}};
|
||||
intent.intent.movement = directions[direction];
|
||||
}
|
||||
}
|
||||
if (!intent.intent.frozen && life.presence == CellularPresence::active &&
|
||||
!mutated.contains(life.identity.life) && life.mutation.offer) {
|
||||
const auto genome =
|
||||
checked(state.archive().find(life.identity.genome), "reference offered genome");
|
||||
const auto& offer = *life.mutation.offer;
|
||||
for (std::size_t offset = 0; offset < offer.candidates.size(); ++offset) {
|
||||
const auto& choice =
|
||||
offer.candidates[(offset + seed) % offer.candidates.size()];
|
||||
const auto successor = 1'000'000 + state.tick() * 4 + life.identity.life - 100;
|
||||
const auto funded =
|
||||
biology::fund_mutation(genome, offer.context, offer, choice.operator_id,
|
||||
successor, successor, life.reserve);
|
||||
if (funded) {
|
||||
tick.mutations.push_back({life.identity.life, life.mutation.event_index,
|
||||
life.mutation.offer_tick, successor,
|
||||
choice.operator_id});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tick.lives.push_back(intent);
|
||||
}
|
||||
return tick;
|
||||
}
|
||||
|
||||
struct Replay {
|
||||
std::uint64_t width{};
|
||||
Owner state;
|
||||
|
||||
Reference in New Issue
Block a user