feat(web): add solver output
This commit is contained in:
@@ -151,6 +151,31 @@ impl Solver {
|
||||
SolverJob { receiver: rc }
|
||||
}
|
||||
|
||||
pub fn evaluate_all_words_cb<F>(&self, progress: F) -> Result<Vec<WordStats>, String>
|
||||
where
|
||||
F: Fn(usize, usize) + Send + Sync + 'static,
|
||||
{
|
||||
let mut completed = 0;
|
||||
let mut result = self
|
||||
.valid_words
|
||||
.words()
|
||||
.map(|w| {
|
||||
let r = self.evaluate_word(w);
|
||||
completed += 1;
|
||||
progress(completed, self.valid_words.len());
|
||||
r
|
||||
})
|
||||
.collect::<Result<Vec<WordStats>, String>>();
|
||||
|
||||
if let Ok(result) = &mut result {
|
||||
result.sort_by(|a, b| {
|
||||
a.expected_score_after_guess
|
||||
.total_cmp(&b.expected_score_after_guess)
|
||||
});
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
pub fn evaluate_all_words(&mut self) -> Result<Vec<WordStats>, String> {
|
||||
let mut best_words: Vec<WordStats> = self
|
||||
.valid_words
|
||||
|
||||
Reference in New Issue
Block a user