The most comprehensive, exhaustive, parameterized command-line wordle solver.

Overview

Wordle Solver

The most comprehensive, exhaustive, parameterized command-line wordle (https://www.powerlanguage.co.uk/wordle/) solver. Wordle is a really popular game made viral by it's inscrutable and quirky emoticon-based game description.

The solver boasts a 99.35%+ accuracy on the 8636 valid 5-letter words. Features:

  • Supports 4 modes: play, show (to show a solution for a specific word), solve (to solve a puzzle online) and eval (evaluate the performance)
  • Deterministic
  • Highest accuracy of all solutions evaluated
  • Fully tested
  • Latency ~0.26s per run Current dictionary used is the valid Scrabble dictionary.

Solver’s attempt to solve the Jan 10, 2022 wordle for the word query:

β¬›πŸŸ¨β¬›β¬›πŸŸ¨ AROSE
β¬›πŸŸ©β¬›β¬›β¬› TUMID
β¬›β¬›πŸŸ¨β¬›β¬› GLYPH
🟩🟩🟩🟩🟩 QUERY

Screen Shot 2022-01-12 at 12 26 16 AM

Algorithm

With the settings for non-strict play, using positional

  • Find all candidates that fit the criteria
  • Amongst the valid candidates, compute a distribution of letters at each position
  • Find a word from all valid guesses which optimizes sum(P(letter at pos i)) + 0.5 * sum(P letter not at pos i)
  • Repeat

The 56 failure cases are sakes, mooed, jived, wanes, jocks, minks, wades, jaded, zoner, joker, wived, jakes, mozos, goxes, vills, rover, zooks, cozes, jibes, wakes, hajes, joked, sinhs, zaxes, yaffs, hiker, bases, moved, bises, zills, hided, eaved, vined, surfs, jiber, gibed, dozer, fuzed, mixed, boxed, waxes, waves, vomer, egged, mazed, pests, hived, socks, fazes, vests, jibed, mewed, hazes, sooks, woods, sinks For all these words, there are 2-5 candidate words left at the last guess, and with a random last guess, there is a probability of guessing these too.

Usage

Play it yourself

python main.py -m play

Guess? tares
TARES
β¬›πŸŸ©πŸŸ¨β¬›β¬›
Guess? unlit
UNLIT
⬛⬛⬛⬛⬛
Guess? raver
RAVER
πŸŸ¨πŸŸ©πŸŸ©β¬›πŸŸ©
Guess? favor
FAVOR
🟩🟩🟩🟩🟩
Solved! - favor

Solve for an unknown word

python main.py -m solve

Try the word [TARES]. There are 8636 possible words: ['aahed', 'aalii', 'aargh', 'abaca', 'abaci']...
How did it do (0=⬛, 1=🟨, 2=🟩) e.g. 00000? 00000
Try the word [NOILY]. There are 575 possible words: ['biddy', 'biffy', 'bifid', 'bigly', 'bijou']...
How did it do (0=⬛, 1=🟨, 2=🟩) e.g. 00000? 02002
Try the word [DHOBI]. There are 39 possible words: ['bobby', 'boggy', 'booby', 'boogy', 'boomy']...
How did it do (0=⬛, 1=🟨, 2=🟩) e.g. 00000? 20100
Try the word [DODGY]. There are 3 possible words: ['dodgy', 'doggy', 'dowdy']...
How did it do (0=⬛, 1=🟨, 2=🟩) e.g. 00000? 22122
Try the word [DOGGY]. There are 1 possible words: ['doggy']...
How did it do (0=⬛, 1=🟨, 2=🟩) e.g. 00000? 22222
Solved! = doggy

Show a solution for a specific word

python main.py -m show -w oozed

Word [OOZED]
Choosing [tares]. Total 8636 candidates: ['aahed', 'aalii', 'aargh', 'abaca', 'abaci']...
TARES
β¬›β¬›β¬›πŸŸ©β¬›
Choosing [coled]. Total 288 candidates: ['bedel', 'bedew', 'bevel', 'bezel', 'bided']...
COLED
β¬›πŸŸ©β¬›πŸŸ©πŸŸ©
Choosing [howdy]. Total 31 candidates: ['boded', 'boned', 'booed', 'bowed', 'boxed']...
HOWDY
β¬›πŸŸ©β¬›πŸŸ¨β¬›
Choosing [bipod]. Total 16 candidates: ['boded', 'boned', 'booed', 'boxed', 'domed']...
BIPOD
β¬›β¬›β¬›πŸŸ¨πŸŸ©
Choosing [dozen]. Total 8 candidates: ['domed', 'dozed', 'foxed', 'joked', 'mooed']...
DOZEN
πŸŸ¨πŸŸ©πŸŸ©πŸŸ©β¬›
Choosing [oozed]. Total 1 candidates: ['oozed']...
OOZED
🟩🟩🟩🟩🟩
Solved! - oozed
Woohoo! Solver solved it in 6 guesses!

Evaluate its performance

python main.py -m eval -k 1000

Evaluating on 1000 words
k=10:	Failed: 1	Accuracy:90.00%	Avg Time: 0.258s
k=20:	Failed: 1	Accuracy:95.00%	Avg Time: 0.250s
k=30:	Failed: 1	Accuracy:96.67%	Avg Time: 0.249s
k=40:	Failed: 1	Accuracy:97.50%	Avg Time: 0.244s
k=50:	Failed: 1	Accuracy:98.00%	Avg Time: 0.239s
...
k=970:	Failed: 10	Accuracy:98.97%	Avg Time: 0.236s
k=980:	Failed: 10	Accuracy:98.98%	Avg Time: 0.236s
k=990:	Failed: 10	Accuracy:98.99%	Avg Time: 0.236s
Failed on: ['jived', 'hides', 'razer', 'zooks', 'jills', 'gibed', 'wises', 'yipes', 'wipes', 'sises']
Distribution of remaining candidates: [(4, 5), (3, 3), (2, 1), (5, 1)]
K=999:	Failed: 10	Accuracy:99.00%

Run Tests

python -m unittest runs the entire test suite.

Evaluation

Using a dictionary of scrabble words, there are 172,819 total words and around 5% of them are exactly 5 letters long (8,636). The algorithm devised achieves a 99.28% success rate at guessing the right word, failing to get the correct the answer for 62 words.

Other settings achieved:

  • Global character frequency heuristic: Couldn't solve for 133 out of 1000 random samples (86.7% Success rate)
  • Conditional character frequency heuristic, on candidates left: Couldn't solve for 100 out of 1000 random samples (90.0% Success rate)
  • Non-strict solution: Couldn't solve for 46 out of 1000 random samples (95.4% Success rate)
  • Position-aware frequency heuristic + bug fixes: Couldn't solve for 9 out of 1000 random samples (99.1% Success rate)

Future Work

  • Support passing in solver settings through command line, including the weight of NON_POS_WEIGHT
  • Support passing in a custom dictionary through settings
  • Expose customizable number of letters in the word (N) and MAX_GUESSES.
Comments
  • Improve solver tests

    Improve solver tests

    This PR:

    • Renames one of the two tests named test_guess_next_word. Currently, the first test with this name is not getting run at all.

    • Adds a new test, test_guess_next_word_no_options, which ensures that we raise a no candidate exception if there's no suitable candidates (ie empty candidate lists or all candidates are already used)

    opened by veeral-patel 3
  • Add CI + Makefile

    Add CI + Makefile

    This PR:

    • Adds CI to the repository using GitHub Actions. The CI pipeline runs unit tests and generates a code coverage report.

    See a sample CI pipeline execution here: Screen Shot 2022-02-20 at 11 29 28 PM

    https://github.com/veeral-patel/wordle-solver/runs/5270506138?check_suite_focus=true

    • Creates a Makefile which can be used to run tests and compute code coverage with make test and make cover respectively. This way no one needs to memorize any commands.

    (Note you may need to install coverage with pip3 install coverage)

    • In addition, make cover-report opens a HTML UI with coverage data, broken down by line, as you can see here:

    Screen Shot 2022-02-20 at 11 31 10 PM

    opened by veeral-patel 2
  • WIP: Add CI (using GitHub Actions)

    WIP: Add CI (using GitHub Actions)

    Hi Deedy - was working on adding CI to the repository in order to run our tests (and help me get my feet wet with working with the codebase). Unfortunately looks like I created this pull request on your repo rather than my own fork. I'll get it working and let you know when I have something to merge :)

    opened by veeral-patel 0
  • Wrong exception management

    Wrong exception management

    While trying to debug the code it didn't stop at the failing sentence. The problem is that main code catches all the exceptions and does nothing to either fix it or solve it.

    https://github.com/deedy/wordle-solver/blob/deed27f02577aa3b00387287114b443f93ebbdc1/main.py#L72-L78

    I think the code shouldn't catch exceptions if it's not going to do anything with them.

    opened by Temporalin 0
  • Fails with non-English languages

    Fails with non-English languages

    I tried running the solver with a Spanish dictionary and it broke in this line: https://github.com/deedy/wordle-solver/blob/deed27f02577aa3b00387287114b443f93ebbdc1/game/solver/solver.py#L131

    It happens when c='Γ±', because ord('Γ±') == 241.

    opened by Temporalin 0
Owner
Debarghya Das
Debarghya Das
Wordle - Wordle solver with python

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

shidocchi 0 Jan 24, 2022
Wordle-solver - A tool that helps people who struggle with vocabulary to enjoy the famous game of WORDLE

Wordle-Solver Wordle-Solver helps people who struggle with vocabulary to enjoy t

Jason Chao 104 Dec 31, 2022
A command-line based, minimal torrent streaming client made using Python and Webtorrent-cli. Stream your favorite shows straight from the command line.

A command-line based, minimal torrent streaming client made using Python and Webtorrent-cli. Installation pip install -r requirements.txt It use

Jonardon Hazarika 17 Dec 11, 2022
PyWordle: A Python-made wordle manual solver

PyWordle: A Python-made wordle manual solver How to use it Start the program with python3 pywordlesolver.py. How it works The program has a simple 5-l

Federico Torrielli 5 Nov 24, 2022
A Python-based Wordle solver and CLI player

Wordle A Python-based Wordle solver and CLI player This was created using Python 3.9.7. SPOILER ALERT: the data directory contains spoilers for upcomi

Will Fitzgerald 1 Jul 24, 2022
Pyrdle - Play Wordle in the CLI. Write an algorithm to play Wordle for you. Ruin all of the fun you've been having

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

Charles Tapley Hoyt 11 Feb 11, 2022
Wordle breaker: A CLI tool to help you solve Wordle

Wordle Breaker A CLI tool to help you solve Wordle I decided to code a solution

Alex 4 Apr 27, 2022
Wordle for CLUE - WORDLE clone for Adafruit Clue

Wordle_for_CLUE This project is a clone of the very popular word solving puzzle

Michael Lacock 4 Feb 15, 2022
Play Wordle Bot - Wordle Bot written in python

Wordle Bot A Bot written in python with a CL Interface to guess adn solve Wordle

Prashant 1 Feb 25, 2022
Wordle-textual - Play Wordle from the CLI, using Textual

Wordle, playable from the CLI This project seeks to emulate Wordle in your shell

PhenoM4n4n 3 Mar 29, 2022
A cd command that learns - easily navigate directories from the command line

NAME autojump - a faster way to navigate your filesystem DESCRIPTION autojump is a faster way to navigate your filesystem. It works by maintaining a d

William Ting 14.5k Jan 3, 2023
AML Command Transfer. A lightweight tool to transfer any command line to Azure Machine Learning Services

AML Command Transfer (ACT) ACT is a lightweight tool to transfer any command from the local machine to AML or ITP, both of which are Azure Machine Lea

Microsoft 11 Aug 10, 2022
Ros command - Unifying the ROS command line tools

Unifying the ROS command line tools One impairment to ROS 2 adoption is that all

null 37 Dec 15, 2022
commandpack - A package of modules for working with commands, command packages, files with command packages.

commandpack Help the project financially: Donate: https://smartlegion.github.io/donate/ Yandex Money: https://yoomoney.ru/to/4100115206129186 PayPal:

null 4 Sep 4, 2021
A Python-based command prompt concept which includes windows command emulation.

PythonCMD A Python-based command prompt concept which includes windows command emulation. Current features: echo: Input your message and it will be cl

null 1 Feb 5, 2022
Library and command-line utility for rendering projects templates.

A library for rendering project templates. Works with local paths and git URLs. Your project can include any file and Copier can dynamically replace v

null 808 Jan 4, 2023
A command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, VueJS projects.

Cookiecutter A command-line utility that creates projects from cookiecutters (project templates), e.g. creating a Python package project from a Python

null 18.6k Dec 30, 2022
instant coding answers via the command line

howdoi instant coding answers via the command line Sherlock, your neighborhood command-line sloth sleuth. Are you a hack programmer? Do you find yours

Benjamin Gleitzman 9.8k Jan 8, 2023
As easy as /aitch-tee-tee-pie/ πŸ₯§ Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie

HTTPie: human-friendly CLI HTTP client for the API era HTTPie (pronounced aitch-tee-tee-pie) is a command-line HTTP client. Its goal is to make CLI in

HTTPie 25.4k Dec 30, 2022