generated from PlexSheep/rs-base
match fix false negative in game
cargo devel CI / cargo CI (push) Successful in 42s
Details
cargo devel CI / cargo CI (push) Successful in 42s
Details
This commit is contained in:
parent
d101d7ddf9
commit
da9a7cd036
|
@ -94,7 +94,7 @@ impl<'wl, WL: WordList> Game<'wl, WL> {
|
||||||
for (idx, c) in guess.chars().enumerate() {
|
for (idx, c) in guess.chars().enumerate() {
|
||||||
if compare_solution.chars().nth(idx) == Some(c) {
|
if compare_solution.chars().nth(idx) == Some(c) {
|
||||||
status = Status::Matched;
|
status = Status::Matched;
|
||||||
compare_solution = compare_solution.replace(c, "_");
|
compare_solution.replace_range(idx..idx+1, "_");
|
||||||
} else if compare_solution.contains(c) {
|
} else if compare_solution.contains(c) {
|
||||||
status = Status::Exists;
|
status = Status::Exists;
|
||||||
compare_solution = compare_solution.replacen(c, "_", 1);
|
compare_solution = compare_solution.replacen(c, "_", 1);
|
||||||
|
|
|
@ -35,7 +35,9 @@ impl<'wl, WL: WordList> Solver<'wl, WL> for NaiveSolver<'wl, WL> {
|
||||||
.get_words_matching(pattern)
|
.get_words_matching(pattern)
|
||||||
.expect("the solution does not exist in the wordlist")
|
.expect("the solution does not exist in the wordlist")
|
||||||
.iter()
|
.iter()
|
||||||
|
// only words that have not been guessed yet
|
||||||
.filter(|p| !game.made_guesses().contains(&&p.0))
|
.filter(|p| !game.made_guesses().contains(&&p.0))
|
||||||
|
// only words that contain the letters we found earlier (that were not matched)
|
||||||
.filter(|p| {
|
.filter(|p| {
|
||||||
// TODO: don't repeat unmatched contained chars on the same position twice #2
|
// TODO: don't repeat unmatched contained chars on the same position twice #2
|
||||||
let mut fits = true;
|
let mut fits = true;
|
||||||
|
|
Loading…
Reference in New Issue