▶️ Section 15: Final Run & Extension
📝 Full Code Review
This is the complete, finished version of the project. Use it to check your work and fix any misunderstandings about how the pieces fit together.
How to run the finished game:
1. Make sure settings.py, model.py, and app.py are all in the same folder.
2. Run the program with python app.py.
3. Controls: left-click reveals, right-click flags, F2 restarts.
settings.py (constants)
model.py (game logic model)
app.py (Tkinter UI)
😀 Emoji Copy/Paste List
💣🚩🎉💥
🛠 Extensions (Required For Full Credit)
To earn full points, create a new file named Mainfile.Ext.py, copy the final working code into it, and then add at least one extension below.
If you do no extension, the highest score you can earn is a B (2.5/4).
You may do any extension below or propose your own, but check with your teacher first.
Choose at least one:
- Custom Themes: Add a Theme menu with 2+ color palettes (covered/revealed colors, number colors, background). Let the user switch themes without restarting.
- “Chording” Reveal: If a revealed numbered cell has exactly that many flags around it, allow a middle-click (or Shift+Click) to reveal all unflagged neighbors.
- Best Time Tracking: Save best times per difficulty to a text file (or JSON). Show “Best: 42s” in the info bar and update it when the player wins faster.
- Hint Button (Limited Use): Add a “Hint” button that reveals one safe cell (not a mine) up to 3 times per game. Track hints used and display it in the UI.
- First Click Always Opens Area: Expand the safe zone rules so the first click guarantees a zero cell (or guarantees at least a small empty area), not just “not a mine.”
- Right-Click Cycling: Make right-click cycle through blank → flag → question mark → blank (classic Minesweeper behavior).
🧠 Core Concepts List
This project includes (and you should be able to explain) these concepts:
- Constants module (settings.py) and why centralized configuration helps maintainability
- Dictionaries and tuples for presets (DIFFICULTIES)
- Object-oriented programming: classes (Cell, Board, GameApp) and instance variables
- Separating model (game rules) from UI (Tkinter widgets)
- Safe APIs and read-only access with @property
- Building 2D grids (lists of lists) for models and UI widgets
- Neighbor traversal on a grid (8-direction adjacency)
- Delayed initialization (placing mines after the first click)
- Breadth-first search (BFS) flood fill using collections.deque
- Returning “changed coordinates” for efficient UI redraws
- Tkinter layout with Frame, pack, and grid
- Event binding (bind) for mouse/keyboard input
- lambda in loops and capturing values with default arguments (rr=r, cc=c)
- Tkinter StringVar to keep labels updated
- Tkinter timers with after / after_cancel
- End-game state handling, disabling input, and user feedback with message boxes


