Skip to content

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wordle Game Implementation

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.

🎯 Features

Game Modes

  • 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

Platforms

  • 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

Advanced Features

  • 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

📁 Project Structure

wordle/
├── wordle/          # CLI game implementation
├── wordle-web/      # Web-based game using Yew framework
├── wordle-solver/   # Advanced Wordle solver
└── openers.json     # Precomputed optimal opening moves

🚀 Getting Started

Prerequisites

  • Rust toolchain (latest stable version recommended)
  • For web version: Trunk (WebAssembly bundler for Rust)

Install Trunk with:

cargo install trunk

Installation

Clone the repository:

git clone <repository-url>
cd wordle

▶️ Running the Game

CLI Version

Play the default game:

cargo run

Or explicitly specify the package:

cargo run -p wordle

Web Version

To run the web version locally:

cd wordle-web
trunk serve

Then open your browser to http://localhost:8080.

You can also play the live version at: https://wordle-rust.netlify.app/

🎮 Game Usage

CLI Options

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

Game Rules

  1. Guess the 5-letter word in 6 tries
  2. 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
  3. In difficult mode, you must use all revealed letters in subsequent guesses

Examples

  1. Play with a specific word:

    cargo run -- -w "rusty"
  2. Play with a random word:

    cargo run -- -r
  3. Play with a specific seed for reproducible randomness:

    cargo run -- -r -s 12345
  4. Play in difficult mode:

    cargo run -- -r -D
  5. Track statistics:

    cargo run -- -r -t
  6. Save/load game state:

    cargo run -- -r -S game_state.json

🧠 Wordle Solver

The project includes a powerful solver that can solve any Wordle puzzle efficiently.

Run the solver:

cargo run -p wordle-solver

Features:

  • 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

🔧 Configuration

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.json

🏗️ Building

CLI Version

cargo build --release

Web Version

cd wordle-web
trunk build --release

🧪 Testing

Run all tests:

cargo test -- --test-threads=1

Run 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=1

📊 Statistics

When running with the -t flag, the game tracks:

  • Win/loss ratio
  • Average number of guesses per win
  • Most frequently used words

🛠️ Custom Word Lists

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.

🤝 Contributing

Contributions are welcome! Feel free to submit issues or pull requests.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages