← All projectsAIT Mobile / Software

Minesweeper for Android

An Android Minesweeper game built with Kotlin and Jetpack Compose.

Minesweeper on Android with an opened area, adjacent-mine counts, and remaining hidden cells
The Kotlin app running on an Android emulator. Revealing an empty cell opens its connected neighborhood. View full size (new tab): Minesweeper on Android with an opened area, adjacent-mine counts, and remaining hidden cells

A board drawn on Canvas

The game uses a 5 × 5 board with three mines. A single Compose Canvas draws the checkerboard tiles, numbers, mines, and flags. Tap coordinates are converted into a row and column; a long press selects the flag action. The ViewModel holds the board and game state, while the activity draws the current state.

A safe first move

Mines are placed only after the first tap, excluding that selected square. The game then calculates each cell’s neighboring-mine count. The timer starts with that first reveal and stops when the game ends.

Unopened five-by-five Minesweeper board with three flags remaining and timer at zero
Before the first tap: the board is covered, the timer is stopped, and no mines have been placed. View full size (new tab): Unopened five-by-five Minesweeper board with three flags remaining and timer at zero

Revealing an area

If a revealed cell has no neighboring mines, a recursive flood fill visits its neighbors. Already revealed cells and board boundaries stop recursion; numbered cells are revealed but do not expand further. The captured game shows the open area produced by this rule.

Winning, losing, and restarting

The assignment has two win conditions: reveal all 22 safe cells or flag all three mines. Revealing a mine loses the game, and flagging a safe cell also ends it. At the end, the app reveals every mine and shows a result dialog. Further board input is ignored until New Game resets the board and timer.

Mithun RameshkumarDartmouth College