Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to Rust version of Mastermind #732

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)