Hey, have you heard of Wordle yet? Stop lying – I know you have! And while it is a super fun game to play for humans, I wanted to let computers in on the action. In this video, I explain and implement a Wordle algorithm in Python which is ALWAYS able to find the secret word in 6 tries or fewer (4 tries on average).
I test the Wordle bot not only on the official wordle website () but on another website that lets you play many times a day ().
I even enter a Wordle Bot Competition and place in the top 10 ().
So what is the bot’s wordle strategy? Well, we consider every possible guessing word and every possible answer. Every guessing word yields us information (green for correct letter in correct location, yellow for correct letter in wrong location, and gray for incorrect letter). We choose a guess that helps us narrow down our answer list the most. Particularly, we choose the guess that guarantees the most narrowing down. I explain this algorithm in detail in the video.
After that, we get the list of all possible guess and answer words from this subreddit (). Then, it is just a matter of Python implementation.
The solution is 100% accurate and typically takes under 3 seconds to solve an entire puzzle. When I run it on the websites mentioned above, it is clear that it excels at its job!
Do you know how my wordle ai can be improved? Or at least sped up? Let me know in the comments and maybe we can crack top 5 in the botfights competition to be a true wordle hacker!
If you watched this video, you probably like code!
Here is the code for my wordle solver:
Chapters:
00:00 – Wordle Introduction
00:48 – High-level algorithm
04:47 – Algorithm Implementation
08:47 – Running algorithm
10:31 – BotFights Competition
11 Comments