Add the terrain store: region grids and tile cache - #55
Conversation
Coverage Report for CI Build 32647543760Coverage increased (+1.0%) to 97.744%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
d974f1c to
1ea3053
Compare
KurbyDoo
left a comment
There was a problem hiding this comment.
I changed some of the specifications of the original tickets since they don't really match what I'm thinking anymore, could you update this PR accordingly? Thanks
| import numpy as np | ||
|
|
||
|
|
||
| class RegionGrids: |
There was a problem hiding this comment.
sorry I'm looking back at the original paper and it doesn't look like there are two different objects to store region grids and tile cache, can we merge the two into one. the only thing that should be cached is the weight value product and the weights as two seperate grids
| """Whether a tile is held, without counting as a use of it.""" | ||
| return seed in self._tiles | ||
|
|
||
| def get(self, seed: int) -> np.ndarray | None: |
There was a problem hiding this comment.
I also think caching by seed is no longer best, can we instead cache by tile x, y coordinates. you can assume that every tile will live at a location at some x and y in a global coordinate space. in general tiles divide the global space into a partition with no overlap
Summary
Implements the Terrain Store (#31) — all six sub-tickets in one PR, since
the two halves are small and share a module.
RegionGrids— scratch space for one region. Holds a sum grid and aweight grid, accumulates each window as
value × weightandweight,and divides one by the other in
heights(). Written to only by thesampler (Clean every window and add the results into the region grids #35).
TileCache— finished tiles by seed, LRU-evicted at a fixedcapacity. Touched only by generation orchestration (Generation Orchestration #36).
Adds numpy (2.5.2) as the project's first runtime dependency, per
CONTRIBUTING:
pyproject.tomlanduv.lockare both committed.Validation
scripts/quality-check.shpasses locally/testcommands were run and are passing (e.g./test gpu)27 tests in
tests/test_store.py, covering every assertion listed in#40–#45. The overlap test uses the worked 1×6 example from #31 directly.
Full suite is 68 passed.
Checklist
Additional Comments
Two decisions worth a second opinion:
putcopies the incoming array so the generator can reuse its buffer,but
gethands back the cache's own grid rather than a copy — copyingon every read would undo the point of caching. Callers should treat a
returned tile as read-only. Happy to change this if you would rather it
be defensive on both sides.
sub-ticket, so it is not implemented here.
Closes #40, #41, #42, #43, #44, #45