Close cellular starvation into corpse transfer
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 39s
Foundation / checks (ecs) (push) Successful in 1m53s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 50s
Foundation / checks (client) (push) Canceled after 2m59s
Foundation / checks (network) (push) Canceled after 2m22s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 39s
Foundation / checks (ecs) (push) Successful in 1m53s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 50s
Foundation / checks (client) (push) Canceled after 2m59s
Foundation / checks (network) (push) Canceled after 2m22s
This commit is contained in:
@@ -28,18 +28,40 @@ propose_cellular_region_step(std::uint64_t begin_tick, CellularArea area,
|
||||
|
||||
CellularRegionStepCandidate candidate{begin_tick, begin_tick + 1, {}, {}};
|
||||
candidate.lives.reserve(ordered.size());
|
||||
candidate.starved.reserve(ordered.size());
|
||||
std::vector<accounting::Inventory> patch_stock;
|
||||
patch_stock.reserve(habitat.patches().size());
|
||||
for (const auto& patch : habitat.patches())
|
||||
patch_stock.push_back(patch.stock);
|
||||
|
||||
for (const auto* life : ordered) {
|
||||
if (life->body.energy.value != 0)
|
||||
return std::unexpected{CellularRegionStepError::invalid_body};
|
||||
if (std::ranges::any_of(life->heat.matter,
|
||||
[](const auto& channel) { return channel.value != 0; }))
|
||||
return std::unexpected{CellularRegionStepError::invalid_heat};
|
||||
auto intent = life->intent;
|
||||
const auto target = intent.intake_target;
|
||||
intent.intake_target.reset();
|
||||
const auto step =
|
||||
propose_cellular_step(begin_tick, area, life->position, life->extent_um, intent,
|
||||
life->reserve, life->heat, life->budget, habitat);
|
||||
if (!step && step.error() == CellularStepError::insufficient_maintenance) {
|
||||
CellularCorpseCandidate corpse{life->life_id, life->position, life->reserve};
|
||||
for (std::size_t channel = 0; channel < corpse.inventory.matter.size(); ++channel) {
|
||||
const auto body_matter = life->body.matter[channel].value;
|
||||
const auto reserve_matter = life->reserve.matter[channel].value;
|
||||
if (reserve_matter > std::numeric_limits<std::uint64_t>::max() - body_matter)
|
||||
return std::unexpected{CellularRegionStepError::overflow};
|
||||
corpse.inventory.matter[channel].value = body_matter + reserve_matter;
|
||||
}
|
||||
if (life->heat.energy.value >
|
||||
std::numeric_limits<std::uint64_t>::max() - candidate.heat_released.value)
|
||||
return std::unexpected{CellularRegionStepError::overflow};
|
||||
candidate.heat_released.value += life->heat.energy.value;
|
||||
candidate.starved.push_back(corpse);
|
||||
continue;
|
||||
}
|
||||
if (!step)
|
||||
return std::unexpected{CellularRegionStepError::life_step};
|
||||
auto result = *step;
|
||||
|
||||
Reference in New Issue
Block a user