feat(lifecycle): preserve inherited plans in exact populations
Foundation / checks (ecs) (push) Successful in 2m26s
Foundation / checks (deploy) (push) Successful in 4m57s
Foundation / checks (network) (push) Successful in 20m53s
Foundation / checks (client) (push) Successful in 22m12s
Foundation / checks (tsan) (push) Successful in 39m45s
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 45m41s
Foundation / checks (checks) (push) Canceled after 45m43s
Foundation / checks (ecs) (push) Successful in 2m26s
Foundation / checks (deploy) (push) Successful in 4m57s
Foundation / checks (network) (push) Successful in 20m53s
Foundation / checks (client) (push) Successful in 22m12s
Foundation / checks (tsan) (push) Successful in 39m45s
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 45m41s
Foundation / checks (checks) (push) Canceled after 45m43s
This commit is contained in:
@@ -14,13 +14,15 @@ CellularPopulation::CellularPopulation(std::unique_ptr<CellularLives> state,
|
||||
|
||||
std::expected<std::unique_ptr<CellularPopulation>, CellularPopulationError>
|
||||
CellularPopulation::create(std::unique_ptr<CellularLives> state, CellularTierPolicy policy) {
|
||||
if (!state ||
|
||||
(state->rules_version() != cellular_lives_foraging_rules &&
|
||||
!(state->rules_version() == cellular_lives_maturation_rules &&
|
||||
state->format_version() == cellular_lives_migration_format)) ||
|
||||
(state->format_version() != cellular_lives_presence_format &&
|
||||
state->format_version() != cellular_lives_migration_format) ||
|
||||
policy.materialize_radius_um == 0 ||
|
||||
const bool supported =
|
||||
state && ((state->rules_version() == cellular_lives_foraging_rules &&
|
||||
(state->format_version() == cellular_lives_presence_format ||
|
||||
state->format_version() == cellular_lives_migration_format)) ||
|
||||
(state->rules_version() == cellular_lives_maturation_rules &&
|
||||
state->format_version() == cellular_lives_migration_format) ||
|
||||
(state->rules_version() == cellular_lives_inheritance_rules &&
|
||||
state->format_version() == cellular_lives_inheritance_format));
|
||||
if (!supported || policy.materialize_radius_um == 0 ||
|
||||
policy.collapse_radius_um <= policy.materialize_radius_um ||
|
||||
policy.collapse_radius_um > biology::cellular_motion_axis_limit_um)
|
||||
return std::unexpected(CellularPopulationError::unsupported);
|
||||
@@ -42,6 +44,8 @@ std::uint64_t CellularPopulation::conversion_sequence() const noexcept {
|
||||
return conversion_sequence_;
|
||||
}
|
||||
std::uint32_t CellularPopulation::format_version() const noexcept {
|
||||
if (state_->format_version() == cellular_lives_inheritance_format)
|
||||
return cellular_population_inheritance_format;
|
||||
return state_->format_version() == cellular_lives_migration_format ? 2U : 1U;
|
||||
}
|
||||
std::expected<std::unique_ptr<CellularPopulation>, CellularPopulationError>
|
||||
@@ -68,6 +72,18 @@ CellularPopulation::maturation_upgrade_candidate() const {
|
||||
(*candidate)->conversion_sequence_ = conversion_sequence_;
|
||||
return candidate;
|
||||
}
|
||||
std::expected<std::unique_ptr<CellularPopulation>, CellularPopulationError>
|
||||
CellularPopulation::inheritance_upgrade_candidate() const {
|
||||
auto biological = state_->inheritance_upgrade_candidate();
|
||||
if (!biological)
|
||||
return std::unexpected(CellularPopulationError::unsupported);
|
||||
auto candidate = create(std::move(*biological), policy_);
|
||||
if (!candidate)
|
||||
return std::unexpected(candidate.error());
|
||||
(*candidate)->members_ = members_;
|
||||
(*candidate)->conversion_sequence_ = conversion_sequence_;
|
||||
return candidate;
|
||||
}
|
||||
std::expected<std::size_t, CellularPopulationError>
|
||||
CellularPopulation::collapse(std::uint64_t genome) {
|
||||
auto candidate = members_;
|
||||
|
||||
Reference in New Issue
Block a user