in pseudocode
Code
onClick(ClickedCell){
q = new queue();
q.add(ClickedCell);
while (q not empty){
Cell = q.remove();
cell.showHiddenValue();
cell.markAsProcessed();
if (cell is number){
// do nothing special
} else if (cell is mine){
// lost the game. throw exception or whatever
} else{
// blank. we need to show all its neighbors and repeat this logic
// we are guarenteed none of the neighbors are a bomb.
q.add(cell.getNeighbors());
}
}
}
Something along those lines. make sure getNeighbors doesnt crash on corners/sides and excludes any flagged cells and any cells already marked as processed
/edit: that's probably happening to you, now that i think of it. when you're trying to recurse on your neighbors you're prolly adding back the cell you just processed, so it goes on forever adding each other back.
This post was edited by carteblanche on Apr 9 2013 05:40pm