From f745dad4b2d1149df4c358aea450ae928189527b Mon Sep 17 00:00:00 2001 From: AnthonyMichaelTDM <68485672+AnthonyMichaelTDM@users.noreply.github.com> Date: Fri, 29 Apr 2022 11:18:17 -0700 Subject: [PATCH] Rust: update comparison logic to follow README.md will likely refactor this project later --- 60_Mastermind/README.md | 2 +- 60_Mastermind/rust/src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/60_Mastermind/README.md b/60_Mastermind/README.md index 2e74ed1c..7820eed7 100644 --- a/60_Mastermind/README.md +++ b/60_Mastermind/README.md @@ -28,7 +28,7 @@ As published in Basic Computer Games (1978): Downloaded from Vintage Basic at http://www.vintage-basic.net/games.html -###How the computer deduces your guess. +### How the computer deduces your guess. The computer takes the number of black pegs and white pegs that the user reports and uses that information as a target. It then assumes its guess is the answer diff --git a/60_Mastermind/rust/src/main.rs b/60_Mastermind/rust/src/main.rs index afe1802d..2c31f4c0 100644 --- a/60_Mastermind/rust/src/main.rs +++ b/60_Mastermind/rust/src/main.rs @@ -324,7 +324,7 @@ fn main() { all_possibilities.iter_mut().enumerate().for_each(|b| { if *b.1 { //filter out ones we already know aren't possible let mut tmp_guess = GUESS::new(CODE::new_from_int(b.0, num_colors, num_positions)); - tmp_guess.evaluate(&answer); + tmp_guess.evaluate(&guess.code); //compare with computer guess if blacks != tmp_guess.blacks || whites != tmp_guess.whites { //if number of blacks/whites is different, set it to false *b.1 = false; }