After building a bot that can automatically play Wordle+ (an infinite Wordle website) thousands of times, I decided to create one that can play the daily New York Times Wordle and record its results on a live dashboard.
If you’re interested, check out the original article about beating Wordle+
What is it?
Every day, my Wordlebot uses the Selenium python library to access the New York Times Wordle website and solves them using an algorithm I wrote. After that, it logs the data and displays existing data on a dashboard built with Google Sheets.
How does it work?
Web interface
Wordlebot uses Selenium to interact with the New York Times Wordle website, allowing it to read the current game state, as well as simulating inputs so that it can “play”.
Algorithm
- Wordlebot assigns different values to letters based on how often they appear (e.g the letter E represents 11% of all letters used in English, so it gets assigned the 11 points).
- Wordlebot then goes through all of the words in it’s dictionary that match the current information about the word, and finds the top 5 words with the most total points
- The word highest in the dictionary (the most common) is then guessed
- Note: Duplicate letters don’t count, this is to discourage words like “eerie”
- For more information, check out the article about the infinite Wordle version
Dictionary
- After every game, Wordlebot moves the winning word upwards if it got it correct, and if Wordlebot didn’t guess the word in time, it swaps the position of the winning word with the one that was chosen before it
- For more information, check out the article about the Infinite Wordle version
Challenges with building it
Loading speed
- The original Wordlebot assessed Wordle+, and as it was programmed for fast loading lower traffic web pages, it would crash when the New York Times site would take more than 5-10 seconds to load.
- This was fixed by making Wordlebot waitlonger for a page to load before requesting elements on the page, as speed was not an issue since Wordlebot only needs to do a Wordle once a day.
Error Handling
- If an error occurs, Wordlebot will log the error and reboot. If this happens three times, Wordlebot will just “give up” and stop trying to reboot.
Dashboard
- To make a functioning dashboard, I used the Google Sheets API to write to a public google sheet which acts as the dashboard. I followed a basic tutorial as well as the gsheet module’s documentation
- To extract helpful information from my log files, I wrote a second script to process the log data into the current streak, the longest streak, how many times each end state occurred (e.g 3 guesses, FAIL etc.) the win rate, as well the actual game board
- Extra functionality had to be added to the Wordlebot script so that it could log the entire game board to be displayed on the dashboard
- I had some difficulty defining specific colours for google sheets to use, finally realising that while google sheets uses RGB for colouring, it’s range for each channel was not 0-255, instead being 0-1. (This is not because the gsheets documentation is bad, just that I didn’t RTFM well enough)