Enforce cellular patch perception
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 39s
Foundation / checks (ecs) (push) Successful in 1m57s
Foundation / checks (postgres) (push) Failing after 51s
Foundation / checks (tsan) (push) Failing after 32s
Foundation / checks (network) (push) Failing after 3m3s
Foundation / checks (client) (push) Failing after 4m19s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped

This commit is contained in:
dingo
2026-10-10 23:41:47 -04:00
parent dae0572426
commit 82bef03138
8 changed files with 74 additions and 4 deletions
+19 -2
View File
@@ -267,14 +267,14 @@ struct CellularLives::State {
accounting::Inventory current_total{};
State(std::uint64_t world_id, std::uint64_t region_id, std::uint64_t frame_id,
CellularLivesConfig cfg, NurseryConfig nursery,
CellularLivesConfig cfg, NurseryConfig nursery_definition,
std::unique_ptr<biology::CellularHabitat> map,
std::vector<CellularOwnedLife> living, std::vector<CellularOwnedCorpse> dead,
const biology::LineageArchive& history, accounting::Inventory source,
accounting::Inventory accumulated_heat, accounting::Inventory initial,
accounting::Inventory current)
: world{world_id}, region{region_id}, frame{frame_id}, config{cfg},
nursery_config{std::move(nursery)},
nursery_config{std::move(nursery_definition)},
habitat{std::move(map)}, lives{std::move(living)}, corpses{std::move(dead)},
archive{history}, nursery{source}, heat{accumulated_heat}, opening_total{initial},
current_total{current} {}
@@ -457,6 +457,23 @@ std::vector<std::uint8_t> CellularLives::snapshot() const {
return bytes;
}
std::expected<std::vector<biology::CellularPatchPerception>, CellularLivesError>
CellularLives::perceive(std::uint64_t life_id) const {
const auto life = std::ranges::find(state_->lives, life_id, [](const auto& owned) {
return owned.identity.life;
});
if (life == state_->lives.end())
return std::unexpected{CellularLivesError::invalid_life};
const auto budget = budget_for(state_->archive, *life,
state_->config.ambient_temperature_millikelvin);
if (!budget)
return std::unexpected{budget.error()};
auto view = state_->habitat->perceive(life->position, budget->phenotype.extent);
if (!view)
return std::unexpected{CellularLivesError::habitat};
return std::move(*view);
}
std::expected<std::unique_ptr<CellularLives>, CellularLivesError>
CellularLives::restore(std::span<const std::uint8_t> bytes, std::uint64_t world,
std::uint64_t region, std::uint64_t frame, std::uint64_t tick) {