Minesweeper

This project is my implementation of the classic puzzle game Minesweeper. The objective of the game is to flag the locations of all of the bombs and clear the entire board. Numbered tiles give the player a clue as to how many bombs there are in the immediate vicinity. If the player clicks on a bomb instead of flagging it, the game ends. Once all of the tiles are either flagged or overturned, the player wins!

Motivation

In my second year of college, long hours in the library with my friends led, for some reason, to many games of Minesweeper as a way to get some breaks from studying. Multiple games later trying to beat each others' scores and I decided I wanted to try my hand at implementing my own version of Minesweeper.

Implementation

My implementation of Minesweeper has 3 different levels of difficulty: Beginner, Intermediate, and Expert. The player has the option to choose between these at the start of each game, and each level of difficulty represents a much higher jump in game board size than the previous one, and consequently an increased time of completion.

I wanted to make sure that the same starting board isn't created each game, and that, like all Minesweeper games, the initial tiles get set after the user clicks on the board. When writing the code for the initial click event, I guaranteed that an area of blank tiles, surrounded by 1 layer of numbered tiles, would always be deployed in a different pattern. This especially helps with replayability, and gives the player a new challenge each game.

As play progresses, the player must flag each bomb location. Of course, it wouldn't make sense for them to be able to flag the entire board, so the number of flags available corresponds to the number of bombs on the board. A flag count and timer in the top left of the board keep track of the flags that have been placed and the time the player has been playing the game. If a bomb is clicked on or if the player successfully flags all of the bombs, then the game ends and the player is given the option to either quit the application or start a new game.

The source code for this project can be found on my GitHub, if you'd like to check out in more depth how I went about implementing my Minesweeper game.

Conclusion

Working on this project was really fun, although it did present some interesting challenges, such as creating that initial, random starting board after the player chooses where they want to begin. It also introduced me to the Java Graphical User Interface, which was satisfying to get a hang of. And of course, completing the project and having my own Minesweeper game to play at the library was awesome too! :)