Skip to content

Instantly share code, notes, and snippets.

@rkasbach
Last active August 29, 2015 14:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rkasbach/6dad2e33d9a175fdd6e6 to your computer and use it in GitHub Desktop.
Save rkasbach/6dad2e33d9a175fdd6e6 to your computer and use it in GitHub Desktop.
Game steps:
* When the game starts, the player gets prompted for the grid size (width x height) and the number of mines.
* The grid is generated according to these requirements.
* The games starts, the user is prompted for the coordinates (x, y) of the first cell to uncover.
* The game shows the resulting grid and prompts for new coordinates.
* And so on ...
The game ends when there is no more non-mined cell to uncover or the player uncovers a mine.
Rules:
* Uncover a mine, and the game ends.
* Uncover an empty cell, and the player keeps playing.
* In each empty uncovered cell the number of adjacent cells holding mines is displayed.
* Uncovering a cell holding the number '0' (=no adjacent mined cells) uncovers all adjacent cells, and so on.
Notes:
Command-line is sufficient, no fancy ui needed.
Basically it's the good old windows minesweeper (minus flags).
@micheleorsi
Copy link

I need a clarification regarding the rules.
The 4th one says "Uncovering a cell holding the number '0' (=no adjacent mined cells) uncovers all adjacent cells, and so on". The requirement is intended to be recursive, right?

To clarify better: if a cell has no mine around it will uncover all adjacent cells and for every cells uncovered with no mine all the adjacent cells will be uncovered in the same step. This process is stopped as soon a cell with at least one mine around is uncovered. Is this right?

I am going to use this one http://minesweeperonline.com to refresh my memory.

Thanks

@micheleorsi
Copy link

Here is my implementation:
https://github.com/micheleorsi/minesweeper

I tried to use at best the design patterns along the full project. On the other hand I was a bit in a rush at the end and "MainApplication" is the only part a bit 'quick & dirty' ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment