feat(cellular): playtest fixes - edge, cell count, mixed bubbles, still pools
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m29s
Foundation / postgres-tools (push) Successful in 29s
Foundation / server-image (push) Successful in 4m24s
Foundation / image (push) Successful in 4m58s
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m29s
Foundation / postgres-tools (push) Successful in 29s
Foundation / server-image (push) Successful in 4m24s
Foundation / image (push) Successful in 4m58s
From the first rules-13 playtest: - An earned offer waits until a single cell can split (keeping its count), so choices are no longer refused one after another. - The client draws the region's walls (dimming outside), names the edge when the cell is against it, shows the region's cell count, and says when upkeep is burning kept matter because no energy is left. - Mixed bubbles hold every nutrient at once (--mixed-motes; none leaves the scatter stream unchanged) and are drawn as small pools of their nutrients. With intake split by the body's recipe, single-nutrient phosphorus bubbles fed slowly; mixed ones carry it with everything else. - Liquid openings move each pool out of the currents to the nearest still water (cellular_still_centre). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "evo/core/random.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <mutex>
|
||||
#include <utility>
|
||||
@@ -254,4 +255,44 @@ std::uint64_t CellularFlowField::digest() const noexcept {
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
CellularPatchAddress cellular_still_centre(const CellularFlowField& field,
|
||||
CellularPatchAddress centre,
|
||||
std::uint32_t radius_um) noexcept {
|
||||
const auto& c = field.config();
|
||||
const std::int64_t r = radius_um;
|
||||
const auto still = [&](std::int64_t x, std::int64_t y) {
|
||||
if (x - r < 0 || y - r < 0 || x + r > std::int64_t{c.width_um} ||
|
||||
y + r > std::int64_t{c.height_um})
|
||||
return false;
|
||||
// The centre and 16 points on the rim and half-rim.
|
||||
if (field.sample(x, y) != CellularFlowSample{})
|
||||
return false;
|
||||
for (int k = 0; k < 8; ++k) {
|
||||
const double angle = k * 0.785398163397448;
|
||||
for (const double reach : {0.5, 1.0}) {
|
||||
const auto px = x + std::llround(std::cos(angle) * reach * static_cast<double>(r));
|
||||
const auto py = y + std::llround(std::sin(angle) * reach * static_cast<double>(r));
|
||||
if (field.sample(px, py) != CellularFlowSample{})
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
const std::int64_t x0 = centre.x_um, y0 = centre.y_um;
|
||||
if (still(x0, y0))
|
||||
return centre;
|
||||
// Rings of growing radius, 250 um apart, each walked at about 250 um steps.
|
||||
for (std::int64_t ring = 250; ring <= 30'000; ring += 250) {
|
||||
const auto steps = std::max<std::int64_t>(8, ring * 2 * 314 / 100 / 250);
|
||||
for (std::int64_t k = 0; k < steps; ++k) {
|
||||
const double angle =
|
||||
6.283185307179586 * static_cast<double>(k) / static_cast<double>(steps);
|
||||
const auto x = x0 + std::llround(std::cos(angle) * static_cast<double>(ring));
|
||||
const auto y = y0 + std::llround(std::sin(angle) * static_cast<double>(ring));
|
||||
if (still(x, y))
|
||||
return {static_cast<std::uint32_t>(x), static_cast<std::uint32_t>(y)};
|
||||
}
|
||||
}
|
||||
return centre;
|
||||
}
|
||||
} // namespace evo::biology
|
||||
|
||||
@@ -373,7 +373,8 @@ std::expected<CellularHabitatConfig, CellularHabitatError>
|
||||
scatter_deposits(CellularHabitatConfig base, std::span<const CellularPatch> pools,
|
||||
const CellularMoteField& field) {
|
||||
if (base.width_um == 0 || base.height_um == 0 || field.source == 0 ||
|
||||
pools.size() + field.count > max_cellular_patches)
|
||||
pools.size() + field.count + field.mixed_count > max_cellular_patches ||
|
||||
(field.mixed_count != 0 && field.mixed == accounting::Inventory{}))
|
||||
return std::unexpected{CellularHabitatError::invalid_config};
|
||||
std::vector<std::size_t> channels; // 0 energy, 1-4 matter
|
||||
if (field.amount.energy.value != 0)
|
||||
@@ -383,6 +384,8 @@ scatter_deposits(CellularHabitatConfig base, std::span<const CellularPatch> pool
|
||||
channels.push_back(c + 1);
|
||||
if (field.count != 0 && channels.empty())
|
||||
return std::unexpected{CellularHabitatError::invalid_config};
|
||||
if (channels.empty())
|
||||
channels.push_back(0); // Only mixed bubbles: the single-nutrient rota is unused.
|
||||
// splitmix64: a fixed, portable stream.
|
||||
std::uint64_t state = field.seed;
|
||||
const auto next = [&state] {
|
||||
@@ -406,7 +409,7 @@ scatter_deposits(CellularHabitatConfig base, std::span<const CellularPatch> pool
|
||||
centres.push_back({static_cast<std::uint32_t>(below(base.width_um)),
|
||||
static_cast<std::uint32_t>(below(base.height_um))});
|
||||
constexpr std::int64_t spread = 600; // Clump half-width (tunable).
|
||||
for (std::uint32_t i = 0; i < field.count; ++i) {
|
||||
for (std::uint32_t i = 0; i < field.count + field.mixed_count; ++i) {
|
||||
std::int64_t x{}, y{};
|
||||
if (below(10) < 3) {
|
||||
const auto& centre = centres[below(centres.size())];
|
||||
@@ -426,6 +429,11 @@ scatter_deposits(CellularHabitatConfig base, std::span<const CellularPatch> pool
|
||||
mote.source = field.source;
|
||||
mote.radius_um = cellular_mote_radius_um;
|
||||
mote.kind = CellularDepositKind::mote;
|
||||
if (i >= field.count) {
|
||||
mote.stock = field.mixed;
|
||||
deposits.push_back(mote);
|
||||
continue;
|
||||
}
|
||||
const auto channel = channels[i % channels.size()];
|
||||
if (channel == 0)
|
||||
mote.stock.energy = field.amount.energy;
|
||||
|
||||
@@ -3383,8 +3383,15 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
|
||||
biology::cellular_affinity_tick(
|
||||
life.revamp.affinity, a, state_->revamp.mutations,
|
||||
{state_->revamp.offers.score_min, state_->revamp.offers.score_max});
|
||||
if (life.revamp.offer.count != 0 ||
|
||||
++life.revamp.active_ticks < state_->revamp.offer_interval_ticks)
|
||||
if (life.revamp.offer.count != 0)
|
||||
continue;
|
||||
if (life.revamp.active_ticks < state_->revamp.offer_interval_ticks)
|
||||
++life.revamp.active_ticks;
|
||||
// A single cell's choice splits it, so an earned offer waits (keeping its count)
|
||||
// until the cell has grown enough to split.
|
||||
if (life.revamp.active_ticks < state_->revamp.offer_interval_ticks ||
|
||||
(life.revamp.members == 1 &&
|
||||
life.growth.realized_per_thousand < state_->revamp.split_min_growth))
|
||||
continue;
|
||||
life.revamp.active_ticks = 0;
|
||||
const auto plan = next_archive.find(cellular_offspring_genome(life));
|
||||
|
||||
Reference in New Issue
Block a user