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,43 +1,43 @@
# verbs.ludic - the only way the clock changes
export function clock_set_scale(s: float) -> void { ck_scale = s }
export function clock_set_day(d: int) -> void { ck_day = d }
export function clock_set_moon(m: float) -> void { ck_moon = m }
export function clock_set_scale(clock_st: mut ClockState, s: float) -> void { clock_st.ck_scale = s }
export function clock_set_day(clock_st: mut ClockState, d: int) -> void { clock_st.ck_day = d }
export function clock_set_moon(clock_st: mut ClockState, m: float) -> void { clock_st.ck_moon = m }
# the hour, wrapped into [0, 24); setting it never turns the day - that is clock_new_day's
export function clock_set_hours(h: float) -> void {
export function clock_set_hours(clock_st: mut ClockState, h: float) -> void {
var x = h % 24.0
if x < 0.0 { x = x + 24.0 }
ck_hours = x
clock_st.ck_hours = x
}
function ck_turn(how: int) -> void {
ck_day += 1
ck_moon = (ck_moon + 1.0 / ck_moon_days) % 1.0
function ck_turn(base_st: mut BaseState, clock_st: mut ClockState, how: int) -> void {
clock_st.ck_day += 1
clock_st.ck_moon = (clock_st.ck_moon + 1.0 / clock_st.ck_moon_days) % 1.0
let d = new DayTurned
d.day = ck_day
d.day = clock_st.ck_day
d.how = how
q_push(clock_days(), d)
q_push(base_st, clock_days(base_st, clock_st), d)
}
# a new day however it came (a night slept, a collapse); the caller sets the hour first
export function clock_new_day() -> void { ck_turn(DAY_SLEPT) }
export function clock_new_day(base_st: mut BaseState, clock_st: mut ClockState) -> void { ck_turn(base_st, clock_st, DAY_SLEPT) }
# run the hours on by `gh` game hours; past midnight the day turns. Only the machine that owns
# the world moves it - another machine is told the time.
export function clock_advance(gh: float) -> void {
export function clock_advance(base_st: mut BaseState, clock_st: mut ClockState, gh: float) -> void {
if not ck_owns() { return }
ck_hours = ck_hours + gh
while not (ck_hours < 24.0) {
ck_hours = ck_hours - 24.0
ck_turn(DAY_STAYED_UP)
clock_st.ck_hours = clock_st.ck_hours + gh
while not (clock_st.ck_hours < 24.0) {
clock_st.ck_hours = clock_st.ck_hours - 24.0
ck_turn(base_st, clock_st, DAY_STAYED_UP)
}
}
# a new trip: day one at the start hour, the moon somewhere in its month
export function clock_reset() -> void {
ck_dice = rng_new(ClockWorld.seed())
ck_day = 1
ck_hours = ck_start_hours
ck_moon = rng_span(ck_dice, ck_moon_lo, ck_moon_hi) % 1.0
q_clear(clock_days())
export function clock_reset(base_st: mut BaseState, clock_st: mut ClockState) -> void {
clock_st.ck_dice = rng_new(ClockWorld.seed())
clock_st.ck_day = 1
clock_st.ck_hours = clock_st.ck_start_hours
clock_st.ck_moon = rng_span(clock_st.ck_dice, clock_st.ck_moon_lo, clock_st.ck_moon_hi) % 1.0
q_clear(base_st, clock_days(base_st, clock_st))
}