feat(cellular): random founder spawns, tunable thrust cost, commit timing
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 1m6s
Foundation / checks (deploy) (push) Successful in 5m41s
Foundation / postgres-tools (push) Successful in 1m33s
Foundation / image (push) Successful in 4m42s
Foundation / server-image (push) Successful in 4m55s
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 1m6s
Foundation / checks (deploy) (push) Successful in 5m41s
Foundation / postgres-tools (push) Successful in 1m33s
Foundation / image (push) Successful in 4m42s
Foundation / server-image (push) Successful in 4m55s
Playtest feedback on region 10. Rules-12 founders now start at a seeded random spot anywhere in the region (1 mm clear of the edges, clear of other cells; seeded by world, region and the life's identity so replay is exact). The provisioned sites remain the fallback. Thrust energy is tunable: founder.thrust_cost_per_mille scales the metabolic full-speed movement cost for thrust and braking (trial 250, a quarter of today's cost). It is part of the liquid rules declared when a region opens, persisted in the format-10 block's reserved slot (zero stands for the original 1,000), so existing regions keep their meaning. The server logs every cellular commit slower than 50 ms (and one in 60) with its tick count and duration, to find what stalls the loop once a second. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,8 @@ bool cellular_liquid_valid(const CellularLiquidRules& rules, biology::CellularAr
|
||||
f.reverse_cost.value == 0 && d.merged_cap != 0 && d.bubble_radius_um != 0 &&
|
||||
d.bubble_radius_um <= biology::max_cellular_deposit_radius_um && d.max_drift_q10 >= 0 &&
|
||||
d.max_drift_q10 <= biology::cellular_velocity_limit_q10 &&
|
||||
d.drift_decay_ppm < biology::cellular_drag_ppm_limit;
|
||||
d.drift_decay_ppm < biology::cellular_drag_ppm_limit &&
|
||||
rules.thrust_cost_per_mille != 0 && rules.thrust_cost_per_mille <= 10'000;
|
||||
}
|
||||
|
||||
CellularLiquidRules cellular_liquid_rules(const biology::CellularTuning& t,
|
||||
@@ -36,12 +37,22 @@ CellularLiquidRules cellular_liquid_rules(const biology::CellularTuning& t,
|
||||
biology::cellular_velocity_q10_per_um_s),
|
||||
.drift_decay_ppm = u32(t.food_induced_drift_decay_ppm_per_tick),
|
||||
.merged_cap = static_cast<std::uint16_t>(t.food_merged_bubble_cap_multiple),
|
||||
.bubble_radius_um = biology::cellular_mote_radius_um}};
|
||||
.bubble_radius_um = biology::cellular_mote_radius_um},
|
||||
.thrust_cost_per_mille = u32(t.founder_thrust_cost_per_mille)};
|
||||
}
|
||||
|
||||
std::expected<biology::CellularHandling, biology::CellularHandlingError>
|
||||
cellular_liquid_handling(const biology::Genome& genome, const biology::MetabolicBudget& budget,
|
||||
const CellularLiquidRules& rules) {
|
||||
return biology::derive_cellular_handling(genome, budget, rules.founder);
|
||||
auto handling = biology::derive_cellular_handling(genome, budget, rules.founder);
|
||||
if (!handling)
|
||||
return handling;
|
||||
const auto scaled = [&rules](accounting::Picojoules cost) {
|
||||
const auto product = cost.value * rules.thrust_cost_per_mille;
|
||||
return accounting::Picojoules{product / 1'000 + (product % 1'000 != 0 ? 1 : 0)};
|
||||
};
|
||||
handling->thrust_cost = scaled(handling->thrust_cost);
|
||||
handling->reverse_cost = scaled(handling->reverse_cost);
|
||||
return handling;
|
||||
}
|
||||
} // namespace evo::server
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "evo/server/lifecycle/cellular_lives.hpp"
|
||||
|
||||
#include "evo/biology/budding.hpp"
|
||||
#include "evo/biology/founder.hpp"
|
||||
#include "evo/core/random.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@@ -1115,7 +1117,9 @@ std::vector<std::uint8_t> CellularLives::snapshot() const {
|
||||
out.put(d.drift_decay_ppm, 4);
|
||||
out.put(d.merged_cap, 4);
|
||||
out.put(d.bubble_radius_um, 4);
|
||||
out.put(0, 4);
|
||||
// Thrust cost share; zero stands for the original 1,000 per mille.
|
||||
const auto cost = state_->liquid.thrust_cost_per_mille;
|
||||
out.put(cost == 1'000 ? 0 : cost, 4);
|
||||
}
|
||||
for (const auto site : state_->nursery_config.sites)
|
||||
out.site(site);
|
||||
@@ -1338,12 +1342,32 @@ CellularLives::birth_candidate(LifeRequest request, LifeAllocation allocation) c
|
||||
if (!budget || budget->body != endowed->body)
|
||||
return std::unexpected{CellularLivesError::biology};
|
||||
|
||||
std::optional<biology::CellularPosition> position;
|
||||
// Rules 12: a new founder starts at a seeded random spot anywhere in the region (1 mm
|
||||
// clear of its edges), so starts spread out; the provisioned sites remain the fallback.
|
||||
// Seeded by world, region and the life's identity, so replay places it identically.
|
||||
std::vector<biology::CellularPosition> candidates;
|
||||
if (state_->rules_version >= cellular_lives_liquid_rules) {
|
||||
constexpr std::uint64_t margin = 1'000;
|
||||
const auto& area = state_->config.area;
|
||||
if (area.width_um > 2 * margin + budget->phenotype.extent &&
|
||||
area.height_um > 2 * margin + budget->phenotype.extent) {
|
||||
Random random{
|
||||
mutation_seed(state_->world, state_->region, allocation.life, 0x5350574EU)};
|
||||
const auto span_x = area.width_um - 2 * margin - budget->phenotype.extent;
|
||||
const auto span_y = area.height_um - 2 * margin - budget->phenotype.extent;
|
||||
for (int attempt = 0; attempt < 16; ++attempt)
|
||||
candidates.push_back(
|
||||
{margin + random.next() % span_x, margin + random.next() % span_y});
|
||||
}
|
||||
}
|
||||
for (const auto site : state_->nursery_config.sites) {
|
||||
if (site.x_um < 0 || site.y_um < 0)
|
||||
return std::unexpected{CellularLivesError::invalid_config};
|
||||
const biology::CellularPosition candidate{static_cast<std::uint64_t>(site.x_um),
|
||||
static_cast<std::uint64_t>(site.y_um)};
|
||||
candidates.push_back(
|
||||
{static_cast<std::uint64_t>(site.x_um), static_cast<std::uint64_t>(site.y_um)});
|
||||
}
|
||||
std::optional<biology::CellularPosition> position;
|
||||
for (const auto candidate : candidates) {
|
||||
bool occupied = false;
|
||||
for (const auto& living : state_->lives) {
|
||||
if (living.presence == CellularPresence::suspended)
|
||||
@@ -1582,7 +1606,9 @@ CellularLives::restore(std::span<const std::uint8_t> bytes, std::uint64_t world,
|
||||
const auto cap = u32();
|
||||
d.merged_cap = static_cast<std::uint16_t>(cap);
|
||||
d.bubble_radius_um = u32();
|
||||
if (in.get(4) != 0 || turn > 0xFFFFU || cap > 0xFFFFU ||
|
||||
const auto cost = u32();
|
||||
liquid.thrust_cost_per_mille = cost == 0 ? 1'000 : cost;
|
||||
if (cost == 1'000 || turn > 0xFFFFU || cap > 0xFFFFU ||
|
||||
!cellular_liquid_valid(liquid, config.area))
|
||||
return std::unexpected{CellularLivesError::format};
|
||||
auto generated = biology::CellularFlowField::shared(liquid.currents);
|
||||
|
||||
Reference in New Issue
Block a user