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>
70 lines
2.7 KiB
Text
70 lines
2.7 KiB
Text
# state.ludic - the port, the prints, the facts, and what the reader has learned
|
|
# what the tracks ask the world. Any member may be left out of the bind: the time is then 0,
|
|
# the reader can name every animal, no bearing is given, and nothing is drawn.
|
|
export port TracksWorld {
|
|
now: fn() -> float = fn tk_time_zero # game hours, counted from the start of the trip
|
|
skill: fn() -> int = fn tk_every_skill # how well the reader reads (the game's tiers)
|
|
bearing: fn(float) -> string = fn tk_no_bearing # a yaw in words ("north-west"), "" for none
|
|
placed: fn(int, int) -> void = fn tk_not_drawn # a print was put down at (kind, ring index): draw it
|
|
}
|
|
function tk_time_zero() -> float { return 0.0 }
|
|
function tk_every_skill() -> int { return 2147483647 }
|
|
function tk_no_bearing(yaw: float) -> string { return "" }
|
|
function tk_not_drawn(kind: int, i: int) -> void { }
|
|
|
|
# where a sign came from
|
|
export const TRACK_PRINT: int = 0 # a print in a ring, read with tracks_read
|
|
export const TRACK_SIGN: int = 1 # a legend's sign, told with tracks_note
|
|
export const TRACK_SCAT: int = 2 # droppings, told with tracks_note
|
|
|
|
# how old a print looks
|
|
export const TRACK_FRESH: int = 0
|
|
export const TRACK_RECENT: int = 1
|
|
export const TRACK_OLD: int = 2
|
|
|
|
export property Track {
|
|
x: float = 0.0
|
|
z: float = 0.0
|
|
yaw: float = 0.0
|
|
sp: int = 0
|
|
legend: bool = false
|
|
made: float = 0.0
|
|
read: bool = false
|
|
}
|
|
|
|
# a sign was read: `first` the first time this one was, `named` whether the reader could tell
|
|
# the animal, `bearing` the way it went in words ("" without them)
|
|
export property TrackRead {
|
|
sp: int = 0
|
|
source: int = 0
|
|
kind: int = 0
|
|
legend: bool = false
|
|
age: float = 0.0
|
|
fresh: int = 0
|
|
yaw: float = 0.0
|
|
named: bool = true
|
|
bearing: string = ""
|
|
first: bool = false
|
|
}
|
|
|
|
export state TracksState {
|
|
tk_kinds: int = 0
|
|
tk_cap: int = 0
|
|
tk_ring: []Track = null # kinds x cap, kind-major
|
|
tk_count: []int = null # per kind: how many of the ring are in use
|
|
tk_next: []int = null # per kind: where the next print goes
|
|
tk_name_at: int = 0 # the skill that tells the animal from its print
|
|
tk_fresh_h: float = 0.5
|
|
tk_recent_h: float = 2.5
|
|
tk_read_n: int = 0 # signs read for the first time, of every source
|
|
tk_yaw: float = 0.0 # the heading of the last sign read
|
|
tk_has_yaw: bool = false
|
|
tk_reads: Queue<TrackRead> = null
|
|
}
|
|
|
|
|
|
# the facts: every sign read, oldest first
|
|
export function tracks_reads(base_st: mut BaseState, tracks_st: mut TracksState) -> Queue<TrackRead> {
|
|
if tracks_st.tk_reads == null { tracks_st.tk_reads = queue_new(base_st, "tracks.reads") }
|
|
return tracks_st.tk_reads
|
|
}
|