ludic.wildlife: pin every transition of the 15 WILD_* states and the dice each draws (phase 27.2a)

Sixteen test programs under tests/*_pins_test.ludic, on today's code, each one tick from a set
state through the public step (wildlife_tick_ground / _bird / wildlife_tick, wildlife_release,
wildlife_new): the state it goes to, its timer, and how many of the package's rolls it took and
which (the next roll is read off a newborn's yaw, compared with a stream of the same seed). IDLE,
WANDER, ALERT, WARY, FLEE, CHARGE, GO_DRINK, GO_FEED, DRINK, APPROACH, EAT, TRAPPED, FLY, LAND,
PERCH; the droppings' roll before them; the newborn's seven (eight for a bird); what the step
leaves alone. tests/pin/ holds the shared step, the dice reader and two species of its own (a tame
horse, a crow that never lands on its own). Compiled, not run here: 27.2 holds to them unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-30 16:57:15 +03:00
parent d7adc28125
commit 67d477af77
19 changed files with 1521 additions and 0 deletions

View file

@ -0,0 +1,81 @@
# seek_pins_test.ludic - phase 27.2a: IDLE and WANDER going to water or forage as they stand. Thirst
# or hunger over 60 asks the world for a spot - water when thirst is the greater, forage on a tie -
# and sets off (GO_DRINK / GO_FEED, 120 s) whatever its timer; no spot, no change; no roll either way
import "ludic.wildlife"
import "ludic.base"
import "fake"
import "pin"
program SeekPins {
numbers float
bind WildlifeWorld {
ground: fn fk_ground
water: fn fk_water
players: fn fk_players
player_on: fn fk_player_on
player_x: fn fk_x
player_y: fn fk_y
player_z: fn fk_z
about: fn fk_about_of
lures: fn fk_count
lure: fn fk_lure
present: fn fk_present
spot: fn pn_spot
taught: fn pn_taught
}
function needy(wildlife_st: mut WildlifeState, state: int, thirst: float, hunger: float) -> WildAnimal {
let a = pn_at(wildlife_st, 2, 0.0, 0.0, state, 5.0)
a.thirst = thirst
a.hunger = hunger
wildlife_seed(wildlife_st, 6)
pn_step(wildlife_st, a)
return a
}
test "IDLE, thirst over 60 and over hunger: GO_DRINK to the world's water, 120 s, no roll" (wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
pn_setup(wildlife_st, wildlife_tests_fake_st)
let a = needy(wildlife_st, WILD_IDLE, 70.0, 10.0)
expect_eq(a.state, WILD_GO_DRINK)
expect_eq(a.spot, 900)
expect(a.spot_water)
expect_near(a.spot_x, 30.0, 0.0001)
expect_near(a.timer, 120.0, 0.0001)
expect_near(a.way_t, 0.0, 0.00001)
expect_eq(pn_drew(wildlife_st, 6), 0)
}
test "IDLE, hunger over 60 and over thirst - or the two level: GO_FEED to forage" (wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
pn_setup(wildlife_st, wildlife_tests_fake_st)
let a = needy(wildlife_st, WILD_IDLE, 10.0, 70.0)
expect_eq(a.state, WILD_GO_FEED)
expect(not a.spot_water)
let b = needy(wildlife_st, WILD_IDLE, 70.0, 70.0)
expect_eq(b.state, WILD_GO_FEED)
expect_eq(pn_drew(wildlife_st, 6), 0)
}
test "WANDER sets off the same way" (wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
pn_setup(wildlife_st, wildlife_tests_fake_st)
let a = needy(wildlife_st, WILD_WANDER, 70.0, 10.0)
expect_eq(a.state, WILD_GO_DRINK)
expect_near(a.timer, 120.0, 0.0001)
}
test "no spot answered: IDLE stays, no roll" (wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState, wild_pin_st: mut WildPinState) {
pn_setup(wildlife_st, wildlife_tests_fake_st)
wild_pin_st.pn_no_spot = true
let a = needy(wildlife_st, WILD_IDLE, 70.0, 10.0)
expect_eq(a.state, WILD_IDLE)
expect_eq(a.spot, 0)
expect_near(a.timer, 4.95, 0.0001)
expect_eq(pn_drew(wildlife_st, 6), 0)
}
test "thirst beats food set out: water first, the lure not taken" (wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
pn_setup(wildlife_st, wildlife_tests_fake_st)
pn_lure(wildlife_tests_fake_st, 50, WILD_FEED, WILD_PLANTS, 5.0, 0.0)
let a = needy(wildlife_st, WILD_IDLE, 70.0, 10.0)
expect_eq(a.state, WILD_GO_DRINK)
expect_eq(a.lure, 0)
}
}