wip(0.S2): migrate - a var nothing writes becomes a let; a state is keyed by its module, directory or program, so every program's plan agrees; paths normalized; program states named SceneDemoState / scene_demo_st; the LSP reads state, mut and entry/handler parameters

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 15:31:34 +03:00
parent 3eda72e8c2
commit 5ffe50ed02
463 changed files with 72045 additions and 67421 deletions

View file

@ -1,36 +1,36 @@
# queries.ludic - what the world asks the body
export function needs_level(needs_st: mut NeedsState, k: int) -> float {
export function needs_level(k: int) -> float {
if not nd_ok(k) { return 0.0 }
return nd_lv(needs_st)[k]
return nd_lv()[k]
}
export function needs_warmth(needs_st: mut NeedsState) -> float { return nd_lv(needs_st)[NEED_WARMTH] }
export function needs_food(needs_st: mut NeedsState) -> float { return nd_lv(needs_st)[NEED_FOOD] }
export function needs_water(needs_st: mut NeedsState) -> float { return nd_lv(needs_st)[NEED_WATER] }
export function needs_energy(needs_st: mut NeedsState) -> float { return nd_lv(needs_st)[NEED_ENERGY] }
export function needs_warmth() -> float { return nd_lv()[NEED_WARMTH] }
export function needs_food() -> float { return nd_lv()[NEED_FOOD] }
export function needs_water() -> float { return nd_lv()[NEED_WATER] }
export function needs_energy() -> float { return nd_lv()[NEED_ENERGY] }
# seconds left before a collapse (0: no countdown), and the need it is for
export function needs_last_legs(needs_st: NeedsState) -> float { return needs_st.nd_legs }
export function needs_last_need(needs_st: NeedsState) -> int { return needs_st.nd_last }
export function needs_collapses(needs_st: NeedsState) -> int { return needs_st.nd_collapses }
export function needs_last_legs() -> float { return nd_legs }
export function needs_last_need() -> int { return nd_last }
export function needs_collapses() -> int { return nd_collapses }
# the walk's pace, times: the ramp of each need, and 0.6 more on last legs
export function needs_pace(needs_st: mut NeedsState) -> float {
let lv = nd_lv(needs_st)
export function needs_pace() -> float {
let lv = nd_lv()
var m = nd_pace(lv[NEED_WARMTH]) * nd_pace(lv[NEED_FOOD])
if NeedsWorld.thirst() { m = m * nd_pace(lv[NEED_WATER]) }
if needs_st.nd_legs > 0.0 { m = m * 0.6 }
if nd_legs > 0.0 { m = m * 0.6 }
return m
}
# running needs legs, calories and a body that is not already in trouble
export function needs_can_run(needs_st: mut NeedsState) -> bool {
let lv = nd_lv(needs_st)
export function needs_can_run() -> bool {
let lv = nd_lv()
return lv[NEED_ENERGY] > 8.0 and lv[NEED_FOOD] > 20.0 and lv[NEED_WARMTH] > 20.0 and lv[NEED_WATER] > 20.0
}
# the lowest of the four
export function needs_lowest(needs_st: mut NeedsState) -> float {
let lv = nd_lv(needs_st)
export function needs_lowest() -> float {
let lv = nd_lv()
return Math.min(Math.min(lv[NEED_WARMTH], lv[NEED_FOOD]), Math.min(lv[NEED_WATER], lv[NEED_ENERGY]))
}