Python bot created with Selenium that finds the word of the day through process of elimintaiton.
- 70% of the time the bot should find the word within the 6 attempts.
- If it does not, a new browser session is launched to continue solving.
- Clone or fork the repo.
- pip install the requirements.txt file. (You may want to create a new virtual environment as well.)
python -m pip install -r requirements.txt
- Create a
.env
file in the project folder.- The
.env
file is required to have the file path to your selenium chrome webdriver. See here for more details on seleniums chrome webdrivers.
- The
CHROME_DRIVER="path/to/your/chromedriver.exe"
- Running
--help
or-h
will show the available arguments and default values.
python -m wordle_bot --help
- To run the module with the chrome instance hidden simply run the below. command:
python -m wordle_bot
- To run the module with the chrome instance visible run enter the
--display
or-d
argument as True
python -m wordle_bot -d True
- To run the module and get results as an SMS pass
textbelt
ortwillo
to the--sms
or-s
argument. Note: You will need to have atextbelt
ortwillo
account and have the appropriate.env
variables set. See below for the details.
python -m wordle_bot -s textbelt
send_twillo_sms_notification
Will send a text message to your default number.- Dependencies:
- Twillo function is deppendent on the .env file saved in root folder.
- You will need to set up a Twillo Account. See Twillo SMS for more information.
- Contents of .env file below:
TWILIO_ACCOUNT_SID=Your_Twillo_Account_SID
TWILIO_AUTH_TOKEN=Your_Twillo_Auth_Token
TWILLO_FROM=Your_Tiwllo_From_Number
TO_NUMBER=Your_Twillo_To_Number
send_textbelt_sms_notification
Will send a text message to your number in the.env
file.- Dependencies:
- Textbelt function is deppendent on the .env file saved in root folder.
- You will need to create a Textbelt account. See Textbelt for more details.
- Contents of .env file below:
TO_NUMBER=Your_Mobile_Number
Algorithm is handled in the WordHandler class. The process is as follow:
- The first two guess are optimized words for elimination, words sourced from wired.com's article here.
- iterate through word list, for each word:
- If the word does not contain a known value at the known index, remove it from the list.
- If the word does not contian a present letter, remove it form the list.
- If the word contains a absent letter, remove it form the list.
- Use random.choice to select the new word form the filtered list.
- Note: There is a lot of room for improvement here, such as not using random and calculating probability, but that was not the intent of this project.
The WordleWebDriver class handles all interactions with the site. An instance of the WordHandler class is encapsulated here for ease of updating known letter indexes, present letters and absent letters.
- display_page boolean toggles wether the chrome driver should run in the background or not.
- Web Driver handles all the interactions with the page, such as sending words and extracting data.
The word list is all 5 letter words downloaded from The Stanford GraphBase: A Platform for Combinatorial Computing. I thought it would be two easy to use the same words as Wordle.