Debit reserve for proposed cellular motion
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m53s
Foundation / checks (client) (push) Failing after 4m23s
Foundation / checks (network) (push) Failing after 3m5s
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 32s
Foundation / checks (checks) (push) Canceled after 5m42s
Foundation / checks (postgres) (push) Canceled after 1m19s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m53s
Foundation / checks (client) (push) Failing after 4m23s
Foundation / checks (network) (push) Failing after 3m5s
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 32s
Foundation / checks (checks) (push) Canceled after 5m42s
Foundation / checks (postgres) (push) Canceled after 1m19s
This commit is contained in:
@@ -114,6 +114,24 @@ propose_cellular_motion(CellularArea area, CellularPosition position, std::uint3
|
||||
return CellularMotionProposal{{next_x, next_y}, distance, {*cost}};
|
||||
}
|
||||
|
||||
std::expected<CellularMotionCandidate, CellularMotionError>
|
||||
propose_funded_cellular_motion(CellularArea area, CellularPosition position,
|
||||
std::uint32_t extent_um, CellularIntent intent,
|
||||
const MetabolicBudget& budget, accounting::Inventory reserve,
|
||||
accounting::Inventory heat) noexcept {
|
||||
const auto motion = propose_cellular_motion(area, position, extent_um, intent, budget);
|
||||
if (!motion)
|
||||
return std::unexpected{motion.error()};
|
||||
const auto cost = motion->movement_cost.value;
|
||||
if (reserve.energy.value < cost)
|
||||
return std::unexpected{CellularMotionError::insufficient_reserve};
|
||||
if (heat.energy.value > std::numeric_limits<std::uint64_t>::max() - cost)
|
||||
return std::unexpected{CellularMotionError::overflow};
|
||||
reserve.energy.value -= cost;
|
||||
heat.energy.value += cost;
|
||||
return CellularMotionCandidate{motion->position, reserve, heat, motion->movement_cost};
|
||||
}
|
||||
|
||||
bool cellular_footprints_contact(CellularPosition a, std::uint32_t extent_a_um, CellularPosition b,
|
||||
std::uint32_t extent_b_um) noexcept {
|
||||
if (extent_a_um == 0 || extent_b_um == 0)
|
||||
|
||||
Reference in New Issue
Block a user