Mine Sweeper is a single-player Android and iOS game where the goal is to clear a board of hidden mines without detonating any. Numbers on each square indicate nearby mines to help deduce mine locations. Players reveal squares by clicking and can flag potential mine squares. If a mine is revealed, the player loses, but clearing all non-mine squares without hitting a mine means the player wins. The game was created by maintaining a grid class to track the game state and placing mines randomly on a new 16x16 grid for each game. It recursively opens squares with no nearby mines and ends the game if a mine is clicked or lets the player restart or exit if all mines are found.
More than Just Lines on a Map: Best Practices for U.S Bike Routes
MineSweeper
1. Mine Sweeper (Android / iOS)
Purpose:
A single player Android plus iOS game app. It clears a rectangular board containing hidden "mines" without
detonating any of them, with help from clues about the number of neighboring mines in each field.
How to Play:
The game is played by revealing squares of the grid by clicking or otherwise indicating each square. If a square
containing a mine is revealed, the player loses the game. If no mine is revealed, a digit is instead displayed in the
square, indicating how many adjacent squares contain mines; if no mines are adjacent, the square becomes
blank, and all adjacent squares will be recursively revealed. The player uses this information to deduce the
contents of other squares, and may either safely reveal each square or mark the square as containing a mine.
A flag mark may be placed in an unrevealed square to serve as an aid to logical deduction. Implementations may
also allow players to quickly "clear around" a revealed square once the correct number of mines have been
flagged around it. The game is won when all mine-free squares are revealed, because all mines have been located.
Approach:
Created a class Grid to maintain and check game status.
Created 16*16 Grid and placed mines randomly over grid on start of each new game.
Count number of mines per grid and maintain that in grid object.
Recursively opened the grid if there is no mines immediate nearby.
If mine is clicked to opened, game will be over and provided option to restart game or Exit.
Provided flag option to remember mines.
If all mines is being detected, game will be Won and provided option to restart game or Exit. :
Some Screenshots: