Minesweeper

The Game

Minesweeper is easiest to learn by playing. For a good, if somewhat unstable, implementation, check out xmine (ie: type "xmine" in a shell). Minesweeper consists of a 2-dimensional grid of squares. Each square is originally covered; under some squares there are mines. When you uncover a square with a mine under it, you lose. When you uncover a square that doesn't have a mine under it, the game displays the number of mined squares adjacent to the current square (a number from 0 to 8). If this number is zero, the game must perform the uncover operation on all squares adjacent to it. A user flags a square to indicate that she thinks that there is a mine underneath the square. When all the squares on the board which are not mines have been uncovered, the player has won the game. A ``power-feature'' of Minesweeper that many are unaware of is the ability to check a square. When the user checks an uncovered square, and there are as many flagged squares adjacent to the checked square as there are mines (i.e., the player believes she has found all the mines adjacent to this checked square), the game performs the uncover operation on all the unflagged squares adjacent to the square. If there are more or less flagged squares adjacent to the checked square than mines, or if the player checks a square that is covered, nothing happens. This all sounds pretty complicated, but playing with it in xmine or the demo will clarify what we mean. In order to check a square in xmine, middle-click on it. Minesweeper supports varying dimensions for the board; the larger the board, the more difficult the game. The game has an 8 x 8 beginner level; a 16 x 16 intermediate level; and a 16 x 30 advanced level.

Your Game

You must implement your Minesweeper either with a text-only interface or using GP. Your Minesweeper must allow the user to uncover, flag, and check squares. Your game must implement all three levels of difficulty, and allow the user to choose which level to play. You must provide some textual way for the user to represent their commands. You're free to use any input format for commands that makes sense. Be sure to document your choices well enough in your README for us to test your code.

Design Check

We will be expecting you to turn in a design check for this program. Minesweeper does not have an overly complex design, but you should get into the habit of designing the entirety of a program before you start coding it. We expect from you a neatly written paper handin of the design for your program, comprised of a class diagram and list of important methods of classes. Additionally, a description of the flow of control of the program is required. You are not required to use OMT or Rational Rose for this handin. The important thing is that it is neat and readable.

Also, keep in mind that if the design takes you one day to do, you don't have to (and should not) wait until after the design handin date to start coding. If you wish to talk to a TA about your design before you start writing code, come see one during TA hours.