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 Streamlit guessing game where the user tries to guess a secret number within a range. The app provides hints and tracks score and attempts.
- ✅ Bugs found: The hint messages were inverted (it said "Go HIGHER" when the guess was too high and "Go LOWER" when it was too low). The new-game reset ignored difficulty range and always picked a number between 1 and 100.
- ✅ Fixes applied: Refactored game logic into
logic_utils.py, corrected the hint direction incheck_guess(), ensuredNew Gameresets the secret number using the selected difficulty range, and added tests to validate the behavior.
- ✅ Tested in the running app: The hint now correctly says "Go LOWER" when the guess is too high and "Go HIGHER" when the guess is too low.
- ✅ Challenge 1 (Edge-Case Testing): Added tests for decimal input, large numbers, and negative guesses to ensure edge inputs are handled gracefully.
- [ X Add a screenshot here showing the
pytestcommand output with all tests passing.- Tip: run
pytest -qand take a screenshot of the terminal output (or use a snipping tool).
- Tip: run
- [If you choose to complete Challenge 4, insert a screenshot of your Enhanced Game UI here]
