The 3D Pangolin Forest scene animates a pangolin wandering, eating and curling but hides the state machine driving it. This 2D companion exposes it directly, top-down: the pangolin cycles between wandering, homing in on the nearest termite mound, digging it open, tongue-flicking to eat the insects it releases, and — the moment a predator's distance drops inside its alarm radius — snapping into a defensive ball.
Alarm trigger: dist(predator, pangolin) < R0 / alarm_sensitivity
Dig rate: mound_hp -= dig_speed * dt (releases 1 insect per ~1.4s while active)
Forage rate: eat_timer -= tongue_speed * dt (energy += 6 per insect eaten)
Energy drain: energy -= 0.6 * dt (metabolism, always running)
Curl duration: fixed at curl_hold_time seconds regardless of how the threat behaves
- Tongue speed — how fast the sticky tongue clears an insect once in range; higher values mean more energy gained per second spent foraging.
- Dig speed — how fast claws break down a termite mound's defenses; faster digging opens more insects per minute but the pangolin is exposed and slow while doing it.
- Alarm sensitivity — a multiplier on the detection radius: real pangolins rely on hearing and vibration more than sight, so higher sensitivity means a threat is sensed from farther away, giving more time to curl before contact.
- Curl hold time — pangolins do not judge when a threat has actually left; they hold the ball for a fixed, hardwired duration. Too short risks uncurling into danger; too long wastes foraging time while energy keeps draining.
A predator that reaches a curled pangolin cannot breach the keratin plates — it is repelled and wanders off, counted as a defense success. A predator that reaches an uncurled pangolin (alarm too insensitive, or curl already timed out) forces an emergency curl mid-encounter instead, which is riskier because it starts closer.