Wordle and Information Entropy


Wordle and Information Entropy

Maria
Wordle looks like a simple word game, but it’s also a great way to explore information theory. The goal is to guess a hidden five-letter word in six tries. After each guess, the colors tell you what you learned: gray means a letter isn’t in the answer, yellow means it is but in another position, and green means it’s correct and in the correct position.

Hope
So each guess isn’t just a shot at the answer. It’s also an experiment that gives you clues. And the question for a Wordle-solving algorithm is: which guess is likely to teach us the most?

Maria
Exactly. In one example, the bot starts with “crane.” The feedback is gray, yellow, green, gray, gray: no C, N, or E; an R somewhere other than its guessed position; and an A in the third position. The bot then suggests “shtik.” That guess reveals S and H, narrowing the answer to either “shard” or “sharp.” It chooses “shard,” which is right, so the puzzle is solved in three guesses.

Hope
And three is a strong result. A useful analogy is that four is par and three is a birdie: getting four is a solid, realistic performance, while getting three feels especially satisfying.

Maria
To build a bot, one tempting approach is to look at common letters and make guesses that cover many of them. One proposed opening pair is “other” followed by “nails.” Hitting a letter feels useful, but even all-gray feedback can be valuable because it rules out words containing those letters.

Hope
But letter frequency alone doesn’t settle the question. It doesn’t account for where the letters appear, so it doesn’t tell us whether “nails” is better than “snail.” And a word like “weary,” with less common W and Y, might still be a good guess if its feedback can sharply narrow the possibilities.

Maria
There’s another important detail: Wordle has about 13,000 valid guesses, including many obscure words, but its answer list is much smaller—around 2,300 words—and consists of more familiar choices. The project here deliberately avoids building in that answer list. That makes the bot less dependent on one particular game and avoids using a list that can reveal the official answers in their scheduled order.

Hope
Instead, we want a general model that prefers words likely to be answers, using word-frequency information. But before adding that preference, let’s temporarily pretend all 13,000 possibilities are equally likely. That gives us a clean first version of the math.

Maria
Consider guessing “weary.” Some feedback patterns leave very few matching words. For instance, one particular pattern leaves only 58 matches in the whole lexicon. That sounds wonderfully informative—but if all words are equally likely, the chance of seeing that pattern is only 58 out of about 13,000.

Hope
So that exciting pattern is also unlikely. A more common pattern might leave around 1,400 matching words, which is about an 11 percent chance under the equal-probability assumption. The key idea is that informative outcomes tend to be rare: when an observation is unlikely, it rules out more of the possibilities.

Maria
For a guess, there can be as many as three to the fifth possible color patterns, since each of the five letters can be gray, yellow, or green. Each pattern has a probability, and each tells us something. To score a guess overall, we need to consider not just its best possible pattern, but the expected information across all its patterns.

Hope
Let’s define information in bits. If an observation cuts the possibilities in half, that’s one bit. If it cuts them to one quarter, that’s two bits; one eighth is three bits. In general, if an event has probability p, its information is log base two of one over p, or equivalently negative log base two of p.

Maria
That logarithm is a way of counting how many halvings an observation represents. It’s also useful because information adds: an observation worth two bits followed by one worth three bits gives five bits total. The corresponding probability reductions multiply, while their information values add.

Hope
Entropy is the expected information: for every possible pattern, multiply its probability by the information it gives, then add those products. For “weary,” that average is about 4.9 bits under the initial equal-likelihood model. For “slate,” it’s about 5.8 bits, so “slate” is expected to reduce the possibilities more.

Maria
That’s the sense in which entropy measures the quality of a guess: higher expected information means a stronger reduction in uncertainty on average. There’s a famous story that John von Neumann suggested the name “entropy” to Claude Shannon for this expected-information quantity. The name also appears in statistical mechanics, though for this lesson we can simply think of entropy as expected information.

Hope
Entropy also reflects how spread out a distribution is and how many outcomes are in play. If all three-to-the-fifth color patterns were equally likely, each would provide log base two of three-to-the-fifth, about 7.92 bits. That’s the maximum possible entropy for that set of patterns.

Maria
And if there are 16 equally likely outcomes, the entropy is four bits; with 64 equally likely outcomes, it’s six bits. So an entropy of six bits represents as much uncertainty as 64 equally likely possibilities, even if the actual distribution has a different shape.

Hope
The first bot version searches all 13,000 valid guesses, calculates the pattern distribution for each one, and picks the guess with the highest entropy. After the feedback, it repeats the process using only the words that still match. So the same strategy is applied to the smaller set after every turn.

Maria
In an illustrative run, it suggests “tares” as the opener. The display can show both expected information before the guess and the actual information provided by the feedback afterward. It also shows the remaining candidates and their uncertainty. When all candidates are treated equally, that entropy is just another way of expressing how many candidates remain.

Hope
For example, if there are about 13,000 equally likely possibilities, the entropy is about log base two of 13,000. That can feel like a complicated way to count, but it becomes useful once the candidates no longer have equal probabilities.

Maria
In one demonstration, the bot suggests “Raman,” but the player chooses “Rains.” The result leaves 55 possibilities. Later, a guess called “combo” produces 4.7 bits of information when the prior uncertainty was 5.78 bits. That leaves about one bit of uncertainty—roughly the equivalent of two equally likely answers.

Hope
That example points to a weakness in version one. If the candidates are “abyss” and another word, but the bot considers them equally likely, it may not choose the more plausible answer intelligently. It keeps seeking information until only one candidate remains, rather than using word commonness to guide the endgame.

Maria
When this first version is tested against all 2,315 official possible answers, its average score is about 4.124 guesses. That’s not bad, but there’s room to improve—especially if we want more games solved in three.

Hope
The next step is to give words different probabilities. The approach described uses word-frequency data from Mathematica, which draws on the public Google Books English Ngram dataset. The data can rank five-letter words by how commonly they appear.

Maria
But raw frequency shouldn’t directly become the probability of being a Wordle answer. A very common word might be a thousand times more frequent than “braid,” yet both could be plausible answers. So the model uses a sigmoid function on the sorted word list: its values move smoothly from near one for words above a chosen cutoff to near zero for words below it.

Hope
The cutoff and the width of that transition are choices, and the example’s author describes setting them informally by looking for a range where roughly half the words seemed more likely than not to be answers. The result is a prior probability for each word, rather than a claim that frequency alone determines the answer.

Maria
Unequal probabilities change how we should understand uncertainty. Suppose four candidates are equally likely. Each has probability one quarter, so learning which one is correct gives two bits of information, and the entropy is two bits.

Hope
Now suppose there are actually 16 matching words, but 12 of them are obscure and each has only a tiny chance—about one in a thousand in the example—of being the answer. The entropy is about 2.11 bits, not four. The unlikely candidates add a little uncertainty, but they don’t make the situation feel like 16 equally plausible choices.

Maria
That’s why entropy is useful in two related ways. We can calculate the expected information from a proposed guess, using the probabilities of its possible feedback patterns. And we can calculate the remaining uncertainty across the candidate answers, using their individual probabilities.

Hope
Those two calculations need to use the same probability model. A feedback pattern with many matching words can still be quite informative if most of those words are extremely unlikely answers. Conversely, a pattern with fewer matches can leave substantial uncertainty if its candidates include plausible answers.

Maria
The second bot version uses those non-uniform probabilities when it scores feedback patterns, and it keeps track of how likely each remaining word is to be the answer. Its uncertainty measure is no longer just a disguised candidate count. For instance, 526 matching words might correspond to about 8.02 bits of uncertainty—equivalent to roughly 259 equally likely outcomes—because many of those 526 words are assigned very little probability.

Hope
There’s another improvement in the decision strategy. Near the end, the bot may stop choosing the guess with the highest information value. If only seven words technically remain but the meaningful probabilities are concentrated on “dorms” and “words,” it can be better to guess one of those directly than to use a different word that separates the candidates more neatly.

Maria
To formalize that, the bot estimates expected final score. If guessing “words” has a 58 percent chance of being correct, then there’s a 58 percent chance the game ends on that guess. If it’s wrong, the game continues, and the bot estimates how many guesses that continuation may take from the uncertainty left afterward.

Hope
The estimate uses a fitted function relating remaining entropy to the number of additional guesses. The function is trained from outcomes of the first bot’s simulated games. For example, at zero bits of uncertainty there’s only one possibility, so one guess is required. At one bit—about two equally likely possibilities—the average number of further guesses in the collected data was about one and a half.

Maria
The uncertainty remaining after a proposed guess can be estimated by subtracting that guess’s expected information from the current uncertainty. The bot then uses the fitted relationship to estimate the continuation score, combines that with the chance the guess is already correct, and compares its expected score with the alternatives.

Hope
This version averages around 3.6 guesses in simulations over the 2,315 official answers, improving on version one. It does sometimes lose by needing more than six guesses, presumably because its strategy sometimes trades the maximum information for a better chance of reaching the answer.

Maria
Using the official answer list itself can improve the average further: the best result described is around 3.43. That version also searches two guesses ahead rather than optimizing only the next guess, though the example’s broader goal is to avoid relying on the official answer list.

Hope
The two-step search gives a useful limit on what’s possible. With the official answer list, the starting uncertainty is a little over 11 bits, while a brute-force search finds that the maximum expected information over the first two guesses is around 10 bits. So even with excellent play, the best case leaves about one bit of uncertainty after two guesses—roughly two possible answers.

Maria
That helps explain why guaranteeing a solution in three guesses for every answer is out of reach under this analysis: there isn’t enough information available in two guesses to guarantee that every game is reduced to one answer. In sample searches, “crane” emerges as the best opener for the author, which is a nice reminder that a familiar-looking guess can still be mathematically strong.

Hope
So the big lesson is that information isn’t simply about getting green tiles or making the candidate list as small as possible in the luckiest case. It’s about the probability of each possible observation, how much that observation changes what you know, and how likely the remaining answers are. Entropy gives us a common mathematical language for choosing guesses and measuring uncertainty.

Ask anything
We've read this whole study set, so questions about it get the best answers.