This project is a complete Rust implementation of the popular Wordle game, featuring both a command-line interface, a web version, and a powerful solver.
- Classic Wordle: Play the standard 5-letter word guessing game
- Daily Challenge: Play a different word each day
- Random Mode: Play with randomly selected words
- Custom Words: Play with your own chosen word
- Difficult Mode: Enforces stricter rules where you must use revealed letters
- Stats Tracking: Keep track of your wins, losses, and average guesses
- CLI Version: Play directly in your terminal
- Web Version: Play in your browser with a beautiful UI
- Solver: Powerful algorithm to solve any Wordle puzzle
- Configurable word lists
- Save/load game state
- Color-coded feedback (green = correct position, yellow = wrong position, red = not in word)
- Keyboard tracking in web version
- Responsive design for all screen sizes
wordle/
├── wordle/ # CLI game implementation
├── wordle-web/ # Web-based game using Yew framework
├── wordle-solver/ # Advanced Wordle solver
└── openers.json # Precomputed optimal opening moves
- Rust toolchain (latest stable version recommended)
- For web version: Trunk (WebAssembly bundler for Rust)
Install Trunk with:
cargo install trunkClone the repository:
git clone <repository-url>
cd wordlePlay the default game:
cargo runOr explicitly specify the package:
cargo run -p wordleTo run the web version locally:
cd wordle-web
trunk serveThen open your browser to http://localhost:8080.
You can also play the live version at: https://wordle-rust.netlify.app/
Usage: wordle [OPTIONS]
Options:
-w, --word <WORD> Target word to guess
-r, --random Use a random word
-d, --day <DAY> Starting day number [default: 1]
-s, --seed <SEED> Random seed [default: 42]
-D, --difficult Activate difficult mode
-t, --stats Activate stats mode
-f, --final-set <FINAL_SET_PATH> Final words document path
-a, --acceptable-set <ACCEPTABLE_SET_PATH> Acceptable words document path
-S, --state <STATE_PATH> Path to load/save game state
-c, --config <CONFIG_PATH> Path to config file
-h, --help Print help- Guess the 5-letter word in 6 tries
- After each guess, the color of the tiles will change to show how close your guess was:
- 🟩 Green: Correct letter in the correct position
- 🟨 Yellow: Correct letter in the wrong position
- 🟥 Red: Letter not in the word
- In difficult mode, you must use all revealed letters in subsequent guesses
-
Play with a specific word:
cargo run -- -w "rusty" -
Play with a random word:
cargo run -- -r
-
Play with a specific seed for reproducible randomness:
cargo run -- -r -s 12345
-
Play in difficult mode:
cargo run -- -r -D
-
Track statistics:
cargo run -- -r -t
-
Save/load game state:
cargo run -- -r -S game_state.json
The project includes a powerful solver that can solve any Wordle puzzle efficiently.
Run the solver:
cargo run -p wordle-solverFeatures:
- Interactive mode: Enter your guesses and results to get the next best move
- Automated benchmarking: Test solver performance against all possible words
- Precomputed optimal openings for maximum efficiency
You can customize the game using a config file in JSON format:
{
"word": "rusty",
"random": true,
"day": 1,
"seed": 42,
"difficult": false,
"stats": false,
"final_set": "path/to/final_words.txt",
"acceptable_set": "path/to/acceptable_words.txt",
"state": "game_state.json"
}Then run with:
cargo run -- -c config.jsoncargo build --releasecd wordle-web
trunk build --releaseRun all tests:
cargo test -- --test-threads=1Run package-specific tests:
cargo test -p wordle -- --test-threads=1
cargo test -p wordle-web -- --test-threads=1
cargo test -p wordle-solver -- --test-threads=1When running with the -t flag, the game tracks:
- Win/loss ratio
- Average number of guesses per win
- Most frequently used words
You can provide custom word lists using the -f and -a options:
- Final set (
-f): Words that can be the target - Acceptable set (
-a): Words that are valid guesses
Format your word lists with one word per line.
Contributions are welcome! Feel free to submit issues or pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.