Possible Extension Ideas
There are many extensions you could add to the Wordle game. Here are a few that might be fun or spark an idea, but keep in mind that you can implement any extension you can imagine!
Create a more balanced dictionary. If you simply choose a word at random from the dictionary, some letters will appear more frequently than others in specific positions. Josh Wardle’s original implementation solved this problem by keeping two sets of words: a smaller one used to select the secret hidden word in which the letter frequencies are more balanced, and a larger one for determining whether a guess is legal. You could devise and implement a strategy to add this two-tiered dictionary without having to choose specific words by hand.
Make more balanced choices from the dictionary. There are other strategies you can use to improve the distribution of letters in the hidden words that don’t require creating a separate dictionary. For example, you could make a significant improvement simply by choosing fewer hidden words that end with the letter “s”, as almost 30% of the five-letter words do. To implement this strategy, you could define the constant
= 1 / 3 FINAL_S_FRACTION
and then use that constant to accept words ending in “s” only a third of the time, going back and choosing a different word the other two-thirds of the time.
Enhance the graphics when the user wins the game. The
set_square_color
method allows you to change the background color of a square to any color you choose, not just the predetermined constants. If you want to make victories more exciting, you could color or even animate (if you want to read ahead in the text) the squares so that the letters of the correct entry cycled through the colors of the rainbow before settling to be all green.Create an option that lists all possible words that are legal given the previous guesses. Even though doing so is clearly cheating, some players would like to see a list of all the words remaining in the dictionary that would be acceptable given the previous set of guesses. You can trigger this option by having the user hit the
RETURN
key or click theENTER
key when the line is not yet finished and filled with text, in which case some squares will contain the empty string. When this occurs, you can have your program go through all the words, check whether they conform to all the previous clues, and print those words to the console.Implement Wordle’s “hard mode”. In both the original implementation and the Times version, you can choose to play Wordle in “hard mode” by toggling a switch in the options. Upon doing so, you are no longer free to guess any valid five-letter word. Instead, each subsequent guess must incorporate any information you have gotten from previous guesses. So if you determine on your first guess that an
R
is the first letter and that anE
is present but not the fourth letter, then your next guess must reflect that information: having theR
still in the first position and theE
in either the second, third, or fifth positions.Keep score in a file. The New York Times Wordle site keeps track of the number of games you’ve played and presents a graph of the number of guesses you needed. To implement this feature, you would need to maintain a file that kept track of this information from game to game and then display it at the end. Although you could print this information to the console, you could also display the counts in the Wordle grid, so that each row shows the number of times you needed that many guesses. Thus, if you had solved four Wordle games in three guesses, eleven in four guesses, and six in five guesses, your Wordle program might show the following display at the end: