How AnyTool Interlocks Words into a Criss-Cross Grid
Generation runs entirely in the browser from a list of word + clue pairs typed as "WORD: clue" (a colon, dash or tab separates the two). Each entry is sanitized — the word is uppercased and stripped to A–Z, words under two letters or with an empty clue are dropped, and duplicates are removed in first-seen order. The longest word is seeded across the centre of a generous working board, because long words are the hardest to interlock once the grid fills. Every remaining word is then tried at every crossing against an already-placed letter: the new word runs perpendicular to the word it crosses and a placement is legal only when each covered cell is empty or already holds the matching letter, the cells immediately before and after the word are blank (so two entries never merge into one long word), and any non-crossing cell has blank perpendicular neighbours (so the word never runs flush alongside another). Each legal placement is scored by the number of crossings first, then by how little it expands the bounding box, with an unbiased crypto tie-break (Web Crypto API, never Math.random). The engine repeats this for several randomly shuffled orderings and keeps the layout that places the most words in the most compact, squarest grid, then trims to the bounding box.
- Input is "WORD: clue" pairs; words sanitized to A–Z, uppercased, de-duplicated, blank-clue lines skipped
- Longest word seeded first; every later word must cross an already-placed letter (perpendicular)
- Adjacency rules forbid end-to-end merges and words running flush alongside each other
- Placements scored by crossings then compactness, with a Web Crypto tie-break (never Math.random)
- Several shuffled orderings are tried; the layout placing the most words most compactly is kept
