An entropy-based strategy to wordle

Overview

Wordle-Bot

An entropy-based strategy to wordle

Inspired by 3Blue1Brown

Install & Run

  1. Clone the script:
git clone https://github.com/GillesVandewiele/Wordle-Bot.git
  1. Install tqdm and scipy
(python -m) pip install tqdm scipy
  1. Run the script (it will generate 10 random words and apply the strategy)
python wordle.py
  1. There are some lines commented that will allow you to play interactively to solve the Wordle of the day.

Example

Example of execution

Statistics

I let the bot guess all the words in our word-list and generated a histogram of the required guesses. Can you do better? Statistics

Comments
  • High usage of RAM

    High usage of RAM

    I am considering a problem with ~ 3k valid solutions and ~ 17k possible guesses.

    I have tried running the code:

    • on my local machine,
    • on Google Colab.

    In both cases, I am faced with high usage of RAM. I wonder if this is normal due to the method used, or if there is a memory leak in the code.


    The script runs fine for now. Script

    The RAM usage linearly increases. High RAM usage

    High RAM usage ends up leading to a crash. RAM

    The script has crashed. Script


    For reference, this does not happen (or it does not have enough time to happen) if I consider a smaller problem where the possible guesses are forced to be valid solutions, i.e. with ~ 3k valid solutions and ~ 3k possible guesses.

    Also, the tool TylerGlaiel/wordlebot does not have this issue with the large problem. It is a C++ program which uses different methods, vaguely explained in this blog post. There are 3 methods, and the Complex one is horrendously slow (but does not crash), and the two other methods (Simple and MinMax) are fine.

    opened by woctezuma 5
  • add all_words and other update

    add all_words and other update

    Add an all_word.txt file and let the bot use the entropy until the entropy gets too small. It helps to reduce over-rounded resolutions. Added option to choose initial guess ('tares' for every word) to reduce testing time. The average round is now around 4.12 for all 2315 solutions with 1 over-rounded solution (7 rounds)

    next stage

    1. Use multi-processing to reduce processing time.
    2. Consider frequently used words using NLTK or other way
    opened by dawghen 3
  • `calculate_pattern` function does not take into account duplicate letters

    `calculate_pattern` function does not take into account duplicate letters

    For example, calculate_pattern('meets', 'weary') currently returns (0, 2, 1, 0, 0), however the correct pattern should be (0, 2, 0, 0, 0) since there is not a second e in the target word. One way to do this correctly is:

    from collections import Counter
    
    def calculate_pattern(guess, true):
        '''Yield the pattern that Wordle would return if you guessed `guess` and the true word is `true`'''
        yellows = Counter(true)
        for x, y in zip(guess, true):
            if x == y:
                yield 2
            elif yellows[x] > 0:
                yield 1
            else:
                yield 0
            yellows[x] -= 1
    

    you just need to then call this as tuple(calculate_pattern(word, word2)).

    opened by MarkCBell 2
  • Crash?

    Crash?

    Running the wordle.py file with a larger wordlist. 3b1b's 12k word list to be precise. Will make its way to 63% and then my computer freezes and then the terminal kills what's running and it stops.

    (wdlENV) [ori@orio Wordle-Bot]$ python wordle.py
    
     63%|█████████████████████████████████████████████▋                          | 8226/12972 [04:43<07:08, 11.07it/s]
    Killed
    
    (wdlENV) [ori@orio Wordle-Bot]$ 
    

    No idea as to why this happens but it does...

    opened by therealOri 2
  • `calculate_pattern` duplicate letter follow-up

    `calculate_pattern` duplicate letter follow-up

    I think you need to do two passes in order to also catch corner cases like calculate_pattern('rower', 'goner'), which currently returns (1, 2, 0, 2, 2) instead of (0, 2, 0, 2, 2).

    Originally posted by @gbotev1 in https://github.com/GillesVandewiele/Wordle-Bot/issues/2#issuecomment-1038630546

    opened by gbotev1 1
  • Switch entropy logic

    Switch entropy logic

    This commit builds upon #13, and aims to follow the strategy described in https://github.com/GillesVandewiele/Wordle-Bot/issues/9#issuecomment-1193172701 for the computation of entropy.

    I would need to test the software to check if I did not break anything with my changes.

    opened by woctezuma 0
  • Compute entropy in chunks

    Compute entropy in chunks

    This should clarify with view from #9 and would avoid removing the code as I suggested in #10.

    This commit builds upon #12, and aims to break down the computation of entropy in chunks.

    opened by woctezuma 0
  • Add disk utilities

    Add disk utilities

    This commit adds utilities to read/write pattern_dict.p (retro-compatibility), and allows to deal with several numbered versions.

    This is important for another pull request (#12) which breaks down the dictionary of patterns into chunks.

    opened by woctezuma 0
  • Fix bug: missing function argument

    Fix bug: missing function argument

    This commit fixes a bug in the original code, as a function is missing an argument. Without this fix, the following error is returned:

    Traceback (most recent call last):
      File "C:\Users\Wok\PycharmProjects\Wordle-Bot\wordle.py", line 135, in <module>
        main()
      File "C:\Users\Wok\PycharmProjects\Wordle-Bot\wordle.py", line 113, in main
        entropies = calculate_entropies(candidates, all_words, pattern_dict)
      File "C:\Users\Wok\PycharmProjects\Wordle-Bot\wordle.py", line 62, in calculate_entropies
        for pattern in all_patterns:
    NameError: name 'all_patterns' is not defined
    
    opened by woctezuma 0
  • Explanation regarding the double call to calculate_entropies()

    Explanation regarding the double call to calculate_entropies()

    I don't understand the double call to calculate_entropies(). Could you clarify the reason behind it?

    https://github.com/GillesVandewiele/Wordle-Bot/blob/f6334959105549745300ff2c1fc7f80e7c8d7a07/wordle.py#L112-L117

    Indeed:

    • the set all_words is a subset of all_dictionary,
    • the variable entropies is a dictionary whose keys are candidates by design.

    So the second call to calculate_entropies() recomputes entropy values which were already computed by the first call.

    If the objective is to decrease the number of items fed to max(), it could be done by filtering entropies returned by the first call.

    https://github.com/GillesVandewiele/Wordle-Bot/blob/f6334959105549745300ff2c1fc7f80e7c8d7a07/wordle.py#L119-L120

    opened by woctezuma 5
Owner
Gilles Vandewiele
Hi, I'm Gilles! I like doing stuff with data & algorithms.
Gilles Vandewiele
Wordle-player - An optimal player for Wordle. Based on a rough understanding of information theory

Wordle-player - An optimal player for Wordle. Based on a rough understanding of information theory

Neill Johnston 3 Feb 26, 2022
Wordle-helper: python script to help solving wordle game

wordle-helper This is a python script to help solving wordle game 5-letter-word-

MD Nur Ahmed 2 Feb 8, 2022
A very bad wordle solver to help me solve the daily wordle

Wordle Solver A very bad wordle solver to help me solve the daily wordle on https://www.powerlanguage.co.uk/wordle/ TODO list take into account letter

Logan Anderson 4 Feb 3, 2022
This is a python implementation of wordle, which uses the same set of available words as the hit game, Wordle

Wordle Game This is a python implementation of wordle, which uses the same set of available words as the hit game, Wordle. Play the game manually pyth

Pierre Theo Klein 11 Mar 4, 2022
Wordle player - A Class that plays wordle optimally

wordle_player A Class that plays wordle optimally if you want to play wordle opt

Andrés Hernández 1 Jan 31, 2022
Wordle - Wordle Clone With Python

Wordle Clone Python This is a cli clone of the famous wordle game developed by J

Shivam Pandya 20 Jul 7, 2022
Wordle-Python - A simple low-key clone of the popular game WORDLE made with python and a 2D Graphics module Pygame

Wordle-Python A simple low-key clone of the popular game WORDLE made with python

Showmick Kar 7 Feb 10, 2022
Wordle - Implementation of wordle and a solver

Wordle - Implementation of wordle and a solver

Kurt Neufeld 1 Feb 4, 2022
Wordle Tas Tool is a terminal application for solving Wordle puzzles

Wordle Tas Tool Terminal application for solving Wordle puzzles Wordle Tas Tool (WTT) is a Python script that iterates over SCOWL95 to solve Wordle pu

null 1 Feb 8, 2022
Wordle Solver: A simple script which is also called Wordle solver

wordle-solver this code is a simple script which is also called Wordle solver. t

amirreza 1 Feb 15, 2022
Wordle-prophecy - The comprehensive list of all Wordle answers, past and future

About This repo contains the comprehensive list of all Wordle answers, past and

Hayden Moritz 2 Dec 15, 2022
A two-player strategy game played on a rectangular grid made up of smaller square cells of chocolate 🍫 or cookies 🍪

Chomp Game ©️ Chomp is a two-player strategy game played on a rectangular grid made up of smaller square cells of chocolate ?? or cookies ?? , which c

Farivar Tabatabaei 2 Feb 2, 2022
Searches the word list in Wordle based on search pattern.

Wordle Searcher Searches the word list in Wordle based on search pattern. Warning: like all forms of cheating, it trivializes the game, and robs you o

Tyler Martin 1 Jan 29, 2022
Termordle - a terminal based wordle clone in python

Termordle - a terminal based wordle clone in python

null 2 Feb 8, 2022
Wordle is a web-based word game. Players have six attempts to guess a five-letter word;

Wordle is a web-based word game. Players have six attempts to guess a five-letter word; feedback is given for each guess, in the form of colored tiles, indicating when letters match or occupy the correct position. This program helps solving wordle problems.

Abhishek 2 May 21, 2022
An optimal solution finder for the game Wordle, written in Python

wordle-solver: a nearly-optimal computer player for Wordle Wordle is an interesting word guessing game. This program plays it very well, taking only 3

null 4 Jun 13, 2022
This is a Python solver for the game Wordle, which recently received its PT-BR version

PT_BR_Wordle_Solver Este é um solver feito em Python do jogo Wordle, que recebeu sua versão PT-BR recentemente. Onde jogar Os sites para se jogar mais

Vinicius Jameli 1 Jan 24, 2022
Given some input, spit out the possible words for a Wordle puzzle

Wordle Helper, because why not. Given some input, spit out the possible words for a Wordle puzzle First time setup # Download the dictionary to a file

Richard Duarte 1 Jan 25, 2022
Allows you to email people wordle spoilers. Very beta, not as many features

wordlespoiler Allows you to email people wordle spoilers. Very beta, not as many features How to Use 1.) Make a new gmail account. Go to settings (Man

null 0 Jan 4, 2023