diff --git a/Cargo.toml b/Cargo.toml index 6915c1d..7ee46dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,9 @@ keywords = ["wordle", "benchmark"] default-run = "wordlec" [features] -default = ["game", "bench", "tui"] +default = ["game", "bench", "tui", "solvers"] game = [] +solvers = [] tui = ["game"] bench = [] diff --git a/src/game/mod.rs b/src/game/mod.rs index 0226c0d..b32e971 100644 --- a/src/game/mod.rs +++ b/src/game/mod.rs @@ -43,6 +43,38 @@ impl Game { } } +/// Build and Configure a [`Game`] +/// +/// This struct is used to build and configure a [`Game`] of Wordle. +/// +/// ## Examples +/// +/// [`GameBuilder`] implements [`Default`]. [`Game::builder`] uses [`GameBuilder::default`]. +/// You don't need to set custom values if you accept the defaults. +/// +/// ``` +/// # use wordle_analyzer::game::*; +/// # use anyhow::Result; +/// # fn main() -> Result<()> { +/// let game: Game = GameBuilder::default() +/// .build()?; +/// # Ok(()) +/// # } +/// ``` +/// +/// ``` +/// # use wordle_analyzer::game::*; +/// # use anyhow::Result; +/// # fn main() -> Result<()> { +/// let game: Game = Game::builder() +/// .length(5) +/// .precompute(false) +/// .max_steps(6) +/// .build()?; +/// # Ok(()) +/// # } +/// ``` +/// #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct GameBuilder { length: usize, @@ -57,17 +89,30 @@ impl GameBuilder { Ok(game) } - /// Sets the precompute of this [`GameBuilder`]. + /// Should we pre compute all possible answers? This will make startup significantly more + /// expensive, but reduce the computing time while playing. + /// + /// Default is [`false`] pub fn precompute(mut self, precompute: bool) -> Self { self.precompute = precompute; self } - /// Sets the length of this [`GameBuilder`]. + /// Set the length of words for the game + /// + /// Default is [`super::DEFAULT_WORD_LENGTH`] pub fn length(mut self, length: usize) -> Self { self.length = length; self } + + /// Set the amount of guesses per game + /// + /// Default is [`super::DEFAULT_MAX_STEPS`] + pub fn max_steps(mut self, max_steps: usize) -> Self { + self.max_steps = max_steps; + self + } } impl Default for GameBuilder { diff --git a/src/lib.rs b/src/lib.rs index 8226925..0e9ed61 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,5 +7,9 @@ pub const DEFAULT_WORD_LENGTH: usize = 5; /// Default amount of guesses per game pub const DEFAULT_MAX_STEPS: usize = 6; +#[cfg(feature = "game")] pub mod game; +#[cfg(feature = "solvers")] pub mod solvers; +#[cfg(feature = "bench")] +pub mod bench;