What it does
A nonogram is a picture hidden in a grid, with a run-length clue for each row and column. The pack solves a line
exactly, for any length, with a dynamic programme over its clue: it never lists arrangements and never marks a cell
that is not forced. The hint, solveStep, marks the forced cells of the first line that has any. The generator draws
random pictures and keeps the first that line logic alone can finish, and its lineSolvable flag tells you honestly
whether it found one, so a guess-free puzzle is something you can check rather than assume.
The light-toggling puzzle, in the style of Lights Out, toggles a cell and its neighbours on every press. Pressing is addition in a two-value arithmetic, where twice is nothing and order does not matter, so Gaussian elimination computes the exact set of presses that turns everything off. Every board the pack makes is solvable, because it is scrambled from all off, and when there are several answers the hint returns one with the fewest presses.
The colour flood, in the style of Flood-It, grows a region from an origin cell as the player picks colours, until
it covers the board within a move limit. preview says exactly how many cells a colour would add now, and the hint is
the colour that absorbs the most. The default move limit is set from greedy play, so the board can always be won
within it.
Features
- Exact nonogram lines — a dynamic programme over each clue finds the forced cells, in time proportional to cells times blocks.
- Honest generation —
lineSolvablereports whether line logic alone finishes the picture. - Your own pictures — pass a
solutionof booleans instead of generating one. - Clue checks —
lineSatisfiedsays when a row or column reads as its clue, to dim a finished clue. - Exact toggle solutions —
solution()gives the presses that clear the board, each cell at most once. - Fewest presses — chosen among several answers, for every square cross board up to 20 by 20.
- Toggle stamps — a cross, a 3×3 square or your own offsets, with optional wrapping round the edges.
- Flood previews and hints —
previewfor any colour's exact gain, andfindMovesranks every colour. - Seeded and headless — every board is deterministic from its seed and draws nothing itself.
Good for
- Picture-logic puzzle books, nonograms in the style of Picross or Griddlers, with a hint that only marks what is certain.
- Light-toggling puzzles, in the style of Lights Out, including variants with square or custom stamps and wrapped boards.
- Colour-flood puzzles in the style of Flood-It or Color Flood, with a move limit and a greedy hint.
- Daily puzzles and puzzle collections, where a seed reproduces each board.
- Teaching logic, where a hint must be a deduction the player could have made.
Make it yours
Each puzzle takes its own small config. Every board has a grid size and a seed. A nonogram adds a fill density for its generator, or your own picture. A toggle board adds its stamp, whether it wraps, and how many random presses scramble it. A flood adds the number of colours, a move limit and the cell it grows from.
Two different uses of the same pack: a fifteen-by-fifteen nonogram generated at a high density and checked with
lineSolvable, with solveStep behind a hint button; and a wrapped toggle board with a 3×3 stamp, where the hint
shows the exact presses that finish it. A flood on a fourteen-by-fourteen board with six colours, grown from a corner,
is a third game again.
A quick look
A generated nonogram, checked, marked and hinted:
const pic = game.deduce.createNonogram({ cols: 15, rows: 15, seed: 4, density: 0.6 });
if (!pic.lineSolvable) { /* this picture needs guessing: try another seed or density */ }
drawClues(pic.rowClues, pic.colClues);
pic.set(2, 5, 'fill'); // 'fill', 'cross' or 'unknown'
const hint = pic.solveStep(); // one line's forced cells, now marked
if (pic.solved) win();
Works with
reveal— for hidden-cell deduction games where a hint must also be certain.netflow— for grids that light up through connections, such as pipe and network puzzles.
Good to know
- A generated nonogram never needs the cross-referencing or guessing hard hand-made puzzles use, which caps its difficulty. Large or sparse boards often fail to be line-solvable within the generator's 40 tries; check the flag and try another seed or density.
- The nonogram hint treats the player's marks as known, so a wrong mark can mislead it.
- The flood has no optimal solver: its hint and its default limit both come from greedy play.
- None of the three has undo; keep your own list of moves, or rebuild a board from its seed.






