# Wave collapse ## What this builds A grid of cells, each a superposition of tiles. At each step the cell of lowest entropy is chosen, a tile is picked from the seed, and neighbours are constrained by an adjacency table. If a cell has no tile left, the run retries from the start, up to a documented limit, or reports a contradiction. The tilesets are original. A seeded run is deterministic and never places a forbidden pair. Read `spekkr.inputs.json` first. `title` labels the grid. `width`, `height` and `seed` size and pin the run. `tileset` chooses the rules. `explain` and `step` change the chrome. ## Out of scope - A 3D or irregular mesh in this version. - Network or a public tileset workshop in the checks. - A licensed commercial tileset. ## Requirements Each requirement has an id. Checks name the id they cover. ### R1. Adjacency and determinism - A placed pair of neighbours is always in the tileset's allowed list, for each of the four sides. - The same tileset, size and seed produce the same sequence of placements, and the same final grid or the same contradiction after the same number of retries. - Seed 7, coast, 16 by 16, finishes in the grid `fixtures/wfc-coast-7.txt` with no retry. Accept when: the seed-7 grid matches the file, and a scan of every edge is in the allowed list. ### R2. Contradiction and retry - A fixture tileset `broken` (tests only) has no complete tiling of a 3 by 3 grid and must report `contradiction` after 8 retries. - A retry starts from a full superposition and consumes the seed from where it left off, as in `design.md`. - The UI can show a contradiction cell; screenshot `contradiction` is taken from this fixture. Accept when: the broken 3 by 3 reports contradiction after 8 retries, and the retry count is in the result. ### R3. Frames and files - Frames: the starting superposition, a mid-collapse of seed 7 at step 40, the contradiction fixture, and the finished seed-7 map. - One command runs adjacency, seed, retry, and writes the frames. No network. Accept when: the command passes for both shipped tilesets (rooms has its own seed-7 file). ### R4. Inputs - The build reads `spekkr.inputs.json`. Settings label the UI, options turn features on or off, and a swap must be one of its choices. - A value outside a stated range, or a swap that is not one of its choices, is refused before the app starts its checks, with a message that names the key. Accept when: the default inputs render, an illegal swap is refused by name, and changing a visible setting (for example the title) shows up in a later check. ## Verification A seeded run is deterministic and uses only allowed adjacencies, checked on every edge of the finished grid. A contradiction fixture retries the documented number of times and then reports failure. A golden map is compared, and the tile-id grid is compared exactly. No network. ## Definition of done - Every acceptance check above runs from one command, and all pass at the person's inputs. - A README says how to collapse a map, how to add a tileset, and how to run the checks.