fix(wildlife): rules-11 foragers short of energy seek energy, not the nearest mote
The controller steered to the nearest non-empty deposit of any kind and held still once touching it. A bud parked on a carbon mote fed on carbon until it starved, and later buds stopped on the first bubble of a corpse's row rather than its energy one. On rules 11 a wildlife cell whose energy reserve covers fewer than 1,200 ticks (60 s) of its full demand now passes over energy-free deposits while it perceives any energy; a fed cell, or one with no energy in view, still takes the nearest food. Earlier rules are unchanged, so their recorded and population histories replay exactly. The choice is the new wildlife_food(), tested directly in photosynthesis-contracts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
// M11.5d (ADR-0125): the bounded deterministic wildlife controller. It reads only the
|
||||
@@ -16,11 +18,22 @@ namespace evo::server {
|
||||
inline constexpr std::uint64_t wildlife_bud_interval_ticks = 20; // 1 s
|
||||
inline constexpr std::uint64_t wildlife_wander_interval_ticks = 40; // 2 s
|
||||
inline constexpr std::int16_t wildlife_full_speed = 1'000;
|
||||
// Rules 11 (trial value): a wildlife cell whose energy reserve covers fewer than this many
|
||||
// ticks of its full demand seeks energy-bearing deposits only, so it never parks on a
|
||||
// carbon or nutrient mote while it starves. Earlier rules keep nearest-any foraging.
|
||||
inline constexpr std::uint64_t wildlife_energy_hunger_ticks = 1'200; // 60 s
|
||||
|
||||
// Full speed toward (dx, dy): the intent's length is at most wildlife_full_speed, as a
|
||||
// cellular intent requires (a longer one is refused and fails the whole tick).
|
||||
[[nodiscard]] biology::CellularIntent wildlife_toward(std::int64_t dx, std::int64_t dy) noexcept;
|
||||
|
||||
// The perceived food a forager centred at (x, y) heads for: the nearest non-empty deposit
|
||||
// (or, before rules 8, the nearest energy patch). A hungry forager on deposits passes over
|
||||
// energy-free ones while it perceives any energy; otherwise it takes the nearest anything.
|
||||
[[nodiscard]] std::optional<biology::CellularPatchPerception>
|
||||
wildlife_food(std::span<const biology::CellularPatchPerception> perceived, std::int64_t centre_x,
|
||||
std::int64_t centre_y, bool deposits, bool hungry);
|
||||
|
||||
// One intention per wildlife life (zero account), sorted by life id: bud when the reserve
|
||||
// funds one, else steer to and feed from the nearest perceived patch holding energy,
|
||||
// else wander. Owned lives are left to their players. ADR-0175: under rules 11 with
|
||||
|
||||
Reference in New Issue
Block a user