wip(0.S3): packages and examples migrated again from their pre-0.S sources in one run

ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic
  1804 vars into 126 states, 64 into lets; 23498 edits in 460 files

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 5ffe50ed02
commit 19fcf60599
459 changed files with 17862 additions and 17603 deletions

View file

@ -1,7 +1,7 @@
# routine.ludic - going somewhere to do something, doing it here, and deciding what is next: the
# kind's own plan first, then a weighted draw among its steps for this hour, falling through to the
# next step whose spot can be found, and standing a while when none can
export function npc_go(p: NpcPerson, x: float, z: float, act: int, dur: float) -> void {
export function npc_go(npc_st: mut NpcState, p: NpcPerson, x: float, z: float, act: int, dur: float) -> void {
p.tx = x
p.tz = z
p.next_act = act
@ -13,16 +13,16 @@ export function npc_go(p: NpcPerson, x: float, z: float, act: int, dur: float) -
p.best = npc_d(p.x, p.z, x, z)
p.fx = x + (x - p.x)
p.fz = z + (z - p.z)
p.speed = 1.1 + npc_rnd() * 0.4
p.speed = 1.1 + npc_rnd(npc_st) * 0.4
}
# whatever it is, it is not done where the place says nobody stops: walk out of there first
export function npc_do(p: NpcPerson, act: int, dur: float) -> void {
export function npc_do(npc_st: mut NpcState, p: NpcPerson, act: int, dur: float) -> void {
if act != NPCA_WALK and not p.fixed and not NpcWorld.allowed(p.x, p.z) {
if npc_spot_near(p.x, p.z, 20.0, 60.0) {
if npc_spot_near(npc_st, p.x, p.z, 20.0, 60.0) {
let fx = p.fx
let fz = p.fz
npc_go(p, np_px, np_pz, act, dur)
npc_go(npc_st, p, npc_st.np_px, npc_st.np_pz, act, dur)
if act != NPCA_IDLE {
p.fx = fx
p.fz = fz
@ -58,10 +58,10 @@ function np_in_hours(s: NpcStep, h: float) -> bool {
}
# what next: the kind's plan, then its steps for this hour
export function npc_plan(p: NpcPerson) -> void {
export function npc_plan(npc_st: mut NpcState, p: NpcPerson) -> void {
p.stalk = false
if p.fixed {
npc_do(p, NPCA_IDLE, 3600.0)
npc_do(npc_st, p, NPCA_IDLE, 3600.0)
return
}
let k = NpcKinds[p.kind]
@ -69,19 +69,19 @@ export function npc_plan(p: NpcPerson) -> void {
let plan = k.plan
if plan(p) { return }
}
if k.steps != null and npc_steps(p, k.steps) { return }
if k.steps != null and npc_steps(npc_st, p, k.steps) { return }
npc_face_ahead(p)
npc_do(p, NPCA_IDLE, 10.0)
npc_do(npc_st, p, NPCA_IDLE, 10.0)
}
# a weighted draw among the steps whose hours hold now; a step whose spot cannot be found
# gives way to the next one in the table, round to the start
export function npc_steps(p: NpcPerson, steps: []NpcStep) -> bool {
export function npc_steps(npc_st: mut NpcState, p: NpcPerson, steps: []NpcStep) -> bool {
let h = NpcWorld.hour()
var total = 0
for i in 0 .. len(steps) { if np_in_hours(steps[i], h) { total += np_pos(steps[i].weight) } }
if total <= 0 { return false }
var r = npc_between(0, total - 1)
var r = npc_between(npc_st, 0, total - 1)
var first = -1
for i in 0 .. len(steps) {
if not np_in_hours(steps[i], h) { continue }