Pyrdle - Play Wordle in the CLI. Write an algorithm to play Wordle for you. Ruin all of the fun you've been having

Overview

Wordle

Pyrdle (pronounced purr-dul) is Wordle implemented in Python.

Contributions welcome, but I don't have a ton of interest in providing support on this code, so use at your own risk.

Install and Play

$ pip install pyrdle
$ wordle

Use --help to see how to set the game to have a different number of letters, different number of guesses, or to use a different language.

CLI Demo

Notes, See Also, and Acknowledgements

Why We're Really Here: to Ruin Wordle

I originally wrote this after talking to @scolby33 and @deoxys314 because I wanted to write an algorithm to play Wordle for me. I started by creating a way of simulating a game, then realized there were lots of ways to play, so naturally I wanted to be able to figure which was best.

This repository assesses two metrics about each algorithm:

  1. Success: how many of the words of the given length and number of guesses can it successfully solve?
  2. Efficiency: what's the average number of guesses needed over all successful words?

Later, this repository will run multiple trials in order to assign confidence intervals for success and quality for randomized algorithms.

Strategies

This repository is a playground for implementing new solve strategies. Feel free to send a PR with your own (just subclass the Player class)!

Terminology:

  1. Perfect guess: a guess that uses all previous information available, including knowledge about correct positions, unused letters, and used letters

Initial Fixed Guesses with Successive Greedy Choices

This algorithm takes a list of one, two, three, etc. initial guesses and always does them in order. This strategy lets you maximize the number of unique letters you can get information (e.g., if you pick three words, you can potentially get information about 15 letters in the standard 5-column variant of the game). However, this strategy sacrifices the positional information learned during these guesses as they are not used.

After the initial guesses, the algorithm tabulates all the constraints it learned (e.g., which letters are in the right position, which letters are present but in the wrong position, and what letters are not present). It then reads through the dictionary and picks the first word that matches all the constraints. If this isn't the winner, it updates the constraints and continues. This works quite well!

The obvious follow-up questions are:

  1. How often does this work?
  2. How many initial words do I need?
  3. What are the best words?
  4. Can this algorithm be improved?

The answer to 4 is yes: rather than picking just the first word, you can rank all the remaining words by "entropy" and pick the highest one. But now let's look at the other questions for different possible 1, 2, and 3-word fixed initial guesses. Each word is given an entropy score by first calculating the letter frequencies across all words of the given length then performing a weighted sum of the unique letters in a word based on their frequencies. Therefore, words containing a larger variety of frequent letters get the highest entropy scores.

One Fixed Guess

For each of the ~3.5 5-letter words in the English dictionary, I chose that word as the initial word, then ran the fixed guess with successive greedy choices algorithm for all possible Wordle games starting with all words. Then I calculated the number of games where the algorithm was successful. The following chart shows entropy score of each initial guess vs. the percentage success rate across all games on all words. I was expecting a weak linear relation between score and success, but there almost isn't one at all. It turns out, if you're a perfect guesser, then Wordle is just too easy most of the time. I bet that the few failures were due to the naïveté of the algorithm, which could be improved the way I described above.

One word initial guess with successive first valid choice

Three Fixed Guesses

We actually got into this whole thing because we thought that we needed three letters to start it off. Mamma Hoyt said she had picked Ariel, thump, and gowns as her initial guesses. I hadn't even considered doing this at the moment, so I was off to the races. My sister came up with the same idea, and had chosen weary, ghost, lions.

This strategy involves deterministically guessing three words that cover a wide variety of vowels and consonants. For example, (lunch, metro, daisy) covers all five vowels and 10 different consonants.

It's pretty likely that with these choices, you will be able to deterministically solve for the word after one more perfect guess. It turns out that with this example, you can solve 96.9% of the time with an average of 4.27 guesses. That's pretty surprising, but also assumes you have computer-like recall of words.

I haven't quite got around to scoring all the possible 3-letter starts. First, it will take a loooong time, and I'm not willing to leave Python to finish this (it will then stop being fun). Second, I haven't yet determined if the following statement is true or not:

The best performing word in the 1 word variant of this algorithm will also appear in the best performing pair of words in the 2 word variant

If this is true, then all of those considerations of implementation will go out the window, so I will need to think about it a bit more!

Owner
Charles Tapley Hoyt
Bio/cheminformatician, open scientist, maintainer of @pybel and @pykeen, part of @indralab (he/him)
Charles Tapley Hoyt
Oil is a new Unix shell. It's our upgrade path from bash to a better language and runtime

Oil is a new Unix shell. It's our upgrade path from bash to a better language and runtime. It's also for Python and JavaScript users who avoid shell!

2.4k Jan 08, 2023
Enlighten Progress Bar is a console progress bar library for Python.

Overview Enlighten Progress Bar is a console progress bar library for Python. The main advantage of Enlighten is it allows writing to stdout and stder

Rockhopper Technologies 265 Dec 28, 2022
A simple weather tool. I made this as a way for me to learn Python, API, and PyPi packaging.

A simple weather tool. I made this as a way for me to learn Python, API, and PyPi packaging.

Clint E. 105 Dec 31, 2022
A command line application to analyse reports from TBC Warcraft Logs.

README A command line application to analyse reports from TBC Warcraft Logs. The application was written and tested with Python 3.9. Features Dumps an

2 Dec 17, 2021
🏃 Python3 Solutions of All Problems in GCJ 2022 (In Progress)

GoogleCodeJam 2022 Python3 solutions of Google Code Jam 2022. Solution begins with * means it will get TLE in the largest data set. Total computation

kamyu 12 Dec 20, 2022
A CLI minesweeper application written in 60 LoC python

This is a CLI minesweeper application written in 60 LoC python. You can use d row,column to dig and f row,column to flag/unflag

1 Dec 21, 2021
Python-based implementation and comparison of strategies to guess words at Wordle

Solver and comparison of strategies for Wordle Motivation The goal of this repository is to compare, in terms of performance, strategies that minimize

Ignacio L. Ibarra 4 Feb 16, 2022
Ssl-tool - A simple interactive CLI wrapper around openssl to make creation and installation of self-signed certs easy

What's this? A simple interactive CLI wrapper around openssl to make self-signin

Aniket Teredesai 9 May 17, 2022
A simple automation script that logs into your kra account and files your taxes with one command

EASY_TAX A simple automation script that logs into your kra account and files your taxes with one command Currently works for Chrome users. Will creat

leon koech 13 Sep 23, 2021
🗃️ Fileio-cli wrapper for fileioapi.py with fire.py, inspiration DOS

🗃️ File.io File.io simply upload a file, share the link, and after it is downloaded, the file is completely deleted. An API wrapper for the file.io w

nkot56297 2 May 12, 2022
Wordle - Wordle solver with python

wordle what is wordle? https://www.powerlanguage.co.uk/wordle/ preparing $ pip i

shidocchi 0 Jan 24, 2022
Analyzing the most strategic words to guess on Wordle, based on letter frequency distributions

wordle-analysis Evaluating different heuristics to determine the most effective solving strategy and building an AI-powered assistant tool to help you

Sejal Dua 9 Feb 27, 2022
gcptree - Like the unix tree command but for GCP Org Heirarchy

gcptree Like the unix tree command but for GCP Org Heirarchy. For a note on coloring, the org node is green, folders and blue, and projects that are n

Ryan Canty 25 Sep 06, 2022
ctree - command line christmas tree

ctree ctree - command line christmas tree It is small python script that prints a christmas tree in terminal. It is colourful and always gives you a d

15 Aug 15, 2022
GDBIGtools: A command line tools for GDBIG varaints browser

GDBIGtools: A command line tools for GDBIG varaints browser Introduction Born in Guangzhou Cohort Study Genome Research Database is based on thousands

广州市出生队列基因组学研究(The genomics study of BIGCS) 7 Sep 14, 2022
Python library and command line tool for interacting with Bugzilla

python-bugzilla This package provides two bits: bugzilla python module for talking to a Bugzilla instance over XMLRPC or REST /usr/bin/bugzilla comman

Python Bugzilla Project 112 Nov 05, 2022
alternative cli util for update-alternatives

altb altb is a cli utility influenced by update-alternatives of ubuntu. Linked paths are added to $HOME/.local/bin according to XDG Base Directory Spe

Elran Shefer 8 Dec 07, 2022
MasterDuel Image Recognition Translation Command Line Tool

MasterDuelTranslate(Use Ygo Card DataBase,belong win32 window shot & image match)

PatchouliTC 77 Dec 01, 2022
uploadgram uses your Telegram account to upload files up to 2GiB, from the Terminal.

uploadgram uploadgram uses your Telegram account to upload files up to 2GiB, from the Terminal. Heavily inspired by the telegram-upload Installing: pi

Shrimadhav U K 97 Jan 06, 2023
A powerful Minecraft command library.

Mecha A powerful Minecraft command library. from mecha import Mecha

32 Dec 10, 2022