ludic.things: a removed Thing's record placed again, oldest first past a lag of 32; things_reserve sizes the grid once

thing_put and thing_spawn made a new record for every Thing placed, and the world places and removes
them all day (an animal's sign and bed, a drop, a fish), so play grew by a record per placement.
Removed records wait in a queue compacted in place; once 32 wait, the oldest is set back as new
with a new uid. ludic.base's grid_reserve makes the buckets for n rows now, since a rehash in play
leaves the old bucket array behind. Tests: a record comes back only past the lag, as new, with a
new uid, the indexes agree, and the spare queue stays bounded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 11:52:23 +03:00
parent 5d71892b7c
commit 1af62d0879
7 changed files with 101 additions and 2 deletions

View file

@ -1,7 +1,7 @@
# verbs.ludic - the only ways a Thing is made, removed, moved, shown or hidden: each writes the
# record and the table's columns together, so the grid and the kind indexes never fall behind
export function thing_spawn(things_st: mut ThingsState, kind: int, look: string, x: float, y: float, z: float, yaw: float, id: int) -> Thing {
return th_place(things_st, new Thing, kind, look, x, y, z, yaw, id)
return th_place(things_st, th_record(things_st), kind, look, x, y, z, yaw, id)
}
function th_place(things_st: mut ThingsState, t: Thing, kind: int, look: string, x: float, y: float, z: float, yaw: float, id: int) -> Thing {
@ -41,7 +41,7 @@ function th_columns(t: Thing) -> void {
# a Thing on the ground (the port's), set into it by `sink`, used from `reach`
export function thing_put(things_st: mut ThingsState, kind: int, look: string, x: float, z: float, yaw: float, sink: float, reach: float, id: int) -> Thing {
let t = new Thing
let t = th_record(things_st)
t.reach = reach
return th_place(things_st, t, kind, look, x, ThingsWorld.ground(x, z) - sink, z, yaw, id)
}
@ -54,6 +54,7 @@ export function thing_remove(things_st: mut ThingsState, t: Thing) -> void {
imap_del(things_st.th_uids, t.uid)
tb_remove(t.tab, t.ent)
t.ent = -1
th_spare_put(things_st, t)
}
# every Thing `gone` says so is removed for good; from the last row down, so the row a removal