Status: done (2026-11-23)
Priority: 2
Size: M
Design ref: docs/architecture/target-v2.md 3.1 (the layers; Player and presentation); docs/architecture/modules.md
Goal: src/gen/ holds the terrain’s generation, its representation and its presentation (review of 23 November). First of four steps: the representation gets a home of its own, world/, which the generator, the simulation and the drawing all read, so that about 30 sim modules no longer import the gen facade (which carries the bake) for B alone.
Acceptance criteria:
@sys, listed in src/manifest.json before all that read them, layer kernel: world/grid (NX, NY, the odd-r directions, toAxial, hexDist, hexLocator, and csample(w, arr, x, y) as a function of the module), world/biomes (B, and the biomes’ key, name and water), world/geology (ROCK, ROCKS, DEPOSIT, DEPOSITS, ENDLESS, FIND), and treeStage in a world module (it is the contract between sim/forest, sim/spread and the drawing). The split may differ where the code asks for it: say why in the notes.gen/ for now: COVER, fullTrees, meadowStones, cover.set, keep, restore, setDeposit, reveins (generator rules applied by hand), and setBiome with the pigments (c, c2, shade), until VB-1504 takes the colours out.VB['gen'] for B, treeStage or a code of the ground: they read world/*. The page and the tests read the names and codes from world/* too. gen/cover, gen/rivers and gen/geology import what they were handed as K, G or B only because gen loaded after them.w.csample is gone from w (the one function in it); tests/plaindata.js no longer exempts w on its account, if it did.kind(w, i) in a world module names Brook, Stream or River by w.river[i] (below 38 a brook, below 225 a stream: today’s widths 8 and 16 at the default hex size), not by the drawn width; page/tileinfo reads it there. At R = 28 the names are as before: a check shows it on a generated island.node tools/same.js --base REF prints same (functions are not compared); the pixel check of VB-1500 prints same; npm run verify and node tests/smoke.js pass.docs/architecture/modules.md, tools/writes.js (GEN), the @state lines and AGENTS.md (Finding things, Conventions) follow where they name what moved.
Notes:KIND, kind): a river’s name is neither grid nor biome. gen/biomes keeps the pigments and gives the drawing BIOMES with
them merged onto world/biomes’ (VB-1504 takes them). gen/noise and gen/biomes load right after world/, so gen/cover, gen/geology and
gen/rivers import mulberry32, B, BIOMES and setBiome; the rivers’ sources (hills, mountains, marsh) moved into gen/rivers.
The gen facade fell from 15 to 10 exports (B, NX, NY, hexLocator, treeStage); setBiome stays on it for sim/forest, sim/spread, sim/saves.
The page reads Biomes, Grid, Strata (world/geology), Flow (world/rivers), declared in page/setup. tools/writes.js GEN unchanged:
world/* writes nothing. samepixels’ adapter calls cover.set with or without G, so both commits bake. same.js and samepixels: same.hrnd is terrain (sim/layout reads it, and it is drawn from the main stream before the map’s name): it does not move. The gen facade stands at 15 exports, the lint’s width: an alias left for a while needs none added.