Friday 28 January 2022

Wordle strategy

Wordle is a popular word game similar to mastermind.
If you do not know how to play, the linked website explains it better than I can.

The naive tactic is to guess a random word that you think might be the solution. This tactic might work, and as this game is very luck-based, an optimal tactic will not necessarily do better.

But in practice, this tactic does not bode very well. In essence, the program has the information. You, as a player, are trying to get the information. There is no point in confirming the information you already know to be true.

For example, imagine you picked as the first word “pound”, and the game returned that “o”, “u”, “n”, and “d” are correct. Furthermore, “p” is absent. There are multiple different words you might pick next, like “found”, “sound”, “round”, or “wound”. But if we are unlucky, we will need four guesses. A better guess would be “safer”. We can immediately distinguish between the different words depending on the letter that lights up.

To refine this tactic, we will need to quantify our notion of information. One can easily see that if only a single possible word could be the solution, information is very high. Similarly, if the solution can be any word, information is low. Therefore a good measure for the entropy would be the number of possible words.

This means that we will search the word to guess such that the worst-case entropy is minimal. This means that we partition the set of possible words into subsets for each word depending on the feedback we would get if this word were the solution. We take the size of the most significant subset, and we minimise that. We can keep doing this in a loop.

All the possible guesses can be precalculated, and the solution you can find here:

or in fullscreen view: here