add panic if solution space is empty
This commit is contained in:
@@ -5,7 +5,9 @@ use wordle_solver::{game::Game, solver::Solver, word_list::WordList};
|
|||||||
pub fn main() {
|
pub fn main() {
|
||||||
let valid_words = WordList::from_file(Path::new("valid-words.txt")).unwrap();
|
let valid_words = WordList::from_file(Path::new("valid-words.txt")).unwrap();
|
||||||
let target_words = WordList::from_file(Path::new("answers.txt")).unwrap();
|
let target_words = WordList::from_file(Path::new("answers.txt")).unwrap();
|
||||||
let mut game = Game::new(target_words.random_word());
|
let target_word = target_words.random_word();
|
||||||
|
println!("Target: {}", target_word);
|
||||||
|
let mut game = Game::new(target_word);
|
||||||
|
|
||||||
let mut solver = Solver::new(valid_words, target_words);
|
let mut solver = Solver::new(valid_words, target_words);
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ impl Solver {
|
|||||||
let information_gained = self.possible_solutions.equal_likelieness_entropy()
|
let information_gained = self.possible_solutions.equal_likelieness_entropy()
|
||||||
- new_possible_solutions.equal_likelieness_entropy();
|
- new_possible_solutions.equal_likelieness_entropy();
|
||||||
|
|
||||||
|
if new_possible_solutions.len() == 0 {
|
||||||
|
panic!("Solution space is empty");
|
||||||
|
}
|
||||||
|
|
||||||
self.possible_solutions = new_possible_solutions;
|
self.possible_solutions = new_possible_solutions;
|
||||||
|
|
||||||
self.guesses.push(Guess {
|
self.guesses.push(Guess {
|
||||||
|
|||||||
Reference in New Issue
Block a user