Expand description
§wordle_rs
WARNING: this project is still unstable, so minor updates may break backwards incompatibility.
Have you ever gotten so obsessed with Wordle that you wanted to evaluate different strategies programmatically? If so, you’re in the right place.
This crate is a part of the wordle_rs project, which has three parts:
wordle_rs, a library with tools you can use to write and evaluate your own Wordle strategies,wordle_strategies, a library demonstrating a few strategies that I wrote, andwordle_runner(WIP), a command line program that can run and compare Wordle strategies written withwordle_rs.
Please feel free to contribute your own strategies to wordle_strategies!
§Using wordle_rs to write a strategy
Add the following to your Cargo.toml:
[dependencies]
wordle_rs = "0.2.0"Then, define a new struct and implement the Strategy trait for it.
use wordle_rs::Strategy;
struct MyCoolStrategy;
impl Strategy for MyCoolStrategy {
// snip
}Then, configure and run the test harness on your strategy.
You can see how to do this below.
You can also use wordle_runner to run your strategy for you, though this is still a work in progress.
§Running strategies from wordle_strategies
To run a pre-made strategy (possibly against your own!), first add the following to your Cargo.toml:
[dependencies]
wordle_rs = "0.2.0"
wordle_strategies = "0.2.0"Then, import a strategy and run the wordle_rs test harness on your strategy.
§Running the wordle_rs test harness
Simply import the harness and configure it to run the strategies that you want to test.
You can add strategies from any location, including those that you write yourself.
The Harness::add_strategy method accepts anything that implements the Strategy trait.
use wordle_rs::{harness::Harness, WordleError};
use wordle_strategies::Common;
fn main() -> Result<(), WordleError> {
let harness = Harness::new()
.add_strategy(Box::new(Common), None)
.test_num(10);
let perfs = harness.run()?;
perfs.print_report()?;
Ok(())
}§Using wordle_runner
Forthcoming.
§Crate level documentation for wordle_rs
§Examples
Examples of how to build your own strategies are available in the
wordle_strategies folder in this repository, which contains the code for
the crate of the same name.
§Build features
The wordle_rs crate supports disabling some non-crucial functionality, allowing it to build without some major dependencies.
Here are the features and their effects:
serde*: allows serializing and deserializing performance records and includes mechanisms for loading and saving baselinesstats*: enables statistical comparisons between performance recordsfancy*: enables fancy display with colors, progress bars, and tablesparallel*: allows running the test harness in parallel
*: enabled by default
§License
Everything in this project is licensed under the MIT license.
Modules§
- harness
- The test harness for running Wordle strategies.
- perf
- Evaluating and comparing strategies.
- strategy
- Tools for defining Wordle strategies.
- words
- The wordlists used by Wordle.
Structs§
- Attempts
- A collection of attempts to solve a Wordle puzzle.
- Attempts
Key - A key provided to
Strategy::solve()to produceAttempts. - Comparison
- A comparison between two
Summarys. - Harness
- A test harness that can run many strategies on many puzzles.
- Perf
- A record of one strategy’s guesses after run by the test harness.
- Print
Options - Configurable options that control printing performance records.
- Puzzle
- A specific Wordle puzzle to solve.
- Record
- A record produced by the test harness of a particular run.
- Summary
- A summary of a strategy’s performance generated by the test harness.
- Word
- A Wordle word.
Enums§
- Grade
- A Wordle “grade” that indicates the correctness of a letter in a guess.
- Harness
Error - The errors that the “harness” side of this crate can produce.
- Puzzle
Error - The errors that the “puzzle” side of this crate can produce.
- Wordle
Error - The errors that
wordle_rscan produce.
Traits§
- Strategy
- Trait defining a Wordle strategy.
Type Aliases§
- Result
- A convenient redefinition of
std::result::Resultthat usesWordleErroras the error type.