Skip to content

ali8hsn/wordle-ai

Repository files navigation

Wordle AI

A Python implementation of Wordle with a built-in AI solver. The AI analyzes letter feedback to narrow down the secret word and make intelligent guesses each round.

Features

  • WordleAI — solver that uses green/yellow/gray feedback to eliminate candidates
  • get_feedback() — generates a feedback string comparing a guess to the secret word
  • guess() — returns the best next guess given prior guesses and feedback
  • Full unit test suite included

Requirements

  • Python 3.10+
  • colorama (for color output)

Quick Start

# 1. Clone the repo
git clone https://github.com/coscoo/wordle-ai.git
cd wordle-ai

# 2. Install dependencies
pip install -r requirements.txt

# 3. Run the AI solver
python WordleAI.py

Running Tests

# Test the feedback logic
python -m unittest test_1_WordleAI_get_feedback.py -v

# Run the AI profiler (plays many games, measures performance)
python -m unittest test_2_WordleAI_profiler.py -v

How the Feedback System Works

Each guess returns a 5-character feedback string:

Character Meaning
Uppercase letter (e.g. A) Correct letter, correct position (green)
Lowercase letter (e.g. a) Correct letter, wrong position (yellow)
- Letter not in the word (gray)

Examples:

get_feedback("LEVER", "LOWER")  →  "L--ER"
get_feedback("lever", "EATEN")  →  "-e-E-"
get_feedback("MOMMY", "MADAM")  →  "M-m--"

Project Structure

wordle-ai/
├── WordleAI.py               # AI solver (get_feedback + guess logic)
├── Wordle.py                 # Wordle game class
├── wordle_secret_words.py    # List of valid secret words
├── valid_wordle_guesses.py   # List of all valid guesses
├── test_1_WordleAI_get_feedback.py   # Unit tests for feedback logic
├── test_2_WordleAI_profiler.py       # Performance profiler
└── requirements.txt

License

MIT

About

Python Wordle game with an AI solver that uses letter feedback to guess the secret word

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages