From f24f83ad64d57c5bb94ddb64e154cae3c745bf3e Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Fri, 22 Mar 2024 15:15:20 +0100 Subject: [PATCH] we have a solver that solves every wordle with enough steps --- src/solve/stupid/mod.rs | 4 ++-- src/wlist/mod.rs | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/solve/stupid/mod.rs b/src/solve/stupid/mod.rs index 5e69298..2637b11 100644 --- a/src/solve/stupid/mod.rs +++ b/src/solve/stupid/mod.rs @@ -12,7 +12,7 @@ impl<'wl, WL: WordList> Solver<'wl, WL> for StupidSolver<'wl, WL> { fn build(wordlist: &'wl WL) -> crate::error::WResult { Ok(Self { wl: wordlist }) } - fn guess_for(&self, game: &crate::game::Game<'wl, WL>) -> Word { - Word::from("hello") + fn guess_for(&self, game: &crate::game::Game) -> Word { + self.wl.rand_word().0 } } diff --git a/src/wlist/mod.rs b/src/wlist/mod.rs index ebc0c26..67c4863 100644 --- a/src/wlist/mod.rs +++ b/src/wlist/mod.rs @@ -23,6 +23,11 @@ pub trait WordList: Clone + std::fmt::Debug + Default { let sol = *self.solutions().iter().choose(&mut rng).unwrap(); (sol.0.to_owned(), sol.1.to_owned()) } + fn rand_word(&self) -> WordData { + let mut rng = rand::thread_rng(); + let w = self.wordmap().iter().choose(&mut rng).unwrap(); + (w.0.clone(), *w.1) + } fn length_range(&self) -> impl RangeBounds; fn amount(&self) -> usize { self.solutions().len()