Object-Oriented Design: Minesweeper with Per-Cell Mine Probabilities
Context
Design an object-oriented Minesweeper game. The board is a grid of cells. On initialization, each cell is given a probability prob that it contains a mine. The system should use these probabilities to generate the mine layout and initialize cell states deterministically when needed (for testing) and randomly otherwise.
Assume prob can be provided as either:
-
A single scalar applied to all cells, or
-
A 2D grid of probabilities (same shape as the board).
Requirements
-
Explain how the per-cell probabilities are used to generate the initial mine layout and initialize cell states.
-
Define the core classes (e.g., Game, Board, Cell), their responsibilities, relationships, and public APIs to:
-
(a) print the current board state
-
(b) process a user click
-
Specify expected state transitions for a click at a high level (lose on mine; otherwise reveal logic handled by standard Minesweeper algorithms).
-
Describe handling of invalid or duplicate clicks.
-
Explain how the design supports maintainability and testing.