iDevGames Forums
Minesweeper algorithm - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Minesweeper algorithm (/thread-5220.html)



Minesweeper algorithm - Coin - Jul 28, 2005 04:32 PM

Know when you click on a tile that is blank in minesweeper? How it uncovers all the blank tiles and one layer of numbered tiles beyond that? Anyone know how?


Minesweeper algorithm - OneSadCookie - Jul 28, 2005 04:41 PM

Code:
uncovertile(tile)
{
    flip(tile)

    return unless i'm a 0

    for each neighbor_tile
    {
        if neighbor_tile ain't already flipped
        {
            uncovertile(neighbor_tile)
        }
    }
}



Minesweeper algorithm - Cochrane - Jul 29, 2005 01:39 AM

You might want to look at ttp://en.wikipedia.org/wiki/Seed_fill. The code I am using is similar to the second algorithm, but much more bloated and doesn't work correctly, so I think I'm gonna use one of the ones shown there.


Minesweeper algorithm - Coin - Jul 29, 2005 09:48 AM

Thanks both of you.