Generate fun minesweeper boards

Table of Contents

1 Description

Generate minesweeper boards, automatically solve then, score them based on fun-ness, show user the board with the highest score.

Fun-ness score is high for moves that require multiple pieces of information. Score is negative for boards that require guessing to solve.

Try: Fun Minesweeper

Example of a fun minesweeper board that can be solved without guessing:

github: https://github.com/danamlund/funminesweeper

2 History

  • 9 May 2019: Initial

3 Fun

A fun minesweeper move is difficult and does not require guessing.

A difficult minesweeper move is one that require multiple pieces of information.

A piece of information is a numbered block and its neighboring free, dug or flagged blocks.

We can find fun moves by:

  1. Automatically solve a minesweeper board but only look at every numbered block one at a time.
  2. If/when no more moves can be found this way, we run the automatic solver again but looking at every pair of numbered blocks.
  3. If 2. finds moves they are fun because they cannot be solved by any single numbered block but can be solved by looking at two numbered blocks.
  4. If we cannot find moves from pairs of numbered blocks we can try with all 3-tuples of numbered blocks, and so on.
  5. If we cannot automatically find a valid move, we have found an anti-fun board that require guessing, so we discard it.

To ensure users and the automatic solver see the same board, we start boards by mining the largest area of 0 blocks. Otherwise users first click could result in a different board that is not fun.

A fun minesweeper board is one with many fun moves and no anti-fun moves.

4 Legend

  • Light-grey: free block.
  • Dark-grey: dug block without mine. Number indicate number of neighboring mines. No number indicate zero neighboring mines.
  • Flag: block marked as having a mine.
  • Mine: mined block with a mine, game over.
  • Pink: whether block is used by the auto-solver.
  • Bottom text: Total number of mines, mines left, and time spent solving this board.

5 Controls

  • Left-click: dig for a mine.
  • Right-click: toggle flag.
  • Right-click (on a numbered block): toggle auto-solver based on that blocks information. The numbers on free blocks indicate the percentage of a mine on that block.
  • r (click the 'r' key): reset the board.

Follow the try link to see more controls.

6 Moves that require 1 piece of information

This is an example of a simple not fun move. The middle block tell us there is one neighboring mine, and the left flag tell us that is where the mine is. So we know that the right block cannot be a mine.

The "piece of information" is the middle block.

7 Moves that require 2 pieces of information

Looking at each 1-block and its neighbors does not reveal a valid move.

But from the left 1-block we know that either the 1st and 2nd free have a mine. Combine that with the middle 1-block we know that the 3rd free cannot have a mine because there is only 1 neighboring mine and it must be in the 1st or 2nd free block.

8 Moves that require 3 pieces of information

Explaining in text why a move is valid based on many pieces of information is difficult, so that is up to you.

A good approach to reasoning about valid moves is to use the auto-solve. You can toggle various numbered blocks (right-click) to include them in the auto-solve calculation. This lets you see which blocks are needed to find a valid move and which are not. You can also try to find different sets of pieces of information to find different methods of finding the same or similar valid moves.

9 Moves that require 4 pieces of information

This gets too complicated to be fun in my opinion.

10 Moves that require information about mines remaining

When we take into account the number of mines not found we can sometimes find more valid moves.

In the first simple example we know that the middle is a mine. But since that is the only mine, we also know that the right block is not a mine.

11 Moves that require >4 pieces of information

You can design a board so you need any finite number of blocks to make a move because minesweeper is turing-complete.

But it was not easy finding an example of a board that require 4 piece of information from just randomization. If you can think of an easy approach to design a board that require x pieces of information to make a move, I would love to hear about it.

12 Fun guessing

A fun guess is one where the highest-probability of being a mine/not a mine is the true guess. The auto-solver could be extended to only mark boards as anti-fun if any guess with less than eg. 80% of being a mine is not actually a mine.

But calculating all probabilities of all free blocks is difficult to do and might not be considered fun.

13 See also

14 Scratch

I used this section to auto-solve all boards given a width, height, and number of mines to find small examples of boards that require specific kinds of information. It finds all boards by trying all combinations of mine placements. I did not try all combinations of mined/flagged blocks, which would give better examples. And I did not trim away mirrored boards that are equivalent.

Currently it shows all boards 3x3 boards with 2 mines that require 2 pieces of information to solve.

Author: Dan Amlund Thomsen

Created: 2019-05-17 Fri 13:00

Validate