Wordle!
It’s the hottest new trend, which means it’s time for YouTubers like me to cash
in on its popularity by making videos about it.
In fact, it’s gotten so popular that even my family are texting me their daily Wordle
results.
But when I called my Dad recently and we got talking about Wordle, he actually had the
AUDACITY to suggest that his strategy is better than mine!
Obviously there was only one reasonable way for me to respond – make a Wordle playing
bot that tests both of our strategies to scientifically prove that I’m right, and then use the same
bot to destroy my Dad at Wordle!
Just in case you haven’t hopped on the Wordle bandwagon yet, here’s a 10 second explanation
of what it is.
You have six tries to guess a five letter word, and with each guess the game gives you
feedback on how many letters you guessed right, and how many letters you guessed right but
in the wrong position.
Basically, it’s that old board game mastermind with words instead of coloured pins, and since
you don’t need a buddy to give you feedback, even a friendless loser like you can play.
Oh, and one more thing – you can only play once per day, and everyone in the world has
the same daily word.
That creates a bit of a problem, because to definitively prove myself right, I need to
test this bot of mine against all 2315 possible Wordle solutions.
But since the official wordle website only lets you play once per day, and I don’t
plan on taking over six years to make this video , I’ll need to make my own version
of Wordle that I can play as many times as I want.
I think it’s time for a coding montage.
And to any programmers who may be watching this video: I am fully aware of how terrible
this code is so no need to let me know in the comments.
Ok, a couple hours of coding and bug squashing later and I have a very janky version of Wordle
that I can play in the windows terminal.
Now I just need to code this bot of mine, which means I should probably explain the
two opposing strategies I’ll be testing.
My strategy is, after my first guess, to always use all the letters I get correct in my next
word.
So if I guessed the word HOIST and got this (-!-~~) as my feedback, I might guess TORUS
as my next word because this incorporates the feedback I received into my next guess.
My reasoning here is that this strategy means my next guess always has a chance of being
the correct answer and that therefore it’ll lead me to the solution the fastest.
On the other hand, my Dad’s strategy is not to reuse any letters from his first guess
in his second guess, even if he got some of the letters right.
So if he guessed HOIST and got the same feedback as before, his second guess might be something
like BLADE.
His reasoning is that by trying more letters he gets more information about what is and
isn’t in the final word, and that this will help in out in the long run.
To create a bot that tests both of these strategies, I’ll need a word picking algorithm that
can make guesses based on the feedback the game gives.
The way this algorithm works is, based on the feedback it receives and the strategy
it’s using , it’ll generate a list of valid guesses . So for example, if the first
guess was OLIVE and the bot got this feedback (----~), then for my strategy the bot would
generate a list of words that contains an E but not in the 5th position, and without
the letters O, L, I, and V. For my dad’s strategy, the bot would just generate a list
of words without any of those letters.
Next, the algorithm tries to find the best possible guess out of the valid word list
by looking at how frequently each letter appears in each position . The algorithm scores each
word based on the positional frequency of its letters and then picks the word with the
highest score as its guess.
So for example, if a lot of words in the list start with a B, then the algorithm is likely
to guess a word starting with a B. I’m glossing over the details of exactly how the algorithm
scores each word because it’s kind of boring, but here’s a breakdown of how it would work
on this short, 5 word long list.
So if you’re a giant nerd, like me, then you can pause the video and take a closer
look to see all the details.
If you apply this scoring algorithm to every possible Wordle solution then you’ll find
that the best starting guess is… drumroll please…
SLATE . Now, I’ve seen a lot of people online say that ARISE is the best word to start with,
so let me just say that it is very possible that there are smarter algorithms out there
than mine, but I’m going to stick with the one I’ve got for this experiment.
Now, if you apply my algorithm on the list of words that doesn’t contain S, L, A, T,
or E , you’ll find that the best second guess for my dad’s strategy is CRONY.
So for the bot simulating my Dad’s strategy it’ll always start with the guesses SLATE
and CRONY, and then proceed from there.
There is one more little feature to add to these bots.
See, there are some groups of very similar words like BOUND, FOUND, SOUND, MOUND, HOUND,
WOUND, and POUND that can be tricky to solve.
To avoid losing in situations like this, I made the algorithm smart enough to recognize
when it gets in situations like this, and then guess a word like WHOMP to find the solution.
Ok, so now that I’ve coded the bots and squashed the many, many bugs, it’s time
to test them against the entire Wordle solution list!
In one corner we have the Professor Goose Bot, in the other, the Father Goose Bot.
And the results are in!
Professor Goose Bot solves the Wordle in an average of 3.66 guesses, while Father Goose
Bot takes an average of 3.71 guesses.
Professor Goose Bot wins!!!!
But all joking aside, I was surprised at how close both bots were.
Here’s the full breakdown of the results and you can see that the dad bot was a little
more consistent at solving the Wordle in only 3 or 4 guesses, while my bot’s greater probability
of solving the Wordle in only two guesses helped bring it’s average down.
And I know, my bot did lose 5 matches compared to dad bot’s 1 loss, but I still think a
99.8% win rate is pretty good, ok!
But the true test of my Wordle bot is to use it on the actual Wordle game to beat my dad.
Alright here goes nothing.
Wow it took the bot 5 guesses, pretty tough word.
I bet my Dad couldn’t even solve that o… what!?
Well, clearly that was just a lucky guess.
Tomorrow I’ll win for sure.
One day later…
FFFFFF *HONK* HMMMMMM
You know, you should really watch this video next.
Seriously, I promise it’s a good video, you won’t regret it.