Analysis of a daily word game "Wordle"

Related tags

CLI Tools 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

You might also like...
Make tree planting a part of your daily workflow. 🌳

Continuous Reforestation Make tree planting a part of your daily workflow. 🌳 A GitHub Action for planting trees within your development workflow usin

A CLI based task manager tool which helps you track your daily task and activity.

CLI based task manager tool This is the simple CLI tool can be helpful in increasing your productivity. More like your todolist. It uses Postgresql as

The most comprehensive, exhaustive, parameterized command-line wordle solver.
The most comprehensive, exhaustive, parameterized command-line wordle solver.

Wordle Solver The most comprehensive, exhaustive, parameterized command-line wordle solver. Wordle is a real

Wordle helper: help you print posible 5-character words based on you input

Wordle Helper This program help you print posible 5-character words based on you

PyWordle: A Python-made wordle manual solver

PyWordle: A Python-made wordle manual solver How to use it Start the program with python3 pywordlesolver.py. How it works The program has a simple 5-l

A helper program to play wordle

A helper program to play wordle

A Python-based Wordle solver and CLI player

Wordle A Python-based Wordle solver and CLI player This was created using Python 3.9.7. SPOILER ALERT: the data directory contains spoilers for upcomi

A command line connect 4 game against a minimax agent.

A command line connect 4 game against a minimax agent.

A fantasy life simulator and role-playing game hybrid distributed as CLI, written in Python 3.

Life is Fantasy Epic (LIFE) A fantasy life simulator and role-playing game hybrid distributed as CLI, written in Python 3. This repository will be pro

Owner
Bartek
Bartek
Wordle-cli - Command-line clone of Josh Wardle's WORDLE

Command-line clone of Josh Wardle's WORDLE, inspired by Paul Battley's Ruby vers

Klipspringer 32 Jan 3, 2023
Pyrdle - Play Wordle in the CLI. Write an algorithm to play Wordle for you. Ruin all of the fun you've been having

Pyrdle - Play Wordle in the CLI. Write an algorithm to play Wordle for you. Ruin all of the fun you've been having

Charles Tapley Hoyt 11 Feb 11, 2022
Wordle - Wordle solver with python

wordle what is wordle? https://www.powerlanguage.co.uk/wordle/ preparing $ pip i

shidocchi 0 Jan 24, 2022
Wordle breaker: A CLI tool to help you solve Wordle

Wordle Breaker A CLI tool to help you solve Wordle I decided to code a solution

Alex 4 Apr 27, 2022
Wordle for CLUE - WORDLE clone for Adafruit Clue

Wordle_for_CLUE This project is a clone of the very popular word solving puzzle

Michael Lacock 4 Feb 15, 2022
Play Wordle Bot - Wordle Bot written in python

Wordle Bot A Bot written in python with a CL Interface to guess adn solve Wordle

Prashant 1 Feb 25, 2022
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 cli tool , which shows you all the next possible words you can guess from in the game of Wordle.

wordle-helper A cli tool , which shows you all the next possible words you can guess from the Game Wordle. This repo has the code discussed in the You

null 1 Jan 17, 2022
Play WORDLE game in your terminal.

Wordle TUI Play WORDLE game in your terminal. The game will be kept the same as the Web version. Prerequisites Python 3.7+ Linux/MacOS (Windows is not

Frost Ming 61 Oct 30, 2022
A clone of the popular online game Wordle

wordle_clone A CLI application for wordle. Description A clone of the popular online game Wordle.

null 0 Jan 29, 2022