we have a solver that solves every wordle with enough steps
cargo devel CI / cargo CI (push) Successful in 40s Details

This commit is contained in:
Christoph J. Scherr 2024-03-22 15:15:20 +01:00
parent 5ef63d4147
commit f24f83ad64
Signed by: cscherrNT
GPG Key ID: 8E2B45BC51A27EA7
2 changed files with 7 additions and 2 deletions

View File

@ -12,7 +12,7 @@ impl<'wl, WL: WordList> Solver<'wl, WL> for StupidSolver<'wl, WL> {
fn build(wordlist: &'wl WL) -> crate::error::WResult<Self> { fn build(wordlist: &'wl WL) -> crate::error::WResult<Self> {
Ok(Self { wl: wordlist }) Ok(Self { wl: wordlist })
} }
fn guess_for(&self, game: &crate::game::Game<'wl, WL>) -> Word { fn guess_for(&self, game: &crate::game::Game<WL>) -> Word {
Word::from("hello") self.wl.rand_word().0
} }
} }

View File

@ -23,6 +23,11 @@ pub trait WordList: Clone + std::fmt::Debug + Default {
let sol = *self.solutions().iter().choose(&mut rng).unwrap(); let sol = *self.solutions().iter().choose(&mut rng).unwrap();
(sol.0.to_owned(), sol.1.to_owned()) (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<usize>; fn length_range(&self) -> impl RangeBounds<usize>;
fn amount(&self) -> usize { fn amount(&self) -> usize {
self.solutions().len() self.solutions().len()