feat(ludic.base): the vocabulary mechanic packages share - Tick, phases, Queue<T>, rng streams, the save tree, the system runner

A mechanic package depends on ludic.base and nothing else: ports (records of
function values for now) for questions, queues for facts, verbs for changes,
phases for order and its own versioned save section. The runner inits, resets,
saves and loads systems in the order added and ticks them phase by phase; a
missing save section is a reset. Tests for each piece and a worked route
between two toy mechanics live under tests/. The old ludic.core (engine ECS
components) is used by examples/library and stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 04:01:16 +03:00
parent ec9a650e65
commit dd6a449921
16 changed files with 928 additions and 0 deletions

View file

@ -0,0 +1,28 @@
# a toy mechanic: a pack of counts by kind, saved in its own section
module toy_pack
numbers float
import "ludic.base"
var counts: []int = null
export function pack_add(kind: int, n: int) -> void { counts[kind] = counts[kind] + n }
export function pack_count(kind: int) -> int { return counts[kind] }
function pack_reset() -> void {
counts = new []int
for i in 0 .. 3 { push(counts, 0) }
}
function pack_save() -> Val {
let v = Value.object()
sv_put_ints(v, "counts", counts)
return v
}
function pack_load(v: Val, version: int) -> void {
pack_reset()
let xs = sv_ints(v, "counts")
for i in 0 .. len(xs) { if i < len(counts) { counts[i] = xs[i] } }
}
export function pack_system() -> System {
let s = system_new("pack", PH_COMMIT)
s.reset = fn pack_reset
s.save = fn pack_save
s.load = fn pack_load
return s
}