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
Doro is a CLI based pomodoro app and countdown timer application built using python.

Doro - CLI based pomodoro app Doro is a CLI based pomodoro app and countdown timer application built using python. Install $ pip install doro Usage Po

Suresh Kumar 14 May 23, 2022
Very nice SMS & Mail Bomber for Termux and Linux.

Very nice SMS & Mail Bomber for Termux and Linux. Coded with love)))

nordbearbot.dev 5 Nov 06, 2022
Magnificent app which corrects your previous console command.

The Fuck The Fuck is a magnificent app, inspired by a @liamosaur tweet, that corrects errors in previous console commands. Is The Fuck too slow? Try t

Vladimir Iakovlev 75k Jan 02, 2023
jenkins-tui is a terminal based user interface for Jenkins.

jenkins-tui 📦 jenkins-tui is a terminal based user interface for Jenkins. 🚧 ⚠️ This app is a prototype and in very early stages of development. Ther

Craig Gumbley 22 Oct 24, 2022
A **CLI** folder organizer written in Python.

Fsorter Introduction A CLI folder organizer written in Python. Dependencies Before installing, install the following dependencies: Ubuntu/Debain Based

1 Nov 17, 2021
Declarative CLIs with argparse and dataclasses

argparse_dataclass Declarative CLIs with argparse and dataclasses. Features Features marked with a ✓ are currently implemented; features marked with a

Mike DePalatis 29 Dec 06, 2022
Features terminal for python

Features Terminal V1.0 (23/10/2021) Um programa para linux com diferentes ferramentas! Recursos: Criador de QR code Gerador de senhas Teste de velocid

1 Oct 26, 2021
PyDropper - pick colors everywhere

PyDropper - pick colors everywhere Downloads Settings PyDropper is an eyedropper

Herman Brunberg 2 Jan 04, 2022
Rdwcli - Car list cli app with python

Rdwcli - Car list cli app with python

Arie Twigt 1 Feb 02, 2022
kitty - the fast, feature-rich, cross-platform, GPU based terminal

kitty - the fast, feature-rich, cross-platform, GPU based terminal

Kovid Goyal 17.3k Jan 04, 2023
This is a command line program to play cricket made using Python.

SimpleCricketPython This is a command line program to play cricket made using Python How it works First you have the option of selecting whether you

Imira Randeniya 1 Sep 11, 2022
A next-generation CLI and TUI that aims to be your personal assistant for everything competitive programming related. 🚀

Competitive Programming Tool Kit The Competitive Programming Tool Kit (cptk for short), is a command line and terminal user interface (CLI and TUI) th

Alon 4 May 21, 2022
Program Command Line Interface (CLI) Sederhana: Pemesanan Nasi Goreng Hekel

Program ini merupakan aplikasi yang berjalan di dalam command line (terminal). Program ini menggunakan built-in library python yaitu argparse yang dapat menerima parameter saat program ini dijalankan

Habib Abdurrasyid 5 Nov 19, 2021
A new kind of Progress Bar, with real time throughput, eta and very cool animations!

A new kind of Progress Bar, with real time throughput, eta and very cool animations!

Rogério Sampaio de Almeida 4.1k Jan 08, 2023
A CLI based task manager tool which helps you track your daily task and activity.

CLI based task manager tool This is the simple CLI tool can be helpful in increasing your productivity. More like your todolist. It uses Postgresql as

ritik 1 Jan 19, 2022
A webmining CLI tool & library for python.

minet is a webmining command line tool & library for python (= 3.6) that can be used to collect and extract data from a large variety of web sources

médialab Sciences Po 165 Dec 17, 2022
tox-server is a command line tool which runs tox in a loop and calls it with commands from a remote CLI.

Tox Server tox-server is a command line tool which runs tox in a loop and calls it with commands from a remote CLI. It responds to commands via ZeroMQ

Alexander Rudy 3 Jan 10, 2022
A command line tool that creates a super timeline from SentinelOne's Deep Visibility data

S1SuperTimeline A command line tool that creates a super timeline from SentinelOne's Deep Visibility data What does it do? The script accepts a S1QL q

Juan Ortega 2 Feb 08, 2022
A CLI tool for searching and watching videos on youtube with no spyware and MPV and yt-dlp

A CLI tool for searching and watching videos on youtube with no spyware and MPV and yt-dlp

TruncatedDinosour 3 Feb 22, 2022
Simple Digital Ocean CLI by python.

Simple Digital Ocean CLI by python.

Chiro 2 Jan 01, 2023