Minesweeper in Haskell

This page links to a selection of implementations of minesweeper in Haskell. These were written in 2002, and were used as a (personal) case study for refactoring Haskell programs.

Minesweeper is a long-lived and popular computer game, with a plethora of implementations (just `google' for minesweeper). The game is played on a rectangular board divided into a number of squares; beneath some of the squares lie mines. Clicking on a mine loses the game; if there is no mine present, the square is cleared, and the number of mines on adjacent squares is shown. In fact, if the square is unoccupied then the whole mine-free region containing the square is uncovered. The player wins when all the mines are marked, and all other squares are cleared.

ASCII interface

The basic commands for the textual versions are (details below of which version implements which):
 q      Quit
 h      Help information
 m7b    Mark position 7b
 u7b    Unmark position 7b
 r7b    Reveal position 7b
 s7b    Show equations at 7b
 a7b    Automatic turn at 7b
 t7b    Transitive automatic from 7b
These commands should not be followed by a newline/carriage return. Earlier versions require the Hugs extensions.

Graphical interface

The graphical interface is provided using the Haskell Graphics Library and was tested (only) on Windows systems using Hugs. I would welcome feedback on other platforms.

More resources

Planet Minesweeper, the world's most complete online resource for Minesweeper: tips and advices, world rankings, videos, active forum...

Last updated 4 April 2005.