
Games::Mines - a mine finding game

require Games::Mines;
# get new 30x40 mine field with 50 mines
my($game) = Games::Mines->new(30,40,50);
# fill with mines, except at the four corners
$game->fill_mines([0,0],[0,40],[30,0],[30,40]);

This module is the basis for mine finding game. It contains the basic methods necessary for a game.
The new method creates a new mine field object. It takes three arguments: The width of the field, the height of the field, and the number of mines.
Returns the width of a mine field.
Returns the height of the mine field.
Returns the total number of mines within the field.
Returns a boolean that says if game play is still possible. Returns false after field is create, but before fill_mines is called. Also returns false if the whole field has been solved, or a mine has been stepped on.
Returns a human readable status of the current game. Mostly useful after a game has ended to say why it has ended.
Randomly fills the field with mines. It takes any number of arguments, which should be array references to a pair of coordinates of where NOT to put a mine.
Returns what is visible at the coordinates given. Takes two arguments: the col and the row coordinates.
Returns a boolean saying if the position has not been stepped on and exposed. Takes two arguments: the col and the row coordinates.
Returns a boolean saying if the position has been stepped on and exposed. Takes two arguments: the col and the row coordinates.
Steps on a particular square, exposing what was underneath. Takes two arguments: the col and the row coordinates. Note that if the particular field is blank, indicating it has no mines in any of the surrounding squares, it will also automatically step on those squares as well. Returns false if already stepped on that square, or if a mine is under it. Returns true otherwise.
Place a flag on a particular unexposed square. Takes two arguments: the col and the row coordinates. Returns true if square can and has been flagged.
Removes a flag from a particular unexposed square. Takes two arguments: the col and the row coordinates. Returns true if square can and has been unflagged.
Returners a boolean based on whether a flag has been placed on a particular square. Takes two arguments: the col and the row coordinates.
Return the total number of flags throughout the whole field.
Returners a boolean saying whether all mines have been found or not.
An internal check to make sure the coordinates given are actually on the field itself. Will truncate to the field limits and values that are no.
This is the method that actually sets up the whole data structure that represents the field, and fills it with the default values. Takes two arguments: The width of the column and row of the coordinates.
Used to add to the numbers surrounding a mine. Normally called from fill_mines to fill the field with the mine counts. Takes two coordinates, the $col and $row coordinates. Assumes there is a mine at the center.
Clears mine field of all bombs, and resets the field to a pre-start state.
It checks to see if a mine should be placed at the the coordinates given. Returns true if it's an acceptable position.
This is a placeholder method for modules that inherit from this one to over ride. Always returns true by default.
It checks to see if a mine field has an acceptable layout. Returns true if it's an acceptable field.
This is a placeholder method for modules that inherit from this one to over ride. Always returns true by default.
Returns what is underneath at the coordinates given, regardless of weather it is uncovered or not. Takes two arguments: the col and the row coordinates.

Martyn W. Peck <mwp@mwpnet.com>

None known. But if you find any, let me know.

Copyright 2003, Martyn Peck. All Rights Reserves.
This program is free software. You may copy or redistribute it under the same terms as Perl itself.