generated from PlexSheep/rs-base
naive filters matches
cargo devel CI / cargo CI (push) Successful in 42s
Details
cargo devel CI / cargo CI (push) Successful in 42s
Details
we can actually win some games in 6 steps with this
This commit is contained in:
parent
2c8b9d903c
commit
41676e9a23
|
@ -1,5 +1,5 @@
|
|||
use crate::error::*;
|
||||
use crate::wlist::word::{Word, WordData};
|
||||
use crate::wlist::word::{ManyWordDatas, ManyWordsRef, Word, WordData};
|
||||
use crate::wlist::WordList;
|
||||
|
||||
use libpt::log::debug;
|
||||
|
@ -139,6 +139,10 @@ impl<'wl, WL: WordList> Game<'wl, WL> {
|
|||
pub fn wordlist(&self) -> &WL {
|
||||
self.wordlist
|
||||
}
|
||||
|
||||
pub(crate) fn made_guesses(&self) -> ManyWordsRef {
|
||||
self.responses.iter().map(|r| r.guess()).collect()
|
||||
}
|
||||
}
|
||||
|
||||
/// Build and Configure a [`Game`]
|
||||
|
|
|
@ -67,7 +67,7 @@ impl GuessResponse {
|
|||
&self.evaluation
|
||||
}
|
||||
|
||||
pub fn guess(&self) -> &str {
|
||||
pub fn guess(&self) -> &Word {
|
||||
&self.guess
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use libpt::log::info;
|
||||
|
||||
use crate::wlist::word::Word;
|
||||
use crate::wlist::word::{ManyWordDatas, Word};
|
||||
use crate::wlist::WordList;
|
||||
|
||||
use super::{AnyBuiltinSolver, Solver, Status};
|
||||
|
@ -26,11 +26,15 @@ impl<'wl, WL: WordList> Solver<'wl, WL> for NaiveSolver<'wl, WL> {
|
|||
}
|
||||
}
|
||||
}
|
||||
game.wordlist()
|
||||
let matches: ManyWordDatas = game
|
||||
.wordlist()
|
||||
.get_words_matching(buf)
|
||||
.expect("the solution does not exist in the wordlist")[0]
|
||||
.0
|
||||
.clone()
|
||||
.expect("the solution does not exist in the wordlist")
|
||||
.iter()
|
||||
.filter(|m| !game.made_guesses().contains(&&m.0))
|
||||
.map(|v| v.to_owned())
|
||||
.collect();
|
||||
matches[0].0.to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ pub type Frequency = f64;
|
|||
// PERF: Hash for String is probably a bottleneck
|
||||
pub type Word = String;
|
||||
pub type WordData = (Word, Frequency);
|
||||
pub type ManyWords<'a> = Vec<&'a Word>;
|
||||
pub type ManyWordsRef<'a> = Vec<&'a Word>;
|
||||
pub type ManyWordDatas = Vec<(Word, Frequency)>;
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
Loading…
Reference in New Issue