Repository navigation
guess-game.py: is the free retry on invalid input a deliberate design choice? #14
|
In try:
guess = int(input("Enter your guess: "))
except ValueError:
print("⚠️ Please enter a valid number! Try again.\n")
continue
guesses_taken += 1
guesses_left -= 1A typo doesn't cost a guess, since |
Replies: 1 comment
|
As written it's a side effect of The case for deliberate: charging a guess for a parse failure is hostile to the player — the game is about guessing numbers, not typing under pressure. The guess budget should count decisions about the number, not keystroke errors. Most guess-the-number implementations and Mastermind-style games don't charge for non-parse input either. The case against: infinite non-loss retries technically let a player grind forever without losing (though they can't win either, so the exploit is harmless), and the behavior is currently implicit — nothing in the code says "this is a rule." So: keep the behavior, make it a rule in the code: except ValueError:
# Deliberate: a typo doesn't cost a guess — only real guesses count.
print("⚠️ Please enter a valid number! Try again.\n")
continueIf you ever want the strict variant (typos cost), the minimal change is moving the decrements above the |
As written it's a side effect of
continueskipping the decrements — but it's a side effect worth keeping, and I'd promote it to a documented design choice.The case for deliberate: charging a guess for a parse failure is hostile to the player — the game is about guessing numbers, not typing under pressure. The guess budget should count decisions about the number, not keystroke errors. Most guess-the-number implementations and Mastermind-style games don't charge for non-parse input either.
The case against: infinite non-loss retries technically let a player grind forever without losing (though they can't win either, so the exploit is harmless), and the behavior is currently implicit — noth…