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

@ -24,6 +24,8 @@ export state ThingsState {
th_uid: int = 0
th_facts: Queue<ThingFact> = th_facts__new()
th_hs: words = words(0) # things_tick's handles, taken before any tick runs
th_spare: []Thing = new []Thing # removed records, made again oldest first (spare.ludic)
th_spare_at: int = 0
}
function th_facts__new() -> Queue<ThingFact> { return queue_new("things.facts") }