mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 07:10:42 -08:00
Merge pull request #613 from AnthonyMichaelTDM/fix-logic-error-in-60_mastermind
fix for potential logic error in 60_Mastermind
This commit is contained in:
@@ -152,7 +152,7 @@ namespace Game
|
|||||||
if (isCandidate[index])
|
if (isCandidate[index])
|
||||||
{
|
{
|
||||||
var (candidateBlacks, candidateWhites) = guess.Compare(candidate);
|
var (candidateBlacks, candidateWhites) = guess.Compare(candidate);
|
||||||
if (blacks != candidateBlacks || whites != candidateWhites)
|
if (blacks > candidateBlacks || whites > candidateWhites)
|
||||||
isCandidate[index] = false;
|
isCandidate[index] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -269,6 +269,8 @@ async function main()
|
|||||||
print("YOU GUESSED IT IN " + m + " MOVES!\n");
|
print("YOU GUESSED IT IN " + m + " MOVES!\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
//tell human results
|
||||||
|
print("YOU HAVE " + b + " BLACKS AND " + w + " WHITES.")
|
||||||
// Save all this stuff for board printout later
|
// Save all this stuff for board printout later
|
||||||
ss[m] = str;
|
ss[m] = str;
|
||||||
sa[m] = [];
|
sa[m] = [];
|
||||||
@@ -341,7 +343,7 @@ async function main()
|
|||||||
copy_hs();
|
copy_hs();
|
||||||
convert_qa();
|
convert_qa();
|
||||||
get_number();
|
get_number();
|
||||||
if (b1 != b || w1 != w)
|
if (b1 > b || w1 > w)
|
||||||
ia[x] = 0;
|
ia[x] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,7 @@
|
|||||||
1035 GOSUB 6500
|
1035 GOSUB 6500
|
||||||
1040 GOSUB 4000
|
1040 GOSUB 4000
|
||||||
1050 GOSUB 4500
|
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
|
1070 NEXT X
|
||||||
1080 NEXT M
|
1080 NEXT M
|
||||||
1090 PRINT "I USED UP ALL MY MOVES!"
|
1090 PRINT "I USED UP ALL MY MOVES!"
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ def main():
|
|||||||
human_readable_possibility, human_readable_guess
|
human_readable_possibility, human_readable_guess
|
||||||
)
|
)
|
||||||
print(comparison)
|
print(comparison)
|
||||||
if (blacks != comparison[1]) or (whites != comparison[2]):
|
if (blacks > comparison[1]) or (whites > comparison[2]):
|
||||||
all_possibilities[i] = 0
|
all_possibilities[i] = 0
|
||||||
if not turn_over: # COMPUTER DID NOT GUESS
|
if not turn_over: # COMPUTER DID NOT GUESS
|
||||||
print("I USED UP ALL MY MOVES!")
|
print("I USED UP ALL MY MOVES!")
|
||||||
|
|||||||
Reference in New Issue
Block a user