wip(0.S3): the packages migrated by ludic migrate state packages - every package test green
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1e8b5b0523
commit
07505e7ef2
294 changed files with 14996 additions and 14675 deletions
|
|
@ -19,8 +19,8 @@ program LuresTest {
|
|||
spot: fn fk_spot
|
||||
}
|
||||
|
||||
function facts() -> []WildFact { return q_drain(wildlife_facts()) }
|
||||
function set_out(uid: int, kind: int, diet: int, x: float, z: float, owner: int) -> WildLure {
|
||||
function facts(base_st: mut BaseState, wildlife_st: mut WildlifeState) -> []WildFact { return q_drain(base_st, wildlife_facts(base_st, wildlife_st)) }
|
||||
function set_out(wildlife_tests_fake_st: mut WildlifeTestsFakeState, uid: int, kind: int, diet: int, x: float, z: float, owner: int) -> WildLure {
|
||||
let l = new WildLure
|
||||
l.uid = uid
|
||||
l.kind = kind
|
||||
|
|
@ -28,24 +28,24 @@ program LuresTest {
|
|||
l.x = x
|
||||
l.z = z
|
||||
l.owner = owner
|
||||
push(fk_lures, l)
|
||||
push(wildlife_tests_fake_st.fk_lures, l)
|
||||
return l
|
||||
}
|
||||
function idle(sp: int, x: float, z: float) -> WildAnimal {
|
||||
let a = wildlife_make(sp, x, z, false, 0.0, 0, 1.0, 7)
|
||||
function idle(wildlife_st: mut WildlifeState, sp: int, x: float, z: float) -> WildAnimal {
|
||||
let a = wildlife_make(wildlife_st, sp, x, z, false, 0.0, 0, 1.0, 7)
|
||||
a.timer = 30.0
|
||||
return a
|
||||
}
|
||||
function go(a: WildAnimal, secs: float) -> void {
|
||||
for k in 0 .. int(secs * 20.0) { wildlife_tick_ground(a, 0.05, 0.05 / 60.0) }
|
||||
function go(base_st: mut BaseState, wildlife_st: mut WildlifeState, a: WildAnimal, secs: float) -> void {
|
||||
for k in 0 .. int(secs * 20.0) { wildlife_tick_ground(base_st, wildlife_st, a, 0.05, 0.05 / 60.0) }
|
||||
}
|
||||
|
||||
test "food of its diet draws it in, it eats, and the fact names what and whose" {
|
||||
fk_setup()
|
||||
set_out(41, WILD_FEED, WILD_PLANTS, 20.0, 0.0, 3)
|
||||
let a = idle(0, 0.0, 0.0)
|
||||
go(a, 40.0)
|
||||
let fs = facts()
|
||||
test "food of its diet draws it in, it eats, and the fact names what and whose" (base_st: mut BaseState, wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
|
||||
fk_setup(wildlife_st, wildlife_tests_fake_st)
|
||||
set_out(wildlife_tests_fake_st, 41, WILD_FEED, WILD_PLANTS, 20.0, 0.0, 3)
|
||||
let a = idle(wildlife_st, 0, 0.0, 0.0)
|
||||
go(base_st, wildlife_st, a, 40.0)
|
||||
let fs = facts(base_st, wildlife_st)
|
||||
var fed = 0
|
||||
for i in 0 .. len(fs) {
|
||||
if fs[i].what == WILD_FED {
|
||||
|
|
@ -58,70 +58,70 @@ program LuresTest {
|
|||
expect(a.calm > 0.0)
|
||||
}
|
||||
|
||||
test "food of another diet is left alone" {
|
||||
fk_setup()
|
||||
set_out(41, WILD_FEED, WILD_FISH, 20.0, 0.0, -1)
|
||||
let a = idle(0, 0.0, 0.0)
|
||||
go(a, 5.0)
|
||||
test "food of another diet is left alone" (base_st: mut BaseState, wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
|
||||
fk_setup(wildlife_st, wildlife_tests_fake_st)
|
||||
set_out(wildlife_tests_fake_st, 41, WILD_FEED, WILD_FISH, 20.0, 0.0, -1)
|
||||
let a = idle(wildlife_st, 0, 0.0, 0.0)
|
||||
go(base_st, wildlife_st, a, 5.0)
|
||||
expect(a.state != WILD_APPROACH)
|
||||
expect_eq(a.lure, 0)
|
||||
}
|
||||
|
||||
test "food taken away while it walks is given up" {
|
||||
fk_setup()
|
||||
set_out(41, WILD_FEED, WILD_PLANTS, 50.0, 0.0, -1)
|
||||
let a = idle(0, 0.0, 0.0)
|
||||
go(a, 1.0)
|
||||
test "food taken away while it walks is given up" (base_st: mut BaseState, wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
|
||||
fk_setup(wildlife_st, wildlife_tests_fake_st)
|
||||
set_out(wildlife_tests_fake_st, 41, WILD_FEED, WILD_PLANTS, 50.0, 0.0, -1)
|
||||
let a = idle(wildlife_st, 0, 0.0, 0.0)
|
||||
go(base_st, wildlife_st, a, 1.0)
|
||||
expect_eq(a.state, WILD_APPROACH)
|
||||
fk_gone = 41
|
||||
go(a, 0.2)
|
||||
wildlife_tests_fake_st.fk_gone = 41
|
||||
go(base_st, wildlife_st, a, 0.2)
|
||||
expect(a.state != WILD_APPROACH)
|
||||
}
|
||||
|
||||
test "a snare holds a small animal, the port can find it, and a release lets it go" {
|
||||
fk_setup()
|
||||
let l = set_out(55, WILD_SNARE, 0, 10.0, 0.0, -1)
|
||||
test "a snare holds a small animal, the port can find it, and a release lets it go" (base_st: mut BaseState, wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
|
||||
fk_setup(wildlife_st, wildlife_tests_fake_st)
|
||||
let l = set_out(wildlife_tests_fake_st, 55, WILD_SNARE, 0, 10.0, 0.0, -1)
|
||||
l.size = 0
|
||||
let h = idle(2, 0.0, 0.0)
|
||||
let h = idle(wildlife_st, 2, 0.0, 0.0)
|
||||
for k in 0 .. 40 {
|
||||
if h.state == WILD_TRAPPED { break }
|
||||
go(h, 2.0)
|
||||
go(base_st, wildlife_st, h, 2.0)
|
||||
}
|
||||
expect_eq(h.state, WILD_TRAPPED)
|
||||
expect(wildlife_in_snare(55) == h)
|
||||
let fs = facts()
|
||||
expect(wildlife_in_snare(wildlife_st, 55) == h)
|
||||
let fs = facts(base_st, wildlife_st)
|
||||
var held = false
|
||||
for i in 0 .. len(fs) { if fs[i].what == WILD_CAUGHT and fs[i].lure == 55 { held = true } }
|
||||
expect(held)
|
||||
wildlife_release(h)
|
||||
expect_eq(h.state, WILD_FLEE)
|
||||
expect(wildlife_in_snare(55) == null)
|
||||
expect(wildlife_in_snare(wildlife_st, 55) == null)
|
||||
}
|
||||
|
||||
test "a thirsty animal walks to the water the port offers, and drinks it down" {
|
||||
fk_setup()
|
||||
let a = idle(0, 0.0, 0.0)
|
||||
test "a thirsty animal walks to the water the port offers, and drinks it down" (base_st: mut BaseState, wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
|
||||
fk_setup(wildlife_st, wildlife_tests_fake_st)
|
||||
let a = idle(wildlife_st, 0, 0.0, 0.0)
|
||||
a.thirst = 90.0
|
||||
a.state = WILD_WANDER
|
||||
go(a, 0.1)
|
||||
go(base_st, wildlife_st, a, 0.1)
|
||||
expect_eq(a.state, WILD_GO_DRINK)
|
||||
expect_eq(a.spot, 900)
|
||||
go(a, 40.0)
|
||||
go(base_st, wildlife_st, a, 40.0)
|
||||
expect(a.thirst < 60.0)
|
||||
}
|
||||
|
||||
test "seed down brings a bird out of the sky and it takes it" {
|
||||
fk_setup()
|
||||
set_out(77, WILD_FEED, WILD_SEED, 30.0, 0.0, -1)
|
||||
let j = wildlife_new(3, 0.0, 0.0, false)
|
||||
fk_px[0] = 200.0 # within 900 m: an animal nobody is near does not think
|
||||
fk_pz[0] = 0.0
|
||||
test "seed down brings a bird out of the sky and it takes it" (base_st: mut BaseState, wildlife_st: mut WildlifeState, wildlife_tests_fake_st: mut WildlifeTestsFakeState) {
|
||||
fk_setup(wildlife_st, wildlife_tests_fake_st)
|
||||
set_out(wildlife_tests_fake_st, 77, WILD_FEED, WILD_SEED, 30.0, 0.0, -1)
|
||||
let j = wildlife_new(wildlife_st, 3, 0.0, 0.0, false)
|
||||
wildlife_tests_fake_st.fk_px[0] = 200.0 # within 900 m: an animal nobody is near does not think
|
||||
wildlife_tests_fake_st.fk_pz[0] = 0.0
|
||||
var landed = false
|
||||
var ate = false
|
||||
for k in 0 .. 4000 {
|
||||
wildlife_tick(0.05, 0.0)
|
||||
wildlife_tick(base_st, wildlife_st, 0.05, 0.0)
|
||||
if j.state == WILD_PERCH { landed = true }
|
||||
let fs = facts()
|
||||
let fs = facts(base_st, wildlife_st)
|
||||
for i in 0 .. len(fs) { if fs[i].what == WILD_FED and fs[i].diet == WILD_SEED { ate = true } }
|
||||
if ate { break }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue