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.
- WordleAI — solver that uses green/yellow/gray feedback to eliminate candidates
get_feedback()— generates a feedback string comparing a guess to the secret wordguess()— returns the best next guess given prior guesses and feedback- Full unit test suite included
- Python 3.10+
- colorama (for color output)
# 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# 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 -vEach 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--"
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
MIT