You asked an AI to build a simple "Number Guessing Game" using Streamlit. It wrote the code, ran away, and now the game is unplayable.
- You can't win.
- The hints lie to you.
- The secret number seems to have commitment issues.
- Install dependencies:
pip install -r requirements.txt - Run the broken app:
python -m streamlit run app.py
- Play the game. Open the "Developer Debug Info" tab in the app to see the secret number. Try to win.
- Find the State Bug. Why does the secret number change every time you click "Submit"? Ask ChatGPT: "How do I keep a variable from resetting in Streamlit when I click a button?"
- Fix the Logic. The hints ("Higher/Lower") are wrong. Fix them.
- Refactor & Test. - Move the logic into
logic_utils.py.- Run
pytestin your terminal. - Keep fixing until all tests pass!
- Run
-
Game purpose: A number guessing game where the player tries to guess a secret number within a set number of attempts. The difficulty setting controls the range and attempt limit. Each wrong guess deducts points; winning awards points based on how quickly you guessed.
-
Bugs found:
- New Game button did not reset the game after a win or loss — the game stayed frozen and new guesses were not registered
- Hint direction was reversed — guessing too high showed "Go HIGHER" and guessing too low showed "Go LOWER"
- Switching difficulty did not update the displayed guess range — it was hardcoded to "1 and 100"
- Attempt counter started at 1 instead of 0, making it always 1 ahead of reality
- Score increased by 5 on even-numbered wrong guesses instead of always subtracting
- Developer debug panel showed stale values from the previous turn instead of the current one
-
Fixes applied:
- Added
status = "playing"andhistory = []resets to the New Game block so the game fully restarts - Swapped the hint messages in
check_guessso Too High says "Go LOWER" and Too Low says "Go HIGHER" - Replaced hardcoded
"1 and 100"in the info banner with dynamic{low}and{high}variables - Changed the initial value of
attemptsfrom1to0 - Removed the even/odd condition in
update_scoreso wrong guesses always subtract 5 points - Moved the Developer Debug Info expander to after the submit logic so it reflects the current turn
- Added
- [If you choose to complete Challenge 4, insert a screenshot of your Enhanced Game UI here]
