be even a little more adversarial

This commit is contained in:
ashastral 2022-03-02 19:19:32 -08:00
parent 4dd91ad03c
commit 6a75cd777b

View file

@ -87,7 +87,17 @@ impl<const N: usize> AdversarialEvaluator<N> {
impl<const N: usize> Evaluator<N> for AdversarialEvaluator<N> { impl<const N: usize> Evaluator<N> for AdversarialEvaluator<N> {
fn evaluate(&self, word: Word<N>) -> Matches<N> { fn evaluate(&self, word: Word<N>) -> Matches<N> {
let best_secrets = self.best_secrets(word); let best_secrets = self.best_secrets(word);
return guess(&word, best_secrets.first().unwrap()); let mut secret_with_most_nowheres: Option<Word<N>> = None;
let mut most_nowheres = None;
for secret in best_secrets {
let matches = guess(&word, &secret);
let nowheres = matches.iter().filter(|&m| m == &LetterMatch::NOWHERE).count();
if most_nowheres.is_none() || nowheres > most_nowheres.unwrap() {
most_nowheres = Some(nowheres);
secret_with_most_nowheres = Some(secret);
}
}
return guess(&word, &secret_with_most_nowheres.unwrap());
} }
fn push(&mut self, result: GuessResult<N>) { fn push(&mut self, result: GuessResult<N>) {