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>
83 lines
3 KiB
Text
83 lines
3 KiB
Text
# approach_pins_test.ludic - phase 27.2a: APPROACH as it stands. Its lure gone, IDLE 2 s; within
|
|
# 1.3 m it EATs - 14 s at food, 9 at a lure - or a snare holds it (TRAPPED where the snare is, a
|
|
# CAUGHT fact); no roll on any of it
|
|
import "ludic.wildlife"
|
|
import "ludic.base"
|
|
import "fake"
|
|
import "pin"
|
|
program ApproachPins {
|
|
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 coming(wildlife_st: mut WildlifeState, kind: int, lure_x: float) -> WildAnimal {
|
|
let a = pn_at(wildlife_st, 2, 0.0, 0.0, WILD_APPROACH, 5.0)
|
|
a.lure = 50
|
|
a.lure_kind = kind
|
|
a.lure_x = lure_x
|
|
a.lure_z = 0.0
|
|
a.lure_owner = 3
|
|
wildlife_seed(wildlife_st, 13)
|
|
pn_step(wildlife_st, a)
|
|
return a
|
|
}
|
|
|
|
test "APPROACH, its lure gone: IDLE 2 s, the lure let go" (wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
|
|
pn_setup(wildlife_st, wildlife_tests_fake_st)
|
|
wildlife_tests_fake_st.fk_gone = 50
|
|
let a = coming(wildlife_st, WILD_FEED, 20.0)
|
|
expect_eq(a.state, WILD_IDLE)
|
|
expect_near(a.timer, 2.0, 0.0001)
|
|
expect_eq(a.lure, 0)
|
|
expect_eq(pn_drew(wildlife_st, 13), 0)
|
|
}
|
|
|
|
test "APPROACH on its way: walks at its walk, the timer untouched by arriving" (wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
|
|
pn_setup(wildlife_st, wildlife_tests_fake_st)
|
|
let a = coming(wildlife_st, WILD_FEED, 20.0)
|
|
expect_eq(a.state, WILD_APPROACH)
|
|
expect_near(a.speed, 1.0, 0.0001)
|
|
expect_near(a.timer, 4.95, 0.0001)
|
|
expect_eq(pn_drew(wildlife_st, 13), 0)
|
|
}
|
|
|
|
test "APPROACH within 1.3 m: EAT 14 s at food, 9 s at a lure" (wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
|
|
pn_setup(wildlife_st, wildlife_tests_fake_st)
|
|
let a = coming(wildlife_st, WILD_FEED, 1.0)
|
|
expect_eq(a.state, WILD_EAT)
|
|
expect_near(a.timer, 14.0, 0.0001)
|
|
expect_near(a.speed, 0.0, 0.00001)
|
|
let b = coming(wildlife_st, WILD_LURE, 1.0)
|
|
expect_eq(b.state, WILD_EAT)
|
|
expect_near(b.timer, 9.0, 0.0001)
|
|
expect_eq(pn_count(pn_drain(wildlife_st), WILD_FED), 0)
|
|
expect_eq(pn_drew(wildlife_st, 13), 0)
|
|
}
|
|
|
|
test "APPROACH within 1.3 m of a snare: TRAPPED on the snare, CAUGHT with the snare and its owner" (wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
|
|
pn_setup(wildlife_st, wildlife_tests_fake_st)
|
|
let a = coming(wildlife_st, WILD_SNARE, 1.0)
|
|
expect_eq(a.state, WILD_TRAPPED)
|
|
expect_near(a.x, 1.0, 0.0001)
|
|
expect_near(a.z, 0.0, 0.0001)
|
|
expect_near(a.y, 10.0, 0.0001)
|
|
let fs = pn_drain(wildlife_st)
|
|
expect_eq(pn_count(fs, WILD_CAUGHT), 1)
|
|
expect_eq(fs[0].lure, 50)
|
|
expect_eq(fs[0].owner, 3)
|
|
expect_eq(pn_drew(wildlife_st, 13), 0)
|
|
}
|
|
}
|