What it does
createWordSearch hides each word in a straight line across a grid of letters, longest words first. It chooses a
direction first, evenly among those with room, then a place in it, preferring places where the word crosses another,
so a crowded grid of long words does not end up with every word in a row. A word that does not fit is left out and
named, rather than failing the puzzle. The free cells take a hidden message, if you give one, and then filler letters,
by default drawn from the hidden words' own letters so the filler looks like the words. Any word the filler spells a
second time by chance has its filler changed, so every word is in the grid exactly once.
Finding is the other half. snap keeps a drag on the nearest of the eight directions, inside the grid; spell says
what a line reads for a preview; select accepts a line that covers an unfound word exactly, from either end, and
refuses anything else with a reason. Found words carry their placement, so a game can draw its highlight; unfound ones
never say where they are.
Words can be given as they should be listed: "Tyrannosaurus Rex" is hidden as TYRANNOSAURUSREX and listed as written. Every puzzle is a seed and a list of moves on the kernel history, so undo, hints, reveals and saves come with it.
Features
- Seeded generation — the same words and seed always make the same puzzle.
- Themed or random — a fixed list of words, or
countwords drawn from apoolsuch as a dictionary. - Direction presets — easy (right and down), medium (adding two diagonals) and hard (all eight), or your own list.
- Crossing words — words share letters where they cross, which packs the grid; or keep them apart.
- Filler letters — the words' own letters, a to z evenly, a set of letters or weights of your own.
- No accidental duplicates — filler that spells a word again is changed.
- Shaped grids — a mask of rows makes a heart, a diamond or a letter.
- Hidden messages — the leftover cells spell a message in reading order.
- Drag helpers —
snap,lineBetweenandspellfor the drag,selectfor the judgement. - Hints, reveals, undo and saves — a word's first cell, a word shown as found, and the kernel history.
Good for
- Themed puzzles for a museum, a lesson or a holiday, the same every time.
- A new puzzle every game, from the english-words lexicon or any big list.
- Young players, with easy right-and-down puzzles in a small grid.
- Puzzle books and daily puzzles, where a seed reproduces each grid.
- Shaped and message puzzles, a heart for a card or a message as the reward.
Make it yours
A puzzle takes its width and height (or a mask), its words or a pool with a count and lengths, its
directions, whether words overlap, its fill and an optional message. The pack draws nothing, so the grid,
highlights and word list are your own.
Two different puzzles from the same pack: a fixed fifteen-by-fifteen dinosaur puzzle on medium directions, the same for every player; and a new ten-by-ten puzzle every round, fourteen words drawn from the dictionary and hidden in all eight directions, with letters filled evenly from A to Z. A third is a heart-shaped puzzle whose leftover letters spell a message.
A quick look
A themed puzzle and a drag:
const puzzle = createWordSearch({ seed: 7, width: 15, height: 15, words: ['Stegosaurus', 'T. Rex', 'Triceratops'] });
const view = puzzle.observation(); // rows of letters, the words to find, progress
const end = puzzle.snap(start, pointerCell); // keep a drag on one of the eight directions
puzzle.spell(start, end); // what the drag spells, for a preview
puzzle.select(start, end); // { ok: true, result } when it covers a word, either way round
Works with
letter-tiles— draws the grid, keeps a drag on a straight line and keeps each found word highlighted.english-words— optional: its search results make the pool for a random puzzle.typography— for the letters and the word list.letter-grid— when words should be traced through touching letters rather than straight lines.
Good to know
- It is the rules only: the game draws the grid and turns pointer positions into cells.
- Letters are a to z; words with other characters are refused.
- An over-full grid leaves words out rather than fail; check
unplacedfor a fixed list. - Filler can spell other words by chance; only the listed words are checked.
- A hidden message fills the free cells in order, and filler follows it when there are more cells than letters.






