Battleships
Phase 1 — Core model & rules
Implement a UI-agnostic Battleships model with a fixed-size ship per player. Validate placement, record shots, and detect hits/misses/sunk. Keep turn-neutral logic and simple helpers for board state inspection.
- Grid representation and coordinates
- Single fixed-length ship placement validation
- Track shots; prevent duplicate targeting
- Hit/miss and “sunk” detection helpers
Functional result: A tiny script can place ships for both players, apply shots, and correctly report hit/miss/sunk without any GUI.
Phase 2 — GUI scaffolding & ship placement
Create a Tkinter window with two concealed boards (Player A/B). Guide sequential ship placement with click-and-drag or click+orientation. Provide a simple “Hide screen / Next player” prompt between players to preserve secrecy.
- Tkinter window with two 10×10 grids
- Interactive fixed-length ship placement
- Orientation toggle (horizontal/vertical)
- “Next player” screen to conceal boards
Functional result: Users can place their ships in turn; grids render correctly, placements respect bounds/overlap rules, and boards stay hidden between players.
Phase 3 — Turn-based firing & feedback
Enable alternating turns to fire at the opponent’s grid via mouse clicks. Show immediate visual feedback for hit/miss, disallow firing the same cell twice, and update a concise status area indicating whose turn it is.
- Turn manager (A↔B)
- Click-to-fire on opponent grid
- Mark and lock fired cells (hit/miss)
- Status label for current turn
Functional result: Players alternate firing; hits and misses are marked reliably; duplicate shots are blocked; turn indicator updates correctly.
Phase 4 — Win condition & minimal polish
Stop the game when a ship is fully sunk and show a winner dialog with options to restart or quit.
- Sunk detection triggers end-of-game dialog
- Restart current match (clear boards/state)
- Minimal input validation and safe UI updates
Functional result: Sinking the opponent’s ship ends the match with a clear winner message; pressing restart resets the boards and allows a fresh game.