MineSweeper - One Click Win Frequency Analysis

This runs through a series of randomly generated beginner (8x8) Minesweeper boards, and determines if the each board is solvable in a single click.

To be one-click solvable, the following must be true:

All non-bomb cells must be adjacent to at least one open cell (a cell with no bomb neighbors) The open cells must be continuous

All output is sent to the console log, not to the browser window. Run this in Chrome and press Ctrl-Shift-J, or run in Firefox and press Ctrl-Shift-K. IE 9 does not work. This is important, if you don't this page won't appear to do anything!

Board width:

Board height:

Number of bombs:

Number of iterations: (one million is the default, takes a couple of seconds. Should return about 7 hits.)

Press the Go button

Findings:

Approximately .00525% (525 in 10 million) are candidates (satisfies rule 1, but not necessarily rule 2).

Assuming the first click always opens empty space and the user has clicked in the middle, the number of candidates jumps to .009% (900 in 10 million)

After 100 million trials, it found 664 successes (passed both rule 1 and 2). That is .000664%, or about 1 in 150k.

With about 6 million beginner games played to completion so far, that would be about 40 games that have been completed in just one click.

Conclusion: It is silly to have an all time Beginner leader board.

After 1 billion iterations on Intermediate (16x16, 40 bombs) there weren't even any candidates (rule 1).

Notes:

Can't easily traverse the whole space, there are 1.85e19 permutations in the 64 bit space, of which 5.5e17 represent a beginner board (10 bits/bombs turned on). At 1 millon per second that would still take years.

See http://www.mathsisfun.com/combinatorics/combinations-permutations-calculator.html for a great permutations calculator.

This method does a random construction of valid beginner boards, and assumes the user clicked in the middle and that the first click is always opening an empty space. To play with the XP version of a beginner board, change the dimensions to 9x9.

This runs locally in your browser so you can view the source, save it locally, and try your own mods. Let me know if you extend it in a cool way.

Works in Chrome and Firefox, and does not work in IE 9. Not sure about IE 10. Chrome's Console API.

And be careful, if you put in bad parameters you could have either a huge console log and/or tie up your CPU until you kill it.

Updates:

20130305: Finished, first put online.

20130306: Did some quick performace testing. Chrome is about 2x Firefox and about 3x IE 9. To get it to work in IE 9 I had to temporarily zap some of the console functionality. Also, apparently any try/catch structures anywhere cause Chrome and Firefox to run at about 1/3 the speed.

20130309: Added a single line of output in the HTML so there is something to see if the user doesn't use the console. Also added a quick test so if the console doesn't appear to be working it dumps out. Plus a few cleanup items and comments. This should be the last update.

Want to discuss? You can email me at "sheppoor at dataexperts.com" or better yet leave a comment on my blog post on the subject.

Published under the Creative Commons Attribution 3.0 Unported license.