From eaff44a86a83fc3605168e7e8b89031f0ec2bce0 Mon Sep 17 00:00:00 2001 From: AnthonyMichaelTDM <68485672+AnthonyMichaelTDM@users.noreply.github.com> Date: Mon, 7 Mar 2022 00:35:18 -0800 Subject: [PATCH 1/3] fix for potential logic error --- 60_Mastermind/csharp/Program.cs | 2 +- 60_Mastermind/javascript/mastermind.js | 2 +- 60_Mastermind/mastermind.bas | 2 +- 60_Mastermind/python/mastermind.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/60_Mastermind/csharp/Program.cs b/60_Mastermind/csharp/Program.cs index 13f525d7..596b552d 100644 --- a/60_Mastermind/csharp/Program.cs +++ b/60_Mastermind/csharp/Program.cs @@ -152,7 +152,7 @@ namespace Game if (isCandidate[index]) { var (candidateBlacks, candidateWhites) = guess.Compare(candidate); - if (blacks != candidateBlacks || whites != candidateWhites) + if (blacks > candidateBlacks || whites > candidateWhites) isCandidate[index] = false; } } diff --git a/60_Mastermind/javascript/mastermind.js b/60_Mastermind/javascript/mastermind.js index 40d8139e..454639a0 100644 --- a/60_Mastermind/javascript/mastermind.js +++ b/60_Mastermind/javascript/mastermind.js @@ -341,7 +341,7 @@ async function main() copy_hs(); convert_qa(); get_number(); - if (b1 != b || w1 != w) + if (b1 > b || w1 > w) ia[x] = 0; } } diff --git a/60_Mastermind/mastermind.bas b/60_Mastermind/mastermind.bas index 774c062c..861547a1 100644 --- a/60_Mastermind/mastermind.bas +++ b/60_Mastermind/mastermind.bas @@ -113,7 +113,7 @@ 1035 GOSUB 6500 1040 GOSUB 4000 1050 GOSUB 4500 -1060 IF B1<>B OR W1<>W THEN I(X)=0 +1060 IF B1>B OR W1>W THEN I(X)=0 1070 NEXT X 1080 NEXT M 1090 PRINT "I USED UP ALL MY MOVES!" diff --git a/60_Mastermind/python/mastermind.py b/60_Mastermind/python/mastermind.py index ccc2ae9c..f97705a0 100644 --- a/60_Mastermind/python/mastermind.py +++ b/60_Mastermind/python/mastermind.py @@ -133,7 +133,7 @@ def main(): human_readable_possibility = make_human_readable(numeric_possibility) #4000 comparison = compare_two_positions(human_readable_possibility, human_readable_guess) print(comparison) - if ((blacks != comparison[1]) or (whites != comparison[2])): + if ((blacks > comparison[1]) or (whites > comparison[2])): all_possibilities[i] = 0 if not turn_over: # COMPUTER DID NOT GUESS print("I USED UP ALL MY MOVES!") From 79e53c293bb41c723595d6877c755cb025c316a4 Mon Sep 17 00:00:00 2001 From: AnthonyMichaelTDM <68485672+AnthonyMichaelTDM@users.noreply.github.com> Date: Mon, 7 Mar 2022 00:58:30 -0800 Subject: [PATCH 2/3] while we're at it, fix the javascript port not showed guess results too --- 60_Mastermind/javascript/mastermind.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/60_Mastermind/javascript/mastermind.js b/60_Mastermind/javascript/mastermind.js index 454639a0..6a8b27db 100644 --- a/60_Mastermind/javascript/mastermind.js +++ b/60_Mastermind/javascript/mastermind.js @@ -269,6 +269,8 @@ async function main() print("YOU GUESSED IT IN " + m + " MOVES!\n"); break; } + //tell human results + print("YOU HAVE " + b + " BLACKS AND " + w + " WHITES.") // Save all this stuff for board printout later ss[m] = str; sa[m] = []; From 98f47dfa44b6eec04e1a24b17724e6db37a4c26d Mon Sep 17 00:00:00 2001 From: AnthonyMichaelTDM <68485672+AnthonyMichaelTDM@users.noreply.github.com> Date: Mon, 7 Mar 2022 01:02:09 -0800 Subject: [PATCH 3/3] fix for potential logic error should fix the conflict --- 60_Mastermind/python/mastermind.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/60_Mastermind/python/mastermind.py b/60_Mastermind/python/mastermind.py index f97705a0..cb898615 100644 --- a/60_Mastermind/python/mastermind.py +++ b/60_Mastermind/python/mastermind.py @@ -133,7 +133,7 @@ def main(): human_readable_possibility = make_human_readable(numeric_possibility) #4000 comparison = compare_two_positions(human_readable_possibility, human_readable_guess) print(comparison) - if ((blacks > comparison[1]) or (whites > comparison[2])): + if (blacks > comparison[1]) or (whites > comparison[2]): all_possibilities[i] = 0 if not turn_over: # COMPUTER DID NOT GUESS print("I USED UP ALL MY MOVES!")