WOW! Very, very cool 😃
I have a few points on it though. If you could make two extra images, on for the bombs and one for the "safe" so that the board doesn't suddenly jump when you hit a bomb. It's a little confusing the first time it happens and it makes it a little difficult to see how the board was layed out. Also, when you complete a column or a row it shrinks to the width/height of the text, it would be nice if you could force the width and height so that these stay constant.
Possible Next Steps: I'm sure you've thought of these already but just in case.
1. Ability to set dimentions and number of mines
2. Timer
3. Not quite so obvious this one but maybe a little fun. The nature of your storage method makes it incredibly easy to have stored boards. You could have some pre-stored ones which come up every now and then (they'd have to be bigger), prehapse the mines spell out a word, or draw a face?
4. Does the board have to be square? It wouldn't require a big change in your algorithm to find out how well it works.
5. You could Ajax it to prevent that little flicker when the page reloads. I'd say this might be quite a nice topical exercise as it would look pretty good on a CV to have a nice slick Ajax app, even if it is a game.
I'd never tried to write a minesweeper app before but I'd never have imagined the algorithm was so simple. I've done it with a loop below but just for fun really, it's no better and will in fact have to do one more check (and the loops as well). It checks the cell which was clicked but we know it's not a bomb so we know it won't cause a problem.
for($i1=$row-1, $c1=$row+1; $i1<=$c1; $i1++) {
for($i2=$col-1, $c2=$col+1; $i2<=$c2; $i2++) {
if(@substr($rows[$i1][$i2], 0, 1) == 'b') $bCount++;
}
}
One last thing, commenting :rolleyes:
Awesome little app though, I love it.