Analysis of a daily word game "Wordle"

Overview

Wordle

Analysis of a daily word game "Wordle"

https://www.powerlanguage.co.uk/wordle/

Description

Worlde is a daily word game in which a player attempts to guess a 5-letter word in at most 6 trials. After each guess for each letter he recieves a response whether or not it is present in a word and if so, is it in correct position. Thus, for each letter we have three options:

  • The letter is correct and in a correct position, denoted by a green colour and letter C in this project
  • The letter is correct (i.e. it exists in a word) but in an incorrect position, denoted by a yellow colour and letter I in this project
  • The letter is incorrect (i.e. is not present in a word), denoted by a gray colour and letter O in this project

The game has two variants: easy and hard. An easy variant allows to guess any word at each stage of the game. The hard version forces the player to guess the word that conforms to the information that has already been discovered (e.g. he is not allowed to guess the words which contain letters that were previously revealed to not be present in a word). In this project we focus on the hard variant.

Instalation

The project requires several packages - the information is contained in the requirements.txt file and can easily be installed with:

using pip

pip install -r requirements.txt

using Conda

conda create --name <env_name> --file requirements.txt

Aim

The aim of the project is to find the strategy that guesses the word in as little number of guesses as possible.

Files

wordle.py

Main package of the project - contains all the code needed to generate game tree and compute the best possible strategy. It implements two classes:

  • GameState: tracks the state of the game - which letters have been eliminated, which are in their correct positions and which exist in a word but at a different position

  • Node: tree data structure for keeping track of all possible scenarios of the game

words.py

Scrapes the list of 5-letter english words from the website:

https://www.bestwordlist.com/

game.py

Simulates the Wordle game by sampling a random word from the list and then repeatedly querying the player for a 5-letter guess and replying with a 5-letter response code (consisting of the letters C, I and O as described in the Description section).

Example usage:

Guess TARES and type the response: OIOOO
Guess PLAIN and type the response: OOCIO
Guess KHAZI and type the response: OOCOC
Guess ABACI and type the response: IOCOC
Guess UMAMI and type the response: CCCCC
It took 5 guesses.

solve.py

Solves the Wordle game by repeatedly providing the player with a guess and then asking him for a 5-letter response code (consisting of the letters C, I and O as described in the Description section) until there word has been guessed correctly. It needs to be provided with solver.json file which is produced by the attached Jupyter Notebook.

Example usage

Enter your guess: TARES
The response was: OIOOO
Enter your guess: PLAIN
The response was: OOCIO
Enter your guess: KHAZI
The response was: OOCOC
Enter your guess: ABACI
The response was: IOCOC
Enter your guess: UMAMI
Correct! It took you 5 guesses.

wordle.ipynb

The Jupyter Notebook with the analysis of the game which also computes the solver.json file for the optimal strategy needed for the solve.py script.

License

Project is distributed under the MIT license

Owner
Bartek
Bartek
A python CLI app that converts a mp4 file into a gif with ASCII effect added.

Video2ASCIIgif This CLI app takes in a mp4 format video, converts it to a gif with ASCII effect applied. This also includes full control over: backgro

Sriram R 6 Dec 31, 2021
Vsm - A manager for the under-utilized mksession command in vim

Vim Session Manager A manager for the under-utilized `mksession` command in vim

Matt Williams 3 Oct 12, 2022
Easily handle day to day CLI operation via Python instead of regular Bash programs.

pz Ever wished to use Python in Bash? Would you choose the Python syntax over sed, awk, ...? Should you exactly know what command would you use in Pyt

CZ.NIC 697 Jan 03, 2023
A Yahtzee-solving python package and command line tool.

yahtzee A Yahtzee-solving python package and command line tool. The algorithm is mathematically guaranteed to have the best strategy. That is, it maxi

David Merrell 0 Aug 19, 2022
A powerful, colorful, beautiful command-line-interface for pypi.org

pypi-command-line pypi-command-line is a colorful, powerful, and beautiful command line interface for pypi.org that is actively maintained Detailed Do

Wasi Master 32 Jun 23, 2022
A simple discord slash command handler for for discord.py.

A simple discord slash command handler for discord.py About ⦿ Installation ⦿ Disclaimer ⦿ Examples ⦿ Documentation ⦿ Discussions Note that master bran

641 Jan 03, 2023
🪛 A simple pydantic to Form FastAPI model converter.

pyfa-converter Makes it pretty easy to create a model based on Field [pydantic] and use the model for www-form-data. How to install? pip install pyfa_

20 Dec 22, 2022
CPOST is a CLI tool to assist with the proper sizing of Clara Deploy pipelines

CPOST (Clara Pipeline Operator Sizing Tool) Tool to measure resource usage of Clara Platform pipeline operators Cpost is a tool that will help you run

NVIDIA Corporation 5 Sep 27, 2021
A very simple and lightweight ToDo app using python that can be used from the command line

A very simple and lightweight ToDo app using python that can be used from the command line

Nilesh Sengupta 2 Jul 20, 2022
Command-line search tool for GitHub

cligh is a command-line search tool for GitHub.

1 Oct 02, 2022
Get latest astronomy job and rumor news in your command line

astrojobs Tired of checking the AAS job register and astro rumor mill for job news? Get the latest updates in the command line! astrojobs automaticall

Philip Mocz 19 Jul 20, 2022
Command line tool to keep track of your favorite playlists on YouTube and many other places.

Command line tool to keep track of your favorite playlists on YouTube and many other places.

Wolfgang Popp 144 Jan 05, 2023
🐾 Get the nftables counters easier to read

nft-stats Get the nftables counters easier to read It kind of hard to read the output of nft list ruleset so there is a small program parcising the ou

7 Oct 08, 2022
ServX | Bash Command as a Service

ServX | Bash Command as a Service Screenshots Instructions for running Run python3 servx.py. COMPATIBILITY TESTED ON ARCHLINUX(x64) & DEBIAN(x64) ONLY

ARPSyndicate 2 Mar 11, 2022
A super simple wallet application for the NANO cryptocurrency that runs in the terminal

Nano Terminal Wallet A super simple wallet application for the NANO cryptocurrency that runs in the terminal Written in 2021 by NinjaSnail1080 (Discor

9 Jul 22, 2022
Create argparse subcommands with decorators.

python-argparse-subdec This is a very simple Python package that allows one to create argparse's subcommands via function decorators. Usage Create a S

Gustavo José de Sousa 7 Oct 21, 2022
Openstack bucket retention cli

Openstack bucket retention cli

Fatih Sarhan 3 Apr 03, 2022
💻 Physics2Calculator - A simple and powerful calculator for Physics 2

💻 Physics2Calculator A simple and powerful calculator for Physics 2 🔌 Predefined constants pi = 3.14159... k = 8988000000 (coulomb constant) e0 = 8.

Dylan Tintenfich 4 Dec 01, 2021
Quo is a Python based toolkit for writing Command-Line Interface(CLI) applications.

Quo is a Python based toolkit for writing Command-Line Interface(CLI) applications. Quo is making headway towards composing speedy and orderly CLI applications while forestalling any disappointments

Secretum Inc. 16 Oct 15, 2022
An open-source CLI tool for backing up RDS(PostgreSQL) Locally or to Amazon S3 bucket

An open-source CLI tool for backing up RDS(PostgreSQL) Locally or to Amazon S3 bucket

1 Oct 30, 2021