Algorithm for minesweeper problem

People, i really need your help with algorithmic problem. I am trying to make the minesweeper solver. As you know there are 2 ways to determine which fields in minefield are safe to open, or to determine which fields are mined and you need to flag it. First way to determine is trivial and as you know we have something like this:

X - field

if (number of mines around X – current number of discovered mines around X) = number of unopened fields around X then
All unopened fields around X are mined

if (number of mines around X == current number of discovered mines around X) then
All unopened fields around X are NOT mined

But my question is: This is just first way to determine mined fields and safe fields. What about situation when we can't find any mined or safe field and we need to look at more than 1 field?

http://www.minesweeper.info/wiki/images/e/e2/Pattern121.PNG

For example this situation. We can't determine anything using previous method. So i need a help with algorithm for these cases.
The way I think now, each field has a container of valid mine configurations:
1
2
3
4
5
6
7
8
9
10
11
//Something like this for a field with one mine
{{1,0,0, 0,0,0, 0,0,0}
,{0,1,0, 0,0,0, 0,0,0}
,{0,0,1, 0,0,0, 0,0,0}

,{0,0,0, 1,0,0, 0,0,0}
,{0,0,0, 0,0,1, 0,0,0}

,{0,0,0, 0,0,0, 1,0,0}
,{0,0,0, 0,0,0, 0,1,0}
,{0,0,0, 0,0,0, 0,0,1}};


Then given a container of possible mines, returns if that container is valid.
Topic archived. No new replies allowed.