What it does
createHangman picks an answer from a seed, from the english-words lexicon within a range of lengths or from a list
of your own, or takes one you set. A list may hold phrases: spaces, hyphens and other characters that are not letters
show from the start and are never guessed, and accents are taken off, so "jack-in-the-box" and "café" just work.
Each guess is checked first, and refused with a reason a player can be shown: not a letter, guessed already, the game over. A right letter uncovers every place it appears, and the result says which, so a game can turn just those tiles over. A wrong letter costs a life; a wrong whole-answer guess costs what you choose. Hints show the hidden letter that uncovers the most places, for a price, and never spend the last life.
The advice is a candidate list: every answer in the word source with the same shape that agrees with every letter
shown and missed. suggest picks the letter most of them hold, which makes a fair hint button and a solver that wins
nearly every long word with six lives. A game is a seed and a list of guesses on the kernel history, so undo, saves
and replays come with it.
Features
- Seeded or set answers — a daily word from a seed, or a puzzle you wrote.
- Words or phrases — the English lexicon by length, or themed lists with spaces and punctuation shown.
- Exact reveals — a hit uncovers every place its letter appears, and the result lists them.
- Lives your way — any number, or
Infinityfor a game with no gallows. - Letters given — each word's first letter, its first and last, or every vowel.
- Whole-answer guesses — on or off, with the lives a wrong one costs.
- Hints at a price — the letter that uncovers most, for
hintCostlives, or free. - A keyboard — every letter marked hit, miss or unused.
- Advice and a solver — the candidates left, the best next letter, and
autoStepto play it. - Undo, saves and replays — a seed and a list of moves on the kernel history.
Good for
- The classic game, a 5 to 9 letter word and six lives.
- Spelling and vocabulary practice, short words with the vowels given.
- Quiz games, themed phrases such as animals, films or places.
- Party and family games, no lives and free hints.
- Daily puzzles, one seed for every player.
Make it yours
A game takes its words (a WordList or an array of words and phrases), min and max letters, a set answer,
lives, a reveal, wordGuess with its wordPenalty, and a hintCost. The pack draws nothing, so the gallows,
tiles and keyboard are yours.
Two different games from the same pack: short three and four letter words with four lives and no help, a quick challenge; and a quiz of animal phrases with the first and last letter of each word shown and no limit on lives. A third gives the vowels and free hints, for a child learning to spell.
A quick look
A game, a guess and the advice:
const game = createHangman({ seed, lives: 6 });
game.letter('e'); // a hit uncovers every E
game.word('kettle'); // or guess the whole answer
const view = game.observation(); // slots, hits, misses, lives left, keyboard, phase
game.suggest(); // the best next letter
Works with
english-words— required: the default answers, and the lists for themed games.letter-tiles— draws the answer as tiles that turn over and the keyboard as tap tiles.word-guess— for guessing a whole word at a time, each letter marked in place.
Good to know
- It is the rules only: no gallows, tiles or keyboard.
- Letters are a to z; any other character is shown, never guessed.
- The English lexicon includes some uncommon words; a themed list keeps answers familiar.
- The advice knows only the answers in its word source, and is good rather than perfect.






