feat(biology): fund offspring from a distinct inherited genome
Foundation / checks (ecs) (push) Successful in 2m27s
Foundation / checks (deploy) (push) Successful in 4m15s
Foundation / checks (network) (push) Successful in 21m4s
Foundation / checks (client) (push) Successful in 22m22s
Foundation / checks (tsan) (push) Successful in 31m40s
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 45m38s
Foundation / checks (checks) (push) Canceled after 45m43s
Foundation / checks (ecs) (push) Successful in 2m27s
Foundation / checks (deploy) (push) Successful in 4m15s
Foundation / checks (network) (push) Successful in 21m4s
Foundation / checks (client) (push) Successful in 22m22s
Foundation / checks (tsan) (push) Successful in 31m40s
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 45m38s
Foundation / checks (checks) (push) Canceled after 45m43s
This commit is contained in:
+21
-2
@@ -18,6 +18,18 @@ std::expected<BudTransition, BuddingError> fund_bud(const Genome& genome, Growth
|
||||
const accounting::Inventory& parent_reserve,
|
||||
std::uint32_t temperature_millikelvin,
|
||||
std::uint32_t share) {
|
||||
return fund_offspring(genome, genome, parent_growth, parent_reserve, temperature_millikelvin,
|
||||
share);
|
||||
}
|
||||
|
||||
std::expected<BudTransition, BuddingError>
|
||||
fund_offspring(const Genome& genome, const Genome& offspring, GrowthState parent_growth,
|
||||
const accounting::Inventory& parent_reserve, std::uint32_t temperature_millikelvin,
|
||||
std::uint32_t share) {
|
||||
if (genome.schema_version() != offspring.schema_version() ||
|
||||
genome.development_version() != offspring.development_version() ||
|
||||
(genome.id() == offspring.id() && genome != offspring))
|
||||
return std::unexpected{BuddingError::incompatible_genome};
|
||||
if (share == 0)
|
||||
return std::unexpected{BuddingError::no_capability};
|
||||
if (!genome.carries(Capability::reproduction))
|
||||
@@ -47,7 +59,7 @@ std::expected<BudTransition, BuddingError> fund_bud(const Genome& genome, Growth
|
||||
// channel. Bodies grow with realized growth, so the scan stops at the first fit.
|
||||
for (std::uint32_t realized = 1000; realized > 0; --realized) {
|
||||
const GrowthState growth{realized, 0};
|
||||
const auto bud = metabolic_budget(genome, growth, {temperature_millikelvin, {}});
|
||||
const auto bud = metabolic_budget(offspring, growth, {temperature_millikelvin, {}});
|
||||
if (!bud)
|
||||
return std::unexpected{BuddingError::development};
|
||||
accounting::Inventory body_only = bud->body;
|
||||
@@ -88,13 +100,20 @@ std::expected<BudTransition, BuddingError> fund_bud(const Genome& genome, Growth
|
||||
|
||||
std::optional<accounting::Inventory> bud_cost(const Genome& genome,
|
||||
std::uint32_t temperature_millikelvin) {
|
||||
return offspring_cost(genome, genome, temperature_millikelvin);
|
||||
}
|
||||
|
||||
std::optional<accounting::Inventory> offspring_cost(const Genome& parent, const Genome& offspring,
|
||||
std::uint32_t temperature_millikelvin,
|
||||
std::uint32_t share) {
|
||||
// Fund against an ample reserve and read the charge: one code path decides both.
|
||||
constexpr std::uint64_t ample = std::uint64_t{1} << 60U;
|
||||
const accounting::Inventory unlimited{
|
||||
{ample},
|
||||
{accounting::Femtograms{ample}, accounting::Femtograms{ample},
|
||||
accounting::Femtograms{ample}, accounting::Femtograms{ample}}};
|
||||
const auto funded = fund_bud(genome, {1000, 0}, unlimited, temperature_millikelvin);
|
||||
const auto funded =
|
||||
fund_offspring(parent, offspring, {1000, 0}, unlimited, temperature_millikelvin, share);
|
||||
if (!funded)
|
||||
return std::nullopt;
|
||||
accounting::Inventory cost;
|
||||
|
||||
Reference in New Issue
Block a user