I had a version working which had logic along the following lines:
If a tile is clicked,it's coordinates are passed to the recursive(reveal) function.The function checks all 8 surrounding tiles and passes each tile that has no surrounding mines back to the recursive(well not really recursive,but it does call itself :p)And so in turn each surrounding tile will be checked in this manner.
So I have 2 options(one of which might not be valid):
2-Could someone please give me a functional algorithm to do so?I've googled it,but I only came across a Java game that had very heavy syntax(ternary operators everywhere!)and minesweeper solving algorithms.
That sounds like the condition for ending the recursion isn't being triggered (or the condition isn't correct). For each tile you should only recurse for adjacent tiles that have not been checked yet after the last click. So you need to keep track of which tiles have been checked already, regardless of whether the result was to reveal them or not.
Ping & DNS - updated with new look and Ping home screen widget
Yes,there is no base case to stop the recursion..I can't think of the criteria that need to be meet for recursion to stop.I tried to do what you say but then the result that I get is that only the 8 surrounding tiles get revealed....ie.they have all been marked as checked resulting in them not being checked again.
The revealed tiles sort of form a barrier:
In this case no further tiles can/will be checked .... Another solution that I investigated was performing a check on 8 compass directions...resulting in a star shape,but the further away that the revealing stops the bigger the gaps of unchecked tiles that occur ie:
Joined: Mar 22, 2005
Each recursive call should in turn check its 8 surrounding tiles. Of those, either 3 (for a NW/NE/SW/SE tile) or just 1 (for a W/N/S/E tile) should trigger further recursions - assuming those tiles are still covered, and that they haven't been marked checked by previous calls.