feat(base): 0.R4 - a queue keeps its own count, so every package verb takes only its own state; ludic migrate state --prune

ludic.base's Queue<T> carries a QueueTag (its name and pending count): queue_new(name), q_push(q, v),
q_drain(q), q_clear(q) take no BaseState, and core_undrained(tags) names the given queues still holding
facts. A reducer on a package's state can now call that package's verbs (wallet_earn(wallet_st, n)).

ludic migrate state --prune (ludicc --migrate-prune) takes out each state parameter a function no
longer uses, nor anything it calls, and the argument that fills it - including an argument for a
parameter the callee has dropped, which is taken out before the call is checked, so a generic's T is
told by the argument that says it. A reducer keeps its state. --dry-run now counts the edits it would
make. Every package was moved with it: 608 base_st parameters and their arguments, 1889 edits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-26 04:19:56 +03:00
parent 8cf4b3fed6
commit 71735b10a2
151 changed files with 58668 additions and 54719 deletions

View file

@ -1,14 +1,14 @@
# birds.ludic - a bird circles its home at its own height, comes down now and then (for seed from
# further off than for nothing), glides in rather than dropping, pecks and drinks, and lifts off
export function wildlife_tick_bird(base_st: mut BaseState, wildlife_st: mut WildlifeState, a: WildAnimal, dt: float) -> void {
export function wildlife_tick_bird(wildlife_st: mut WildlifeState, a: WildAnimal, dt: float) -> void {
a.timer = a.timer - dt
let dh = wl_near(wildlife_st, a.x, a.z)
if a.state == WILD_LAND {
wl_land(base_st, wildlife_st, a, dh, dt)
wl_land(wildlife_st, a, dh, dt)
return
}
if a.state == WILD_PERCH {
wl_perch(base_st, wildlife_st, a, dh, dt)
wl_perch(wildlife_st, a, dh, dt)
return
}
wl_circle(wildlife_st, a, dt)
@ -63,12 +63,12 @@ function wl_take_off(wildlife_st: mut WildlifeState, a: WildAnimal, h: float) ->
a.fly_h = Math.max(a.fly_h, h)
}
function wl_land(base_st: mut BaseState, wildlife_st: mut WildlifeState, a: WildAnimal, dh: float, dt: float) -> void {
function wl_land(wildlife_st: mut WildlifeState, a: WildAnimal, dh: float, dt: float) -> void {
let s = wl_sp(wildlife_st, a.sp)
a.fly_h = Math.max(0.0, a.fly_h - dt * 3.2)
a.speed = s.walk * 0.8
wl_face(a, a.tx, a.tz, 2.4, dt)
wl_step(base_st, wildlife_st, a, dt)
wl_step(wildlife_st, a, dt)
a.y = WildlifeWorld.ground(a.x, a.z) + a.fly_h
a.bank = 0.2 * Math.clamp(a.fly_h / 4.0, 0.0, 1.0)
if dh < s.flee or a.timer < -20.0 {
@ -84,14 +84,14 @@ function wl_land(base_st: mut BaseState, wildlife_st: mut WildlifeState, a: Wild
}
# on the ground it pecks at seed or takes a drink at the water's edge; it leaves no droppings
function wl_perch(base_st: mut BaseState, wildlife_st: mut WildlifeState, a: WildAnimal, dh: float, dt: float) -> void {
function wl_perch(wildlife_st: mut WildlifeState, a: WildAnimal, dh: float, dt: float) -> void {
a.speed = 0.0
a.y = WildlifeWorld.ground(a.x, a.z)
a.bank = 0.0
if wl_bird_seed(wildlife_st, a) and Math.sqrt((wildlife_st.wl_best.x - a.x) * (wildlife_st.wl_best.x - a.x) + (wildlife_st.wl_best.z - a.z) * (wildlife_st.wl_best.z - a.z)) < 3.0 {
a.hunger = Math.max(a.hunger - 30.0 * dt, 0.0)
a.timer = Math.max(a.timer, 1.0)
if wl_rnd(wildlife_st) < 0.12 * dt and WildlifeWorld.present(wildlife_st.wl_best.uid) { wl_ate(base_st, wildlife_st, a, wildlife_st.wl_best.uid, wildlife_st.wl_best.owner, WILD_SEED) }
if wl_rnd(wildlife_st) < 0.12 * dt and WildlifeWorld.present(wildlife_st.wl_best.uid) { wl_ate(wildlife_st, a, wildlife_st.wl_best.uid, wildlife_st.wl_best.owner, WILD_SEED) }
} else if wl_wet(a.x - Math.sin(a.yaw) * 2.0, a.z - Math.cos(a.yaw) * 2.0, 0.05) {
a.thirst = Math.max(a.thirst - 30.0 * dt, 0.0)
}