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: Last step of the terrain split: generate builds the map’s colours, hillshade, brush texture and coast distance into w in every run, headless too, and the simulation keeps the colours up through setBiome. They become a cache the page builds from the world and recolours itself, so the world holds terrain and run state only, and the generator and the simulation know no colour.
Acceptance criteria:
draw/paint builds a world’s paint from the world alone: tr, tg, tb per tile, shade, cdist and chex per coarse cell, and the brush texture tile (makeTile moves with it). generate no longer makes them, and w no longer holds them: their @state lines, tools/stocks.js (NOT_STOCKS) and tests/lib/tiny.js follow. macro, hrnd and elev stay in w: they are terrain (meadow stones read macro, sim/layout reads hrnd), so a seed’s world and a save are unchanged.c, c2, shade) and the sea’s and the lake’s colours are draw/pigments; the biome table of world/biomes holds key, name and water. setBiome writes the biome alone, in a world module; sim/saves sets the loaded biome as it sets the other arrays.paintOf(wd) in page/chunks, a WeakMap), not in a module’s closure; bakeWater and bakeChunk take it as an argument.st.biomeDirty before their chunks are repainted, the editor’s strokes, restore (page/editplace), and a load onto a world already painted. The pixel check, not the bake, asserts that no colour is stale: after each of those four, the cache equals one built anew.mc in double precision from csample(w.macro, ...) and w.hrnd, stored to Float32): the pixel check of VB-1500 prints same, also after a cover set by hand and after restore.node tools/same.js --base REF differs only by the seven fields gone from w, listed in the result; npm run verify, node tests/smoke.js and the browser tests of the map and the editor pass.sim.js in the manifest names a colour: grep -n "tr\[\|\.c2\b\|shade" src/gen.js src/gen src/world finds only the relief (elev). docs/architecture/modules.md follows.
Notes:w.crossing is not in the WORLD list of sim/saves; nothing writes it yet, and the task that builds bridges adds it.page/tileinfo’s depth line reads the paint’s cdist (w.landDist counts tile steps, so it would change the line). A world put back whole (the editor’s edRestore, a load) drops its paint, built anew on the next bake, rather than recolouring every tile: the plainer rule, and shade, cdist and the texture are cheap beside a world’s generation. page/animate now runs refreshTrees when st.biomeDirty alone is set (it waited for st.treeDirty): without it a chunk baked meanwhile would keep a stale colour, which the bake no longer mends. gen/biomes is kept, holding COVER only (the generator’s cover rule; no rename). The moves (pigments, makeTile) are committed after the change, not before: before it, gen built the colours and could not name a draw/ module.