Skip to content

fkodom/wordle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wordle

Fastest Wordle solver in the West.

  • 99.83% success rate
  • 3.597 average turns to win
  • <10 ms per guess (single-threaded)
  • Measured against the official Wordle word list! (Always check your sources. 🙃)

Use the --mode win-percentage flag to optimize for success rate (see below). In that case, you can't lose if your first guess is RALPH. ¯\(ツ)

quick draw

Install

Install directly from this repository:

pip install git+https://github.com/fkodom/wordle.git

Solve

Launch the assistive solver:

solve-wordle

Or optimize for win percentage:

solve-wordle --mode win-percentage

Play

Visit the Public Web App, or play a command line game:

play-wordle

Benchmarks

Full details in benchmarks.jsonl.

  • Accuracy (99.83%) and turns-to-win (3.597) are averages over recommended starting words, using default settings
  • RALPH has the highest win percentage (99.95%)
  • SLATE has the fewest turns to win (3.539)
  • BLAST is a good balanced choice (99.91%, 3.608)

NOTE: RALPH has a 100% win percentage if you use the --mode win-percentage flag.

How It Works

Exactly solving for word probabilities requires an exhaustive search through all possible word combinations. (There are way too many to be fast or practical.) Instead, we approximate them using a cheaper method.

Maximum Split

Each guess should eliminate as many possible words from the word bank as possible. The "maximum split" method does just that:

  • iterate through each possible (guess, target) pair
  • measure the number of remaining possible words for each pair
  • recommend guesses that give the smallest average numbers of remaining words.

Word Probability

A few definitions:

--> probability of character $c$ at position $i$ in the word

--> probability of character $c$ at any position

--> probability of a word ($c_1$, $c_2$, $c_3$, $c_4$, $c_5$)

--> counts of character $c$ in word $w$

--> counts of character $c$ in the remaining word bank

Very roughly speaking, the word probability scales with each of $p_i(c)$ and $p(c)$:

Then, and can be approximated from the remaining possible words, just by counting the frequencies of different letters. Then, to avoid over-counting from words with repeated letters, we divide by the number of identical permutations.

Hybrid (Default)

The "maximum splits" method is more accurate, but it's slow when the number of remaining words is large. So as a hybrid method:

  • If >128 possible words remain, use word probability
  • Otherwise, use maximum split

The --mode win-percentage flag uses exhaustive search once the number of remaining words drops below 16. It's somewhat of a hack, but you win a slightly higher percentage of games. Unless RALPH is your starting word, it's probably too small of a difference to notice.