Tech News
← Back to articles

Making Explainable Minesweeper

read original related products more articles

šŸŽ®Game 🧩Puzzle šŸ’£Minesweeper šŸ¤–Algorithm šŸ’»Game Dev

Background

I recently purchased and played a game called 14 Minesweeper Variants during a Steam Summer sale. It was a fun game. However, I became curious while looking at the hints provided in the game. What exactly are these?

Actually, when I played Minesweeper, which was a default Windows game, I could solve cases where there was a definite answer, but I remember stepping on countless mines in ambiguous situations. For example, situations like this:

The numbers 1 and 2 indicate the number of mines in each cell’s 8 neighbors (up, down, left, right, and diagonals). Empty cells mean there are no mines in their neighbors. However, in situations like the image above, it’s not easy to figure out which squares have mines and which don’t. It’s also difficult to accurately guess the mine locations because there are too few mines.

50/50 Situations

Let’s look at this situation. This image is from this source, and it’s exactly a 50/50 probability. There’s 1 mine left, and whichever of the two remaining squares you choose, there’s a chance it could be a mine.

This situation occurs due to Minesweeper’s map generation algorithm. The original Minesweeper usually doesn’t let you step on a mine on your first click. This is because it places mines in locations other than the square the user selects on their first click. Since mines are placed at that moment, it can’t perform enough calculations to prevent 50/50 situations. When I experimented, finding boards solvable only through logical deduction required about 250,000 attempts per level on a 9x9 board with 33 mines.

Situations Where Deduction is Possible

However, there’s a common mistake that beginners like my past self often make. They think it’s a 50/50 situation and leave it to luck when deduction is actually possible! The 14 Minesweeper Variants I mentioned earlier provides hints for such situations. Let’s go back to the previous image:

... continue reading