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:
parent
5d71892b7c
commit
1af62d0879
7 changed files with 101 additions and 2 deletions
|
|
@ -38,3 +38,9 @@ function grid_rehash(g: Grid) -> void {
|
|||
if k >= 0 { grid_link(g, r, k, grid_bucket(g, grid_key_x(k), grid_key_z(k))) }
|
||||
}
|
||||
}
|
||||
|
||||
# buckets enough for `rows` filed rows before a rehash, made now: a rehash in play makes a new
|
||||
# bucket array and nothing gives the old one back
|
||||
export function grid_reserve(g: Grid, rows: int) -> void {
|
||||
while (g.mask + 1) * 2 < rows { grid_rehash(g) }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue