Back to Projects

Minesweeper

Jan 03, 2023

Picture of a battle in my game Random Fate

I made this Minesweeper game for a college class while I was getting my software engineering degree.

The assignment was to make a simple Minesweeper game with a grid of buttons (Minesweeper tiles) and when you click a tile, It should go through it's neighbors see how many mines each neighbor has next to them and display that number on the neighbor. It also had to have a scoring system and a reset button.

It showed us how to make algorithms to look at the nearby neighbors, to see if it was a mine and get the correct nearby mine count. It also taught me how to turn a visual 2D grid into an array so I could manipulate it through code.

I also added the recurisive clearing of no-mine neighbors. So when you click one tile with no-mine neighbors, it also acts as if you "clicked" any of it's neighboring tiles with no-mine neighbors clearing them and it's neighbors with no-mine neighbors also get "clicked", creating a sort of chaining effect (I know there's a lot of neighbors, huh, Imagine having to code it). Quickly I also made it so right-click would add a flag icon just like the normal Minesweeper game.

Both of these weren't required for the assignment but I wanted my Minesweeper game to actually BE Minesweeper. As well the chaining effect gave me a lot of practice with recursive functions and showed me just how useful they can be.


Follow Me