Minesweeper is a classic single-player puzzle game where the player’s objective is to reveal all non-mine cells on a grid without triggering a mine. The game requires logic, deduction, and careful strategy.
0
to 8
indicating how many of its adjacent cells contain mines.0
, all adjacent cells are automatically revealed recursively.In this chapter, we’ll explore the low-level design of a Minesweeper game.
Lets start by clarifying the requirements:
Before starting the design, it's important to ask thoughtful questions to uncover hidden assumptions and better define the scope of the system.
Here is an example of how a conversation between the candidate and the interviewer might unfold:
Candidate: Should the game support different board sizes?
Interviewer: Yes, support configurable board sizes and mine counts.
Candidate: What actions should a player be able to perform on a cell?
Interviewer: Players should be able to reveal a cell, flag a cell as suspected mine, or unflag a flagged cell.
Candidate: Should the first cell the player clicks on always be safe, or can it contain a mine?
Interviewer: Good question. The first click should always be safe. It must never reveal a mine.
Candidate: What happens when a player clicks on a cell with no adjacent mines? Should we auto-reveal surrounding cells?
Interviewer: Yes, if a cell has zero adjacent mines, the game should recursively reveal its neighbors until all non-mine cells with adjacent mines are found.
Candidate: How do we determine game outcomes?
Interviewer: If a player reveals a mine → Game Over. If all non-mine cells are revealed → Player Wins.
Candidate: Is there a time limit or scoring mechanism based on how fast the user completes the board?
Interviewer: You can ignore timer or scoring mechanism for this version.
Candidate: Should we support undo functionality or saving and resuming the game?
Interviewer: Not in this version. Let’s keep the scope limited to a single continuous game session.
After gathering the details, we can summarize the key system requirements.