Learn breakpoint debugging with a simple, visual bug
A Snake game with an intentional bug that's perfect for learning VS Code debugging. The bug is simple: the snake passes over food without eating it. Use breakpoints to find why!
- Set breakpoints โ Pause code execution at specific lines
- Inspect variables โ See
headvsnew_headvsfood_posin real-time - Find the bug โ Discover why a simple variable mix-up breaks the game
- Use GitHub Copilot โ Ask AI to explain the code and suggest fixes
- Open in VS Code
- Click "Reopen in Container" when prompted
- Everything is pre-configured: extensions, settings, dependencies โ
git clone https://github.com/chkp-ai-transformation/debug-demo.git
cd debug-demo
pip install -r requirements.txtRequired VS Code Extensions:
- GitHub Copilot
- GitHub Copilot Chat
- Python (ms-python.python)
- Python Debugger (ms-python.debugpy)
- Debug MCP Extension
Press F5 and select a configuration:
| Configuration | Description |
|---|---|
| ๐ Snake: Manual Mode | Play with arrow keys |
| ๐ค Snake: Auto-Player | Watch the AI play |
| ๐ Debug: Step Through Auto-Player | Best for debugging |
python src/main.py --manual # Play manually
python src/main.py --auto # Watch AI playSymptom: The snake moves over the red food dot but doesn't eat it. Score stays at 0, food never moves.
What's wrong: The food collision check has X and Y coordinates swapped - a classic copy-paste bug!
# Bug: compares (snake_x, snake_y) with (food_y, food_x)
if (new_head[0], new_head[1]) == (self.food_pos[1], self.food_pos[0]):Your challenge:
- Set a breakpoint in
snake.pyat the food collision check - Watch
new_headandself.food_posin the debugger - Notice the X/Y swap in the comparison!
๐ See DEBUGGING_GUIDE.md for a step-by-step walkthrough.
debug-demo/
โโโ .devcontainer/ # Pre-configured dev container
โโโ .vscode/launch.json # Debug configurations
โโโ .github/skills/ # Copilot debugging skill
โโโ src/
โ โโโ main.py # Entry point
โ โโโ snake.py # Game logic (bug is here!)
โ โโโ auto_player.py # AI pathfinding
โ โโโ web_game.py # Browser version
โโโ DEBUGGING_GUIDE.md # Step-by-step tutorial
โโโ requirements.txt
| Mode | Controls |
|---|---|
| Manual | Arrow keys to move, R to restart, ESC to quit |
| Auto | D to toggle debug info, R to restart, ESC to quit |
- DEBUGGING_GUIDE.md โ Complete debugging tutorial
- VS Code Debugging Docs
MIT License
