feat(cellular): split collection evenly across a source's nutrients
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m31s
Foundation / postgres-tools (push) Successful in 21s
Foundation / server-image (push) Successful in 4m21s
Foundation / image (push) Successful in 5m3s
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m31s
Foundation / postgres-tools (push) Successful in 21s
Foundation / server-image (push) Successful in 4m21s
Foundation / image (push) Successful in 5m3s
Playtest: phosphorus held growth back everywhere. Per-nutrient collection limits followed the body recipe (5% phosphorus), but the membrane is 10% phosphorus, so no cell could collect phosphorus as fast as it builds with it. Two optional revamp tuning keys, stored in a formerly reserved rules word so regions opened without them keep their exact meaning: - feeding.split_evenly: matter from one food source is split equally between the nutrients it holds (a carbon-only bubble gives the whole matter limit to carbon, carbon and phosphorus half each, all four a quarter each), each share scaled by the cell's collection trait; - feeding.collection_percent: every collection limit per cent (100 default). The DEV tuning file takes these keys with the image that reads them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -85,10 +85,12 @@ std::optional<Limits> revamp_limits(const CellularLifeStepInput& life,
|
||||
for (std::size_t channel = 0; channel < limits.channel.size(); ++channel) {
|
||||
const auto per_second = channel == 0 ? life.budget.intake_limit.energy.value
|
||||
: life.budget.intake_limit.matter[channel - 1].value;
|
||||
const auto base = accounting::per_tick(per_second, cellular_motion_tick_microseconds,
|
||||
accounting::Rounding::down);
|
||||
auto base = accounting::per_tick(per_second, cellular_motion_tick_microseconds,
|
||||
accounting::Rounding::down);
|
||||
if (!base || *base > u64_max / 2'000)
|
||||
return std::nullopt;
|
||||
*base =
|
||||
*base / 100 * rules.collection_percent + *base % 100 * rules.collection_percent / 100;
|
||||
limits.channel.at(channel) = *base / 100 * own.collection.at(channel) +
|
||||
*base % 100 * own.collection.at(channel) / 100;
|
||||
if (limits.channel.at(channel) > u64_max / 2'000)
|
||||
@@ -266,10 +268,26 @@ propose_cellular_region_step(std::uint64_t begin_tick, CellularArea area,
|
||||
deposit))
|
||||
continue;
|
||||
bool took = false;
|
||||
// Even split: the matter limit left this tick, shared equally by the nutrients
|
||||
// this source holds.
|
||||
const bool even = rules.revamp->split_evenly;
|
||||
std::uint64_t share{};
|
||||
if (even) {
|
||||
std::uint64_t present{};
|
||||
for (std::size_t channel = 1; channel < limits->channel.size(); ++channel)
|
||||
present += channel_of(patch_stock[index], channel) != 0 ? 1 : 0;
|
||||
const auto matter = matter_of(drained);
|
||||
const auto left = limits->shared > matter ? limits->shared - matter : 0;
|
||||
share = present == 0 ? 0 : left / present;
|
||||
}
|
||||
for (std::size_t channel = 0; channel < limits->channel.size(); ++channel) {
|
||||
auto& stock = channel_of(patch_stock[index], channel);
|
||||
auto& taken = channel_of(drained, channel);
|
||||
auto allowance = limits->channel.at(channel) - taken;
|
||||
if (even && channel != 0) {
|
||||
const auto trait = std::uint64_t{life->revamp->collection.at(channel)};
|
||||
allowance = share / 100 * trait + share % 100 * trait / 100;
|
||||
}
|
||||
if (channel != 0) {
|
||||
const auto matter = matter_of(drained);
|
||||
allowance = std::min(allowance,
|
||||
@@ -277,8 +295,10 @@ propose_cellular_region_step(std::uint64_t begin_tick, CellularArea area,
|
||||
}
|
||||
if (deposit.kind == CellularDepositKind::pool)
|
||||
allowance =
|
||||
std::min(allowance, limits->channel.at(channel) *
|
||||
cellular_pool_yield_per_thousand / 1000);
|
||||
even && channel != 0
|
||||
? allowance * cellular_pool_yield_per_thousand / 1000
|
||||
: std::min(allowance, limits->channel.at(channel) *
|
||||
cellular_pool_yield_per_thousand / 1000);
|
||||
auto& reserve = channel_of(result.reserve_after, channel);
|
||||
const auto take = std::min({stock, allowance, u64_max - reserve});
|
||||
if (stock > take) {
|
||||
|
||||
@@ -36,6 +36,9 @@ constexpr std::array fields{
|
||||
rate_limit},
|
||||
Field{"feeding.membrane_collection_per_mille_per_point",
|
||||
&CellularRevampTuning::feeding_membrane_collection_per_mille_per_point, 0, 1'000},
|
||||
Field{"feeding.collection_percent", &CellularRevampTuning::feeding_collection_percent, 1,
|
||||
1'000},
|
||||
Field{"feeding.split_evenly", &CellularRevampTuning::feeding_split_evenly, 0, 1},
|
||||
Field{"predation.engulf_ratio_milli", &CellularRevampTuning::predation_engulf_ratio_milli, 1,
|
||||
1'000'000},
|
||||
Field{"predation.engulf_reserve_percent",
|
||||
@@ -246,7 +249,9 @@ parse_cellular_revamp_tuning(std::string_view text) {
|
||||
tuning.*field.member = *value;
|
||||
}
|
||||
for (std::size_t index = 0; index < fields.size(); ++index)
|
||||
if (!seen.at(index) && fields.at(index).key != "playtest.starting_wildlife_cells")
|
||||
if (!seen.at(index) && fields.at(index).key != "playtest.starting_wildlife_cells" &&
|
||||
fields.at(index).key != "feeding.collection_percent" &&
|
||||
fields.at(index).key != "feeding.split_evenly")
|
||||
return std::unexpected{
|
||||
error(CellularTuningErrorKind::missing_key, 0, fields.at(index).key)};
|
||||
if (tuning.version != cellular_revamp_tuning_version)
|
||||
|
||||
@@ -1630,7 +1630,11 @@ std::vector<std::uint8_t> CellularLives::snapshot() const {
|
||||
if (revamp) {
|
||||
const auto& r = state_->revamp;
|
||||
out.put(r.body.essential_upkeep_per_thousand, 4);
|
||||
out.put(0, 4);
|
||||
// Formerly reserved: collection per cent (0 for the original 100) and the even split
|
||||
// in bit 16. Regions opened before these keys hold zero and keep their meaning.
|
||||
out.put((r.step.collection_percent == 100 ? 0U : r.step.collection_percent) |
|
||||
(r.step.split_evenly ? 0x10000U : 0U),
|
||||
4);
|
||||
for (const auto rate : r.burn_pj_per_kfg)
|
||||
out.put(rate);
|
||||
out.put(r.step.membrane_collection_per_mille_per_point, 4);
|
||||
@@ -2157,7 +2161,10 @@ CellularLives::restore(std::span<const std::uint8_t> bytes, std::uint64_t world,
|
||||
if (revamp_version) {
|
||||
const auto u32 = [&in] { return static_cast<std::uint32_t>(in.get(4)); };
|
||||
revamp.body.essential_upkeep_per_thousand = u32();
|
||||
const auto reserved = in.get(4);
|
||||
const auto feeding = in.get(4);
|
||||
revamp.step.collection_percent =
|
||||
(feeding & 0xFFFFU) == 0 ? 100U : static_cast<std::uint32_t>(feeding & 0xFFFFU);
|
||||
revamp.step.split_evenly = (feeding & 0x10000U) != 0;
|
||||
for (auto& rate : revamp.burn_pj_per_kfg)
|
||||
rate = in.get();
|
||||
revamp.step.membrane_collection_per_mille_per_point = u32();
|
||||
@@ -2169,7 +2176,8 @@ CellularLives::restore(std::span<const std::uint8_t> bytes, std::uint64_t world,
|
||||
revamp.drip_bubble_pj = in.get();
|
||||
revamp.drip_bubble_fg = in.get();
|
||||
spent = in.inventory();
|
||||
if (!read_revamp_offers(in, revamp) || reserved != 0 || !cellular_revamp_valid(revamp))
|
||||
if (!read_revamp_offers(in, revamp) || (feeding & ~0x1FFFFULL) != 0 ||
|
||||
(feeding & 0xFFFFU) == 100 || !cellular_revamp_valid(revamp))
|
||||
return std::unexpected{CellularLivesError::format};
|
||||
}
|
||||
const auto life_bytes =
|
||||
|
||||
@@ -41,6 +41,7 @@ bool cellular_revamp_valid(const CellularRevampRules& rules) noexcept {
|
||||
return false;
|
||||
return rules.body.essential_upkeep_per_thousand <= 1'000 &&
|
||||
step.membrane_collection_per_mille_per_point <= 1'000 && step.engulf_ratio_milli >= 1 &&
|
||||
step.collection_percent >= 1 && step.collection_percent <= 1'000 &&
|
||||
step.engulf_ratio_milli <= 1'000'000 && step.engulf_reserve_percent <= 100 &&
|
||||
step.kill_bubble_per_thousand <= 1'000 && rules.drip_interval_ticks <= 72'000 &&
|
||||
rules.drip_bubble_pj <= most && rules.drip_bubble_fg <= most &&
|
||||
@@ -51,8 +52,9 @@ bool cellular_revamp_valid(const CellularRevampRules& rules) noexcept {
|
||||
rules.split_share_per_thousand < 1'000 && rules.split_min_growth != 0 &&
|
||||
rules.split_min_growth <= 1'000 && rules.bud_fee_scale_percent <= 100 &&
|
||||
rules.bud_fee.energy.value <= most &&
|
||||
std::ranges::all_of(rules.bud_fee.matter,
|
||||
[](const accounting::Femtograms& f) { return f.value <= most; }) &&
|
||||
std::ranges::all_of(
|
||||
rules.bud_fee.matter,
|
||||
[](const accounting::Femtograms& f) { return f.value <= most; }) &&
|
||||
rules.organism_cap != 0 && rules.organism_cap <= biology::max_cellular_tick_lives &&
|
||||
rules.organism_load_per_thousand <= 10'000 && rules.emerge_members >= 2 &&
|
||||
rules.emerge_members <= 10'000 && rules.emerge_mass_fg <= most &&
|
||||
@@ -248,7 +250,9 @@ CellularRevampRules cellular_revamp_rules(const biology::CellularRevampTuning& t
|
||||
u32(t.feeding_membrane_collection_per_mille_per_point),
|
||||
.engulf_ratio_milli = u32(t.predation_engulf_ratio_milli),
|
||||
.engulf_reserve_percent = u32(t.predation_engulf_reserve_percent),
|
||||
.kill_bubble_per_thousand = u32(t.predation_kill_bubble_per_mille)},
|
||||
.kill_bubble_per_thousand = u32(t.predation_kill_bubble_per_mille),
|
||||
.collection_percent = u32(t.feeding_collection_percent),
|
||||
.split_evenly = t.feeding_split_evenly != 0},
|
||||
.drip_interval_ticks = u32(t.spent_drip_interval_ticks),
|
||||
.drip_bubble_pj = u64(t.spent_drip_bubble_pj),
|
||||
.drip_bubble_fg = u64(t.spent_drip_bubble_fg),
|
||||
|
||||
Reference in New Issue
Block a user