46

How would someone go about doing this? Assume that the first "click" will never be a bomb, and that the number of mines and the area are both known. Rather hoping there is a clever way to do this, but I will not be so surprised if there isn't.

EDIT: I would assume (though without any real proof) that a program could be written that could solve minesweeper in linear time (as the board gets bigger linearly, if the mines/area ratio stays the same).

It would seem to me that in general no more than 9 blocks need to be considered (the high end of what i've see playing minesweeper at expert) to determine if

  1. its a mine
  2. its a safe square
  3. the odds that its a mine

That would support my earlier assertion.

EDIT 2: This would also seem to contradict the fact that minesweeper is NP complete, and with probably not so much work one (maybe even I, but probably not) could write an algorithm that can play a perfect game of minesweeper that would have a linearly increasing runtime which would contradict (summery of) the paper here. So I guess this raises the next question which is: where is the flaw in my logic?

EDIT 3: I really am more interesting in the odds than in the algorithm to solve minesweeper. And it would be helpful to me if someone could explain why the number of checks/tests/calculations one has to do does not rise linearly with respect to area.

soandos
  • 1,756
  • 2
    This might be of use to you. I've not read it personally. http://web.mat.bham.ac.uk/R.W.Kaye/minesw/ordmsw.htm – Austin Mohr Jun 01 '11 at 03:13
  • Its very interesting, but since I want to know a simpler piece of information (what are the odds, not what algorithm will get me those odds) is it possible? – soandos Jun 01 '11 at 03:20
  • @saondos: I have deleted my answer. I apologize for the oversimplification. – JavaMan Jun 01 '11 at 03:27
  • 1
    @DJC not a problem, every piece of input is appreciated. – soandos Jun 01 '11 at 03:32
  • Knowing a non 0/1 probability of a mine being present doesn't help you to solve minesweeper. That's why it's not linearly solvable. – trutheality Jun 01 '11 at 05:34
  • It does (calculate this for all available squares. If none are zero, then guessing is a must anyway, and this way the program can pick the lowest) , and two, I just want to know the odds of it being beaten with perfect play.
  • – soandos Jun 01 '11 at 06:09
  • And as a not so significant aside, people can do this pretty quickly with simple logic for a decently large sized board (expert) without making mistakes, so I am not sure what the author of the paper was talking about when he said all solvers are slow... – soandos Jun 01 '11 at 06:45
  • 2
    @soandos: Go to the link that Austin Mohr provided for you, and read it. The Minesweeper Decision Problem is NP-complete. The assumption in your first edit is simply wrong. – TonyK Jun 01 '11 at 07:36
  • My question is why though. (I do know what NP means, but it would seem to me (not that means a lot) that since one only has to consider a relatively constant number of blocks to advance, then as the grid gets bigger, this process has to be done more times. But not some power more, just linearly more) – soandos Jun 01 '11 at 07:39
  • 1
    I can't see why picking the square least likely to contain a mine should be the best play. It might be that some other square is more dangerous but (if you survive) more likely to give information allowing you to proceed without guesswork. – Chris Eagle Jun 01 '11 at 09:05
  • @Chris Eagle Agreed, I guess I was hasty. So the conclusion is that its basically impossible to figure out? – soandos Jun 01 '11 at 11:51
  • @soandos: sigh No -- the conclusion is that it is NP-complete to figure out. – TonyK Jun 03 '11 at 17:45
  • @soandos: Your assumption that it is enough to look around a constant number of squares is incorrect. Look at this pdf: http://web.mat.bham.ac.uk/R.W.Kaye/minesw/minesw.pdf. – Aryabhata Jul 15 '11 at 17:30
  • @Aryabhata, Thank you. I realize this is stupid, but it "seems" that given a number of mines, and the area, it should be possible to determine the odds of winning with perfect play. To actually do the perfect play is not the way to go about it, but in the aggregate, I was hoping for some clever way. – soandos Jul 17 '11 at 02:02
  • I have a minesweeper solver that is quite fast and it uses Matrix mathematics to solve the deterministic part of minesweeper. You can find my post here: http://robertmassaioli.wordpress.com/2013/01/12/solving-minesweeper-with-matricies/ I am going to start working on the probabilities and statistics involved in the game soon. I'll write more information on that blog if I work anything more out. And, as @soandos mentions, minesweeper solvers are fast, my solver can play 100000 expert games in less than a minute and a half on my computer. – Robert Massaioli Jan 16 '13 at 03:42
  • @RobertMassaioli thanks, and would appreciate any updates – soandos Jan 16 '13 at 04:48
  • Intermediate level gives a higher expectation of winning the game. In some games there are required guesses. I have played $754$ games and won $618$ of them or $82.2%$. My longest winning streak is $14$ games and longest losing streak is $3$ games, (played $17$ won $14 = 82.4%$). I recognize the basic patterns ($1,2,1; 1,2,2,1;$ etc) but may miss larger patterns. I play carefully and lose by making the wrong guess rather than a blunder. Does this mean anything more than I have reached my own expectation of winning? –  Feb 22 '13 at 08:29
  • I have written a quick program to play minesweeper. It doesn't play perfectly (there are still a couple of tricks I haven't taught it yet), and it doesn't make guesses. Currently, it can win about 70% of easy games (8x8, 10 bombs), about 60% of medium games(16x16, 40 bombs), and 8% of hard games (16x30, 99 bombs). Let me know if you want more information. – ThisIsAQuestion Apr 27 '16 at 14:10
  • So I was playing and I just came across a situation impossible to solve by pure logic. I thought I'd add this as an answer but unfortunately I'm not allowed. But I still think it's value information to illustrate how it is not possible to always win at minesweeper (despite sound deduction and having already cleared the necessarily guessed tiles). So, I guess, my answer as non-mathematician is, odds are <100%. Notice the highlighted areas and how it is impossible to discriminate reliably through deduction in this case, as there are two possible solutions: https://imgur.com/soEizGO – ecv Apr 08 '19 at 16:53