Off by one error in for/range. Previously if the computer chose a secret code of zero (all blacks) it would skip initialization entirely and the player would not be able to finish the puzzle. Alternatively, if the computer chose the highest secret code (e.g. all Red in a three color puzzle), the actual secret code would be initialized to one less (RRW).

This commit is contained in:
Joe Nellis
2022-04-24 17:39:03 -07:00
parent 9ce5c9bb23
commit bacad32a61

View File

@@ -46,7 +46,7 @@ def main() -> None:
print("Guess my combination ...")
answer = int(possibilities * random.random())
numeric_answer = [-1] * num_positions
for _ in range(0, answer):
for _ in range(0, answer + 1):
numeric_answer = get_possibility(numeric_answer)
# human_readable_answer = make_human_readable(numeric_answer, color_letters)
while num_moves < 10 and not turn_over: