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:
parent
d7adc28125
commit
67d477af77
19 changed files with 1521 additions and 0 deletions
82
packages/ludic.wildlife/tests/perch_pins_test.ludic
Normal file
82
packages/ludic.wildlife/tests/perch_pins_test.ludic
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
# perch_pins_test.ludic - phase 27.2a: a bird coming down and on the ground as it stands. Gliding in,
|
||||
# down and within 2 m it PERCHes for 8 + 16 r0 s; anyone within its flee, or 20 s over its time,
|
||||
# lifts it (FLY, 20 + 40 r0 s); on the ground its time up or anyone within its flee lifts it too
|
||||
import "ludic.wildlife"
|
||||
import "ludic.base"
|
||||
import "fake"
|
||||
import "pin"
|
||||
program PerchPins {
|
||||
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 bird(wildlife_st: mut WildlifeState, state: int, timer: float, fly_h: float) -> WildAnimal {
|
||||
let a = pn_at(wildlife_st, 3, 0.0, 0.0, state, timer)
|
||||
a.fly_h = fly_h
|
||||
wildlife_seed(wildlife_st, 17)
|
||||
pn_fly(wildlife_st, a)
|
||||
return a
|
||||
}
|
||||
|
||||
test "LAND, down and at its spot: PERCH for 8 + 16 r0 s, one roll" (wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
|
||||
pn_setup(wildlife_st, wildlife_tests_fake_st)
|
||||
let a = bird(wildlife_st, WILD_LAND, 20.0, 0.1)
|
||||
expect_eq(a.state, WILD_PERCH)
|
||||
expect_near(a.timer, 8.0 + 16.0 * pn_roll(17, 0), 0.0001)
|
||||
expect_near(a.fly_h, 0.0, 0.00001)
|
||||
expect_eq(pn_drew(wildlife_st, 17), 1)
|
||||
}
|
||||
|
||||
test "LAND still high: gliding on, no roll" (wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
|
||||
pn_setup(wildlife_st, wildlife_tests_fake_st)
|
||||
let a = bird(wildlife_st, WILD_LAND, 20.0, 5.0)
|
||||
expect_eq(a.state, WILD_LAND)
|
||||
expect_near(a.fly_h, 5.0 - 0.05 * 3.2, 0.0001)
|
||||
expect_eq(pn_drew(wildlife_st, 17), 0)
|
||||
}
|
||||
|
||||
test "LAND with somebody within its flee, or 20 s past its time: FLY for 20 + 40 r0 s at the height it had" (wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
|
||||
pn_setup(wildlife_st, wildlife_tests_fake_st)
|
||||
let b = bird(wildlife_st, WILD_LAND, -19.99, 5.0)
|
||||
expect_eq(b.state, WILD_FLY)
|
||||
expect_near(b.fly_h, 5.0 - 0.05 * 3.2, 0.0001)
|
||||
pn_player(wildlife_tests_fake_st, 5.0, 0.0)
|
||||
let a = bird(wildlife_st, WILD_LAND, 20.0, 5.0)
|
||||
expect_eq(a.state, WILD_FLY)
|
||||
expect_near(a.timer, 20.0 + 40.0 * pn_roll(17, 0), 0.0001)
|
||||
expect_eq(pn_drew(wildlife_st, 17), 1)
|
||||
}
|
||||
|
||||
test "PERCH, its time up or somebody within its flee: FLY for 20 + 40 r0 s, 0.5 m up" (wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
|
||||
pn_setup(wildlife_st, wildlife_tests_fake_st)
|
||||
let a = bird(wildlife_st, WILD_PERCH, 0.01, 0.0)
|
||||
expect_eq(a.state, WILD_FLY)
|
||||
expect_near(a.timer, 20.0 + 40.0 * pn_roll(17, 0), 0.0001)
|
||||
expect_near(a.fly_h, 0.5, 0.0001)
|
||||
pn_player(wildlife_tests_fake_st, 5.0, 0.0)
|
||||
let b = bird(wildlife_st, WILD_PERCH, 5.0, 0.0)
|
||||
expect_eq(b.state, WILD_FLY)
|
||||
expect_eq(pn_drew(wildlife_st, 17), 1)
|
||||
}
|
||||
|
||||
test "PERCH before its time, nobody near: stays, no roll" (wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
|
||||
pn_setup(wildlife_st, wildlife_tests_fake_st)
|
||||
let a = bird(wildlife_st, WILD_PERCH, 5.0, 0.0)
|
||||
expect_eq(a.state, WILD_PERCH)
|
||||
expect_near(a.timer, 4.95, 0.0001)
|
||||
expect_eq(pn_drew(wildlife_st, 17), 0)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue