Please see my comment to the question. Who knows what are you trying to do int this code? — but it's no wonder it goes nowhere.
This game is a similar
Cellular Automaton, and a very simple one. Please see:
http://en.wikipedia.org/wiki/Cellular_automaton[
^].
You need to define the set of cells. In this simple case of finite set with square cells, a simple array of rank 2, X by Y, will do just fine. The value of each array element should carry a current
state of the cell: a mine present or not, reveled or not, flag is set or not, etc. As the state is the fundamental notion of the Cellular Automaton, the state should be one distinct type of object.
Then you should define what is a set of the
neighborhood. As this is a distinct and fundamental notion of the Cellular Automaton, it's the best to put the definition of the neighborhood set in one discrete function. A function returning the list of cell coordinates would do just fine.
After this step, define the rules for each step of a player, who can eventually loose, discover an mine-free cell, etc. As each rule is very simple and only involves the number of neighboring cells in certain state, the central algorithm of this simple game is also very simple: obtain the
neighborhood set (see above) and then simply iterate through it counting the cells in certain state (having a mine). You also need to implement clearing of the mine-free area automatically based on logical inference. You will need to develop some iteration cycle which should finish when all possibilities for inference are
exhausted.
Let's summarize it:
<il>Definition of the set of all cells, also called world.
<il>Definition of the cell state.
<il>Definition of the neighborhood.
<il>Definition of the rule for checking up a cell; implementation based on the iteration through the neighborhood.
<il>Application of the rule and transition between the states of a cell probed by a player.
<il>Main player cycle.
<il>Automatic clean up of the mine-free area based on logical inference.
If you through out ad-hoc approach and apply this regular approach, your work will go smoothly.
—SA