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
💻 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
Dynamically Generate GitHub Stats as like Terminal Interface

GitHub Stats Terminal Style Dynamically Generate GitHub Stats as like Terminal Interface Usage Create a New Repository using this Template or click he

YOGESHWARAN R 63 Jan 03, 2023
A simple CLI application helps you to find giant files that are eating up your system storage

Large file finder Sometimes it's very hard to find if some giant files are eating up your system storage. We might need to hunt those down. This simpl

Rahul Baruri 5 Nov 18, 2022
Python Library and CLI for exporting MySQL databases

expdb Python library and CLI for exporting MySQL databases Installation Pre-requisites MySQL server Python 3.9+ Using git Clone the repository to your

Devansh Singh 1 Nov 29, 2021
NudeNet wrapper made to provide a simple cli interface to the library

Nudenet Wrapper. Small warpper script for NudeNet Made to provide a small and easy to use cli interface with the library. You can indicate a single im

1 Oct 20, 2021
This is a CLI utility that allows you to view RedFlagDeals.com on the command line.

RFD Description Motivation Installation Usage View Hot Deals View and Sort Hot Deals Search Advanced View Posts Shell Completion bash zsh Description

Dave G 8 Nov 29, 2022
Freaky fast fuzzy Denite/CtrlP matcher for vim/neovim

Freaky fast fuzzy Denite/CtrlP matcher for vim/neovim This is a matcher plugin for denite.nvim and CtrlP.

Raghu 113 Sep 29, 2022
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

18.6k Dec 30, 2022
Browse Hacker News like a haxor: A Hacker News command line interface (CLI).

haxor-news Coworker who sees me looking at something in a browser: "Glad you're not busy; I need you to do this, this, this..." Coworker who sees me s

Donne Martin 3.8k Jan 07, 2023
A python library for parsing multiple types of config files, envvars & command line arguments that takes the headache out of setting app configurations.

parse_it A python library for parsing multiple types of config files, envvars and command line arguments that takes the headache out of setting app co

Naor Livne 97 Oct 22, 2022
Chopper: An Automated Security Headers Analyzer

____ _ _ / ___| |__ ___ _ __ _ __ ___ _ __| | | | | '_ \ / _ \| '_ \| '_ \ / _ \ '__| | | |___| | | | (_) |

Kamran Saifullah (Frog Man) 2 Nov 27, 2022
My dotfiles -My configuration, with installations steps.

.dotfiles My configuration, with installations steps. Installation Oh My ZSH Install with this command: sh -c "$(curl -fsSL https://raw.githubusercont

Luca Angioloni 4 Dec 14, 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 03, 2023
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 very simple python script to encode and decode PowerShell one-liners.

PowerShell Encoder A very simple python script to encode and decode PowerShell one-liners. I used Raikia's PowerShell encoder ALOT, but one day it wen

John Tear 5 Jul 29, 2022
eBay's TSV Utilities: Command line tools for large, tabular data files. Filtering, statistics, sampling, joins and more.

Command line utilities for tabular data files This is a set of command line utilities for manipulating large tabular data files. Files of numeric and

eBay 1.4k Jan 09, 2023
split-manga-pages: a command line utility written in Python that converts your double-page layout manga to single-page layout.

split-manga-pages split-manga-pages is a command line utility written in Python that converts your double-page layout manga (or any images in double p

Christoffer Aakre 3 May 24, 2022
Sink is a CLI tool that allows users to synchronize their local folders to their Google Drives. It is similar to the Git CLI and allows fast and reliable syncs with the drive.

Sink is a CLI synchronisation tool that enables a user to synchronise local system files and folders with their Google Drives. It follows a git C

Yash Thakre 16 May 29, 2022
dsub is a command-line tool that makes it easy to submit and run batch scripts in the cloud.

Open-source command-line tool to run batch computing tasks and workflows on backend services such as Google Cloud.

Data Biosphere 233 Jan 01, 2023
A simple command-line tracert implementation in Python 3 using ICMP packets

Traceroute A simple command-line tracert implementation in Python 3 using ICMP packets Details Traceroute is a networking tool designed for tracing th

James 3 Jul 16, 2022