Minesweeper
 |
Minesweeper
Moves: 12 Flags: 7/12 0:57
1 2 3 4
5 6 7 8 9 0
A:
1 @ 2 1
B:
1 2 3 @
C:
1 @ 2
D:
1 1 1
E: 1 1 2
1 1
1 1
F: 1 @ 2
@ 2 1 2 2 @
G: 1 - -
- - - - - -
H: 1 2 - - -
- - 3 1 1
I: 1 @ - - -
- - 1
J: 1 2 - - -
- - 1
--------------------------------
1)Restart 2)New 3)Hall 4)Peek 5)Cheat 6)Quit
7)Prefs
|
Note: The Edit menu is replaced by Preferences, and the title bar
should display the name of the plugin.
The goal of Minesweeper is to find all the hidden bombs in a
two dimensional grid. At the start of the game the grid is
completely filled with hidden squares. Click on a square to
reveal the contents. If you click on a square containing a
bomb, you lose. The goal is to uncover all the squares that
don't contain a bomb as fast as possible.
When you click on a square which doesn't have a bomb, numbers in
squares next to unrevealed squares will indicate how many bombs
are adjacent to it. For example, if an empty square has a 2 in it,
there are 2 bombs adjacent to it.
When you click on an empty square that has no bombs next to it,
all the adjacent empty squares are revealed.
A right mouse button click will toggle a "flag" image on and off
to allow the player to mark squares that are suspected
bombs. In the console version, preface the move with a
period to indicate a right mouse click, e.g., ".A3"
The status panel displays the number of moves made, flags placed,
and time elapsed in minutes and seconds. In the GUI version
the time updates automatically every second. In the console
version, the time is updated when the board is redisplayed.
The Restart menu item begins the same game over again.
New Game starts a different game.
Hall (of Fame) opens a dialog showing the top five saved winning
times (ordered from fastest to slowest).
The Hall of Fame entry dialog:
If the player loses, the squares are all revealed.
|
Minesweeper
Moves: 0 Flags: 0/10 0:05
1 2 3
4 5 6 7 8 9 0
A:
1 1 1
B: 1 2 2 2
1 1 B 3 2 1
C: * 2 B B
1 1 2 B B 2
D: 1 2 2 2
1 1 3 B 2
E:
1 2 2
F:
1 B
G:
1 1 1 1 1
H:
1 B
1
I:
1 2 2 1
J:
1 B 1
--------------------------------
1)Restart 2)New 3)Hall 4)Peek 5)Cheat 6)Quit
7)Prefs
|
Note that the bomb that was clicked on is shown as exploded.
When you click an empty cell, it recursively reveals all the other
adjacent empty cells, until it gets to one that is numbered. For
example, the screenshot below shows a board after only one move -
clicking on the lower left corner (an "empty" cell).
|
Minesweeper
Moves: 1 Flags: 0/10 0:03
1 2 3
4 5 6 7 8 9 0
A: - - - -
- - - - - -
B: - - - -
- - - - - -
C: - - - -
1 1 2 - - -
D: 1 2 2 2
1 1 3 - -
E:
1 2 -
F:
1 -
G:
1 1 1 1 1
H:
1 -
1
I:
1 2 2 1
J:
1 - 1
--------------------------------
1)Restart 2)New 3)Hall 4)Peek 5)Cheat 6)Quit
7)Prefs
|
Note that a click on a cell that contains a number does NOT perform
this recursive reveal action.
There is a Peek function that reveals the entire board, which is of
course only for people of low moral stature.
To facilitate testing, there is a Cheat function that clears the
entire game board except for two tiles in the upper left corner (but
doesn't win the game). The left-most tile hides a bomb, and
the right-most tile hides a "1". If the user clicks on the
right-most tile, the square is revealed and they win.
(Clicking on the bomb loses the game as expected). If the user
cheats and wins (or loses) and then clicks cheat again, the tiles
show up again.
The Preferences menu operates as specified in project 2. For
the console user interface, Preference options are labeled with
alphabetic characters. (You can assume there won't be more
than 26 options). The current setting is indicated with all
caps.
|
[Board Size]
(a) SMALL = 8 (b) medium =
10 (c) large = 12
[Difficulty]
(d) easy = 8 (e) MODERATE =
6 (f) hard = 4
Your choice?
|
The first option in each category is the default when the games
starts.
In the console version, the user enters the letter associated with
an option. You may assume the user will enter only one letter
in each category, e.g., "bf" selects medium - hard. If no
choice is made in a category, the first option is used as the
default. You may assume the user will enter only valid
letters.
Note that after the preferences dialog closes, the game is restarted
with the selected preferences. No warning or confirmation
dialog is provided.
In the console version, for 10x10 and 12x12 boards, the input must
allow selecting a column with a two-digit value. So "A10" is a
valid move.
GUI Menu Accelerator Keys:
Restart Alt+R, New Alt+N, Hall Alt+H, Peek Alt+P, Cheat Alt+C,
Quit Alt+Q, Prefs Alt+F
The console menu has a hidden "0" choice that clears the hall of
fame. There is no corresponding menu in the GUI.
Allowed anomalies
If you place a flag on a cell that subsequently gets cleared, the
flag counter may not decrement to account for this.
Design/Implementation Constraints
The graphical UI must not contain any output to the console
(System.out.print).
The "preferences.ini" and hall of fame files are stored in the
plugin directory.
Downloads & Resources
Kaboom piece images: KaboomImages.zip
(You may make your own alternate images).
Background: Restrict image file size to 256K.
Frequently Asked Questions
Q: How do I get the location of a right mouse click?
A: Try this:
if (SwingUtilities.isRightMouseButton(ev))
{
row = (int) (ev.getPoint().getY()/cellHeight);
col = (int) (ev.getPoint().getX()/cellWidth);
Q: If you press cheat, does that mean it just shows the solution
and gets rid of anything you've flagged, etc?
A: It gets rid of anything you've flagged, because flags only appear
on hidden cells, and cheating reveals all the hidden cells.
Q: For the game timer, is there any specific way you recommend
this to be implemented?
A: Yes, I recommend a Swing Timer.
http://java.sun.com/products/jfc/tsc/articles/timer/
Q: I'm looking through the docs, the video and the pictures; I'm
not seeing how many flags I should allow for. I see one picture
with 8, one with 7, and one with 9.
A: There's really no limit to how many flags someone can place.
Well, except until every square on the board is flagged :)
I think what you are seeing in the documentation is the count of the
number of bombs on the board.
Q: Is the styling on a number in
the display examined by the tests?
A: No.
Q: Is it possible for there to be more/less than 3 options per
section of the preferences?
A: Yes.
Last modified on 11/24/2015 22:52:03