Crate rs_wordle_solver
source ·Expand description
Provides tools to algorithmically select the answer to a game of Wordle.
§Quick start
§Solving a game in one function
use rs_wordle_solver::*;
// Construct a WordBank to select guesses from.
let bank = WordBank::from_iterator(&["abc", "bcd", "def"])?;
// Construct a guesser.
let guesser = RandomGuesser::new(bank);
// Play the game.
let max_number_of_guesses = 3;
let objective = "bcd";
let result = play_game_with_guesser(objective, max_number_of_guesses, guesser);
assert!(matches!(result, GameResult::Success(_guesses_made)));
§Solving a game interactively
use rs_wordle_solver::*;
// Construct a WordBank to select guesses from.
let bank = WordBank::from_iterator(&["abc", "bcd", "def"])?;
// Construct a guesser.
let mut guesser = RandomGuesser::new(bank);
// Take a guess
let objective = "abc";
let guess = guesser.select_next_guess().unwrap();
// Get the results
let results = get_result_for_guess(objective, &guess)?;
// Update the guesser
guesser.update(&results)?;
// Repeat!
let guess = guesser.select_next_guess().unwrap();
// ...
§Solving algorithms
See the implementations of Guesser
for more information on the available guessing
algorithms.
If you want to implement your own algorithm, the easiest place to start is likely by
implementing the scorers::WordScorer
trait, and using this with MaxScoreGuesser
. There
are additional helpful utilities for implementing your own algorithms in the details
mod.
Modules§
- Internals and other things that may be useful if you want to implement your own Wordle solving algorithms.
- Scorers for determining which word is the best guess.
Structs§
- The data from a game that was played.
- The result of a single word guess.
- Selects the next guess that maximizes the score according to the owned scorer.
- Guesses at random from the possible words that meet the restrictions.
- Represents a guess with a ‘score’ estimating how useful the guess is. Higher scores are better.
- Data about a single turn of a Wordle game.
- Contains all the possible words for a Wordle game.
Enums§
- Whether the game was won or lost by the guesser.
- Indicates which set of words to guess from. See
MaxScoreGuesser::new()
. - The result of a given letter at a specific location. There is some complexity here when a letter appears in a word more than once. See
GuessResult
for more details. - Indicates that an error occurred while trying to guess the objective word.
Traits§
- Guesses words in order to solve a single Wordle.
Functions§
- Determines the result of the given
guess
when applied to the givenobjective
. - Attempts to guess the given word within the maximum number of guesses, using the given word guesser.