fkodom / semantle

Fastest 'Semantle' solver this side of the Mississippi.
MIT License
16 stars 1 forks source link
python3 semantle semantle-solver

semantle

Fastest Semantle solver this side of the Mississippi.

NOTES:

fast car

Install

Install directly from this repository:

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

Solve

Launch the assistive solver:

solve-semantle

In some situations, you may want to increase the solver's uncertainty:

It will take longer to solve the puzzle, but the solver will be more robust to discrepancies in word similarities. For example, to allow for differences of ±5 similarity score:

solve-semantle --uncertainty 5

Play

Play a command line game:

play-semantle

NOTE: I believe the word bank is much larger than in the official Semantle game. You may get some obscure target words. ¯\(ツ)

How It Works

Semantle uses Word2Vec [Wiki][Docs] to compute the similarity between the target word and each guess. How it works, at a very high level:

Cosine similarity scores are commutative, which means that:

similarity(word1, word2) == similarity(word2, word1)

The solver uses that to efficiently search through all possible words. If a candidate word doesn't give the same similarity score, it can't possibly be the answer.

  1. Takes the user's guess, and the reported similarity from Semantle
  2. Finds all remaining words that have (approximately) the same similarity to the user's guess. (Needs to be approximate to allow for rounding and floating point errors.)
  3. Recommends one of those words, and then repeats from step (1) if the puzzle isn't solved yet.

With each guess, the solver eliminates a tremendous amount of possible solutions. There are roughly 150,000 possible answers (unique English words made up of only lowercase letters), but the solver wins in about 3 turns on average. :)