Skip to content

Commit

Permalink
Merge pull request #732 from AnthonyMichaelTDM/fixes_for_Mastermind
Browse files Browse the repository at this point in the history
Fixes to Rust version of Mastermind
  • Loading branch information
coding-horror authored May 4, 2022
2 parents d7be02e + 12e6bc0 commit 9a582ed
Show file tree
Hide file tree
Showing 8 changed files with 518 additions and 4 deletions.
2 changes: 1 addition & 1 deletion 60_Mastermind/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "rust"
name = "mastermind"
version = "0.1.0"
edition = "2021"

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -378,7 +378,6 @@ fn print_board(guesses: &Vec<GUESS>) {
for guess in guesses.iter().enumerate() {
println!("{}\t{}\t\t{}\t{}", guess.0,guess.1.code._as_human_readible_chars(),guess.1.blacks,guess.1.whites);
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "mastermind_refactored_for_conventions"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rand = "0.8.5"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)

Conversion to [Rust](https://www.rust-lang.org/) by Anthony Rubick [AnthonyMichaelTDM](https://github.com/AnthonyMichaelTDM)
Loading

0 comments on commit 9a582ed

Please sign in to comment.