Merge branch 'master' of https://git.cscherr.de/PlexSheep/wordle-analyzer
cargo devel CI / cargo CI (push) Successful in 39s Details

This commit is contained in:
Christoph J. Scherr 2024-03-21 11:44:03 +01:00
commit 5dba824235
Signed by: cscherrNT
GPG Key ID: 8E2B45BC51A27EA7
2 changed files with 12 additions and 10 deletions

View File

@ -4,7 +4,7 @@ pub struct Game {
precompute: bool,
max_steps: usize,
step: usize,
solution: String
solution: String,
}
impl Game {
@ -24,14 +24,15 @@ impl Game {
/// # Errors
///
/// This function will return an error if .
pub(crate) fn build(length: usize, precompute: bool, max_steps: usize) -> anyhow::Result<(Self)> {
let mut game = Game {
length, precompute, max_steps,
pub(crate) fn build(length: usize, precompute: bool, max_steps: usize) -> anyhow::Result<Self> {
let _game = Game {
length,
precompute,
max_steps,
step: 0,
solution: String::default() // we actually set this later
solution: String::default(), // we actually set this later
};
// TODO: load wordlist of possible answers
// TODO: select one as a solution at random
// NOTE: The possible answers should be determined with a wordlist that has the
@ -79,14 +80,14 @@ impl Game {
pub struct GameBuilder {
length: usize,
precompute: bool,
max_steps: usize
max_steps: usize,
}
impl GameBuilder {
/// build a [`Game`] with the stored configuration
pub fn build(self) -> anyhow::Result<Game> {
let game: Game = Game::build(self.length, self.precompute, self.max_steps)?;
Ok(game)
let game: Game = Game::build(self.length, self.precompute, self.max_steps)?;
Ok(game)
}
/// Should we pre compute all possible answers? This will make startup significantly more
@ -120,7 +121,7 @@ impl Default for GameBuilder {
Self {
length: super::DEFAULT_WORD_LENGTH,
precompute: false,
max_steps: super::DEFAULT_MAX_STEPS
max_steps: super::DEFAULT_MAX_STEPS,
}
}
}

View File

@ -0,0 +1 @@