How the ranking works
Ranking guesses with information theory
In a five- or six-letter word puzzle, every guess is a question and its colours are the answer. Claude Shannon's information theory measures how much an answer can tell you, in bits. Guess Grid ranks every guess it could suggest by that measure. Here is the maths, where it falls short, and what happened when it was played against the obvious alternative over every answer in its list.
- A guess partitions the possible answers
- Measuring a partition in bits
- Try it
- The best openings
- Three ways to score a split
- Greedy, not optimal
- A small bonus for words that could win
- The word list matters
- Making it fast enough for a phone
1. A guess partitions the possible answers
Take a puzzle down to six possible answers that differ only in their first letter:
- BATCHCATCHHATCHLATCHMATCHPATCH
Guess WATCH and every one of the six shows the same colours:
Whatever the answer is, you're left with all six. One group, nothing learned, a wasted turn.
Now guess BLIMP, which can't be the answer but tests four of the first letters at once. Each answer shows a different pattern, except for two:
Five groups. Four of them hold a single word, so four times out of six you know the answer for certain.
In general, the colours are a function of the guess and the answer. Fix the guess, and that function sorts the remaining answers into groups, one per colour pattern: a partition. Five letters have 35 = 243 possible patterns, of which 238 can occur (four greens and one amber is impossible); six letters have 36 = 729. Repeated letters are coloured the way puzzles colour them: greens first, then ambers from left to right, one per matching letter in the answer.
This is the whole idea: you end up holding exactly one group, you don't know in advance which, and a guess is good when its groups are many and small.
2. Measuring a partition in bits
If N answers are equally likely, not knowing which is right is worth log2 N bits of uncertainty. One bit is one yes-or-no question: six equally likely answers hold log2 6 ≈ 2.585 bits.
A guess that splits them into groups of sizes n1, n2, … leaves you in group i with probability ni / N, still holding log2 ni bits. What the guess removes on average is its expected information gain:
bits = log2 N − Σ (ni / N) log2 ni
= − Σ (ni / N) log2(ni / N)
The second line is the Shannon entropy of the colour pattern. The two lines are equal because the colours are completely determined by the answer: the mutual information between the answer and the colours is just the entropy of the colours. So "how much will this guess teach me?" becomes "how unpredictable are its colours?"
WATCH, with a single group, scores 0 bits. BLIMP scores 2.25 of the possible 2.585, which only a guess putting every word in its own group would reach. The measure rewards two things at once: more groups, and more even ones.
It's the same criterion ID3 uses to choose each split when it builds a decision tree, and the analogy is exact. A game is a path down a decision tree whose branches are colour patterns, and at every node Guess Grid asks the question with the highest information gain.
One assumption sits under all of this: every remaining answer is equally likely. Guess Grid's answer lists are curated to common words and don't weight one above another. A solver with a better prior, word frequencies for example, would use the same formula with unequal probabilities.
3. Try it
A real position. The first guess was SLATE: A and E are in place, S, L and T aren't in the word, and 26 answers remain, log2 26 ≈ 4.70 bits of uncertainty. Type any five letters to see how they partition the 26 and how many bits that's worth, beside the solver's own pick.
Show the 26 words
- ADAGEAMAZEAWAKEAWAREBRACEBRAKEBRAVECHAFECRANECRAVECRAZEDRAKEDRAPEEVADEFRAMEGRACEGRADEGRAPEGRAVEGRAZEHEAVEIMAGEINANEPEACEQUAKEWEAVE
It runs entirely in your browser, on just these 26 words, with the same scoring as the app. Any five letters are allowed, so you'll find strings that split the 26 better than BRICK. The solver only suggests familiar words; a puzzle won't accept most of the strings that beat it.
In the app, the info button beside the suggestions shows the same thing for your own puzzle, on every turn: each suggestion's groups, and why it ranks where it does.
4. The best openings
At the start, a guess faces every possible answer. Here is how three openings partition them. Each segment is one group, largest first; groups too small to draw are shown as a striped tail.
| Opening | Groups | Largest group | Bits | Avg words left | Rank by bits | Rank by avg |
|---|---|---|---|---|---|---|
| SLATE | 151 | 226 | 5.859 | 72.7 | 2nd | 14th |
| RAISE | 131 | 170 | 5.865 | 61.6 | 1st | 1st |
| CRIME | 115 | 338 | 5.221 | 117.6 | — | — |
Ranks are among every word the solver can play as a guess. "Avg words left" is how many words you'd have left on average after the guess. Rank by bits includes the small bonus for words that could win, described in section 7; all three of these could.
SLATE and RAISE are 0.006 bits apart, a statistical tie, with RAISE just ahead. SLATE makes more groups; RAISE keeps its largest group smaller. CRIME is a reasonable guess, better than 93% of words, but its largest group holds 338 words, and that is where it loses.
5. Three ways to score a split
Bits aren't the only way to score a partition. Two others come up often, and all three belong to one family, the Rényi entropies. With pi = ni / N, the entropy of order α is:
Hα = 1/(1 − α) × log2 Σ piα
| Rank guesses by | Equivalent to maximising | Order |
|---|---|---|
| Expected information (Guess Grid) | Shannon entropy, −Σ pi log2 pi | α → 1 |
| Fewest words left on average | Collision entropy, −log2 Σ pi2, since the average is N Σ pi2 | α = 2 |
| Smallest worst case | Min-entropy, −log2 max pi, since the largest group is N max pi | α = ∞ |
The last is the rule Donald Knuth used for Mastermind in 1977: choose the guess whose worst outcome leaves the fewest possibilities. The higher the order, the more the score is dominated by the largest groups, and that is where SLATE and RAISE part. RAISE keeps its biggest group smaller, 170 words against 226, so it wins clearly at order 2. SLATE breaks the field into more groups, 151 against 131, which almost makes up for that at order 1, where RAISE leads by only 0.006 bits.
None of these measures looks past the next guess, so which one plays better over a whole game can't be settled by argument. Guess Grid's solver was played against every answer in its lists, ranking by bits and then by fewest words left, always taking its own top suggestion:
| Ranking by | Opening | Avg guesses | Most guesses |
|---|---|---|---|
| Five letters, every answer in the list | |||
| Bits (as shipped) | SLATE | 3.456 | 6 |
| Bits, with its own top opening | RAISE | 3.498 | 6 |
| Fewest words left | RAISE | 3.509 | 6 |
| Six letters, every answer in the list | |||
| Bits (as shipped) | SALTER | 3.114 | 5 |
| Bits, with its own top opening | SATIRE | 3.123 | 5 |
| Fewest words left | SATIRE | 3.129 | 5 |
Bits solved faster on average at both lengths, and no ranking did better in the worst case: six guesses at most at five letters, five at six. Guess Grid optimises the average, the way you'd judge a solver over many puzzles. The worst-case rule wasn't played.
Why the difference? The average squares each group's size, so a few large groups dominate it. Shannon entropy weighs every group by its share of the words, which rewards breaking up all of them, including the many small ones.
6. Greedy, not optimal
Taking the most informative guess each turn is a greedy policy with one step of lookahead. The truly optimal strategy, the one with the fewest guesses on average, comes from searching the whole game tree: every guess, every colour pattern, every follow-up, to the end of every game. That search is enormous, and its answer is specific to one word list. The greedy policy needs only the current position and runs in a fraction of a second.
Greed has a cost. The most informative guess isn't guaranteed to be the one that ends games soonest, which is why the comparisons above were made by playing whole games. The opening shortcut in section 9 is another example: a cruder measure that happens to play better at both lengths.
7. A small bonus for words that could win
Information alone can't see winning. A guess that could itself be the answer might end the game on the spot; a probe that splits the field just as well can't. Entropy counts that outcome as just another group of one, and doesn't know it ends the game a turn early.
So a word that is still possible gets a bonus of 0.15 bits on top of its score. It's enough to break near-ties in favour of a word that could win, and too small to prefer a possible answer that splits the field badly. You can see it in the position above: CRAVE is worth 3.04 bits, less than CRIMP, CRUDE and CRUMB at 3.17, but it could be the answer, so with the bonus it ranks second, behind BRICK.
Once only one or two words are left, the solver stops probing and plays one of them.
8. The word list matters
A ranking is only as good as the list of words it assumes could be the answer. Change the list and the order can change, even though nothing else has.
Take SLATE coming back all red, which leaves 226 words. On Guess Grid's answer list, the top two next guesses are CRONY and ROUND, and they come out almost level:
| Guess | Groups | Largest group | Bits | Avg words left |
|---|---|---|---|---|
| CRONY | 69 | 24 | 5.507 | 7.35 |
| ROUND | 72 | 18 | 5.494 | 7.27 |
CRONY leads by 0.013 bits, inside the solver's tie margin of 0.02, so the app calls them all but tied, and a practice review grades either as the best available. ROUND makes more groups, and leaves fewer words on average and fewer at worst. Both could be the answer, so both get the bonus from section 7; on bits alone, PRION, which can't be the answer, falls between them at 5.501.
Guess Grid's own list shows how easily that order moves. Before version 1.6 added more everyday words as possible answers, the same position left 209 words, and ROUND led CRONY by 0.007 bits. Score it against a broader list still, one that counts rarer words as possible answers too, and CRONY leads by 0.09 bits. The words a list adds happen to decide which of two near-equal guesses comes first.
Guess Grid's answer list is chosen to match the kind of words these puzzles use, and on it CRONY now ranks first. If you'd rather play ROUND, you've lost nothing: at this position the two are as good as each other.
9. Making it fast enough for a phone
Ranking every guess means computing a colour pattern for every allowed guess against every remaining answer. On the opening turn that's millions of pattern computations, and the app does it on the device, with no server.
- Patterns as integers. Each pattern is encoded in base 3, so sorting answers into groups is a counter increment in a fixed array of 243 slots (729 for six letters) rather than a hash map.
- Flat memory. Every word's letters are copied once into contiguous byte buffers, so the inner loop reads memory directly.
- Every core. The guesses are split into chunks, several per CPU core, scored in parallel. Each chunk has its own counters and writes only its own results, so nothing is shared and nothing is locked.
That's fast enough from the second guess onwards. The opening turn, with every answer still possible, is still too slow to repeat each time you tap, so there Guess Grid takes a shortcut: it ranks the possible answers by how common their letters are among the words left, counting a letter in the right position double. The app says as much under the opening suggestions: "Sharper ranking kicks in once fewer words remain."
The shortcut does well. At five letters it picks SLATE, a statistical tie with the full calculation's RAISE; at six, SALTER over SATIRE. Both played better than the full calculation's pick: SLATE averaged 3.456 guesses against RAISE's 3.498, and SALTER 3.114 against SATIRE's 3.123. No one-turn measure predicts a whole game perfectly; this is where that shows.
For the same ideas applied to common questions, such as the best second guess after SLATE and how to beat word families, see the guides.