Skip to content

Fix consecutive-wins bug in solution#17

Open
XueyanZhang wants to merge 1 commit into
spiside:masterfrom
XueyanZhang:fix-solution-runner
Open

Fix consecutive-wins bug in solution#17
XueyanZhang wants to merge 1 commit into
spiside:masterfrom
XueyanZhang:fix-solution-runner

Conversation

@XueyanZhang
Copy link
Copy Markdown

Problem

runner.consecutive_wins += 1

consecutive_wins is never initialized.
The first time the player guesses correctly, the reference solution
crashes with:

AttributeError: 'GameRunner' object has no attribute 'consecutive_wins'

Fix

  • Track consecutive wins with a local consecutive_wins variable in
    run() (initialized to 0), removing the broken instance attribute.
  • Roll the dice each round so the game state actually changes between
    rounds. (I'm not sure if not re-rolling is intentional — happy to revert this if so.)

- remove uninitialized `runner.consecutive_wins` attribute
- roll the dice each round
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant