Status: done (2026-11-15)
Priority: 2
Size: S
Design ref: none (cost; AGENTS.md, Rules for cost 6 and 8). src/sim/routes.js, reachTiles; src/sim/fish.js, src/sim/forage.js, src/sim/deer.js, ground
Goal: The fishing, gathering and hunting grounds of a house (ground in sim/fish, sim/forage and sim/deer) each ran a breadth-first search of the house’s walking reach at every ask: when the household’s work is refreshed and again for each idle pawn looking for work. The search’s order depends only on where a pawn can stand, which play does not change; only the test of each tile (stock, cover, building) does. The order is searched once a house and reach and kept; the tests stay live, so the grounds found are the same.
Acceptance criteria:
reachTiles(w, from, steps) in sim/routes gives the search’s tiles in its order, kept beside the world (never in st, never saved); the three grounds scan it.node tools/same.js --base c5b7ee3 --scenario founders,heirs,populous --seeds 7,42 --map tiny --years 3 prints same.tests/lib/invariants.js): each kept list of a live farm is what a new search finds. A test in tests/routes.js (fast) of the list, and of the lists searched again when a tile’s standing changes.5ce315e) put the time under the jobs functions at about 19 ms a game day against 4; the ground searches were its clearest single item.WeakMap by world in sim/routes’ closure, not in st or on w. It is derived from the world alone (as sim/fish’s lakeSize), so a loaded run cannot drift from it; on w it would have been a new world leaf for tools/same.js and the saves to step round. Where a pawn can stand: not water, not a river away from its crossings, not snow; a house can be stood on (passable). No act of play changes those today. Should one (a bridge built), costChanged compares the tile’s standing with what the lists were searched under and drops them all; the invariant checks the lists daily against new searches.ground functions with what they call 2.83 and 0.34; refreshJobs 6.23 and 4.67; lookForWork 1.92 and 0.95; the whole run with its generation 55.6 and 50.9. The year lines (ms a day, years 1 to 4): 53.5, 43.5, 46.9, 59.5 before; 50.0, 40.1, 40.6, 51.2 after. One run each: the totals carry a few ms of noise, the ground lines do not.fishGround, forageGround and deerGround now count the tiles tested, not the tiles searched; they barely move (per living pawn-day, recorded and now: 45.86 and 46.3, 15.67 and 14.85, 10.57 and 10.57), because most asks find no ground and test the whole reach. All in target; the recorded values are left.sim/routes goes to 18 exports over its baseline of 17: VB-451 opened to split it.small-y40, medium-ref); sim/drying’s nearWater and boatShore and sim/dig’s search run the same search but are already kept by their callers, and are left.