Cellular rules 8: pools and bubbles fed by contact (ADR-0136 step A)
Foundation / checks (checks) (push) Successful in 47m40s
Foundation / checks (client) (push) Successful in 17m27s
Foundation / checks (deploy) (push) Successful in 4m17s
Foundation / checks (ecs) (push) Successful in 4m31s
Foundation / checks (network) (push) Successful in 22m1s
Foundation / checks (tsan) (push) Successful in 13m10s
Foundation / checks (postgres) (push) Successful in 20m54s
Foundation / image (push) Successful in 4m15s
Foundation / postgres-tools (push) Successful in 5m32s
Foundation / server-image (push) Successful in 7m15s
Foundation / checks (checks) (push) Successful in 47m40s
Foundation / checks (client) (push) Successful in 17m27s
Foundation / checks (deploy) (push) Successful in 4m17s
Foundation / checks (ecs) (push) Successful in 4m31s
Foundation / checks (network) (push) Successful in 22m1s
Foundation / checks (tsan) (push) Successful in 13m10s
Foundation / checks (postgres) (push) Successful in 20m54s
Foundation / image (push) Successful in 4m15s
Foundation / postgres-tools (push) Successful in 5m32s
Foundation / server-image (push) Successful in 7m15s
Square patches invited camping and left the space between them empty. Rules 8 run on a format-2 habitat of deposits: - pools and single-nutrient bubbles at free micrometre centres, each with a stable id and a contact radius; the cellular-v7 opening scatters bubbles reproducibly from the genesis commit (three in ten in loose clumps) and lists pools with --pool; - every cell drains what it touches, up to its intake rate per tick, with no target; a pool gives at most a quarter of that rate; an emptied deposit disappears; - a dead cell's detritus breaks into one bubble per non-empty channel; - wildlife swims to the nearest non-empty deposit and feeds by touch. Bundle v9 (habitat 2) and schema v43 admit it. Session v11 carries the owner's 512 nearest deposits (id, centre, radius, shape, a drained flag and 16-bit amount codes) instead of patches; every other cellular message is v10's. The client asks for v11, draws bubbles (nutrient-coloured, pulsing while drained, popping when gone) and pools as puddles, slows near food and sends no feed target; the HUD summarises food in range. Earlier rules, regions and v10 clients are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -124,19 +124,34 @@ wildlife_intents(const CellularLives& state, std::uint64_t tick) {
|
||||
const auto centre_y = static_cast<std::int64_t>(life.position.y_um) + extent / 2;
|
||||
std::optional<biology::CellularPatchAddress> nearest;
|
||||
std::uint64_t nearest_distance{};
|
||||
// Rules 8 (ADR-0136): deposits are discs at their centres, any non-empty one is food,
|
||||
// and touching feeds; earlier rules seek energy patches and name them.
|
||||
const bool deposits = state.rules_version() >= cellular_lives_foraging_rules;
|
||||
const auto offset = deposits ? 0 : half_pitch;
|
||||
std::optional<biology::CellularPatchPerception> chosen;
|
||||
for (const auto& patch : *perceived) {
|
||||
if (patch.available.energy.value == 0)
|
||||
if (deposits ? patch.available == accounting::Inventory{}
|
||||
: patch.available.energy.value == 0)
|
||||
continue;
|
||||
const auto dx = std::int64_t{patch.address.x_um} + half_pitch - centre_x;
|
||||
const auto dy = std::int64_t{patch.address.y_um} + half_pitch - centre_y;
|
||||
const auto dx = std::int64_t{patch.address.x_um} + offset - centre_x;
|
||||
const auto dy = std::int64_t{patch.address.y_um} + offset - centre_y;
|
||||
const auto distance = static_cast<std::uint64_t>(dx * dx + dy * dy);
|
||||
// Perception is ordered by address, so the first of equal distances wins.
|
||||
if (!nearest || distance < nearest_distance) {
|
||||
nearest = patch.address;
|
||||
nearest_distance = distance;
|
||||
chosen = patch;
|
||||
}
|
||||
}
|
||||
if (nearest) {
|
||||
if (nearest && deposits && chosen) {
|
||||
biology::CellularPatch disc{};
|
||||
disc.address = chosen->address;
|
||||
disc.radius_um = chosen->radius_um;
|
||||
disc.kind = chosen->kind;
|
||||
if (!biology::cellular_patch_contact(life.position, extent, disc))
|
||||
intent.movement = wildlife_toward(std::int64_t{nearest->x_um} - centre_x,
|
||||
std::int64_t{nearest->y_um} - centre_y);
|
||||
} else if (nearest) {
|
||||
intent.intake_target = nearest;
|
||||
if (!overlaps(life.position.x_um, extent, nearest->x_um) ||
|
||||
!overlaps(life.position.y_um, extent, nearest->y_um))
|
||||
|
||||
Reference in New Issue
Block a user