The Oz Minesweeper

Raphaël Collet (raph@info.ucl.ac.be)

After two or three clicks Done in 15 seconds! Uh!  Too many mines!

The game

This application looks like the usual minesweeper game. The playing field is a grid of squares, each of which may hide a mine. The total number of mines is given when the game starts. The objective is to find out where they are located. The rules are:
  1. You uncover a square by clicking on it. If you explode a mine, the game is over. Otherwise, the number in the square gives the number of adjacent mines.
  2. You mark a square as a mine by clicking on it with the middle button of your mouse. This helps to visualise your knowledge about the field.
  3. You win the game when all the non-mined squares have been uncovered. To help you, a counter in the window indicates the number of remaining squares to be uncovered.

The digital assistant

This application is definitely more than the usual minesweeper game. The checkbuttons under the mine field (see screenshots) enable/disable modules of a digital assistant. The latter is a software component that augments the knowledge about the hidden mine field. Briefly, the modules are:
Autoplay
This module automatically uncovers the squares that are known safe.
Zero propagation
The module implements the following inference rule: if a square is uncovered and shows a ``0'', then all the squares around it are known safe. It is the simplest form of intelligence for this game. Usual implementations of the game never provide more than this.
Constraints
This one uses the power of constraint programming in Oz. It implements the general rule: if a square is uncovered and shows number x, then x squares around it are mined. The module propagates lots of information and automatically marks squares as safe (with a ``-'') or mined (with a ``X''). When used in conjonction with Autoplay, it is able to uncover large parts of the game field. The module also provides a search tool: if you click on a square with the right button of the mouse, the assistant searches for the common part of all the solutions of the mine field around the target square. The searched part is the squares at the frontier between the known and unknown squares, of which the target square is a member.
The assistant is called intelligent thanks to the latter module. This is because it is able to solve nontrivial problems.

Try it!

You first need to install The Mozart Programming System version 1.2.0 and enable Oz applets in your internet browser. Read the Installation Manual to make the whole thing. Then launch Minesweeper.oza!

The source files are:

This Site vi powered