Back in 1997 I decided I needed to learn Javascript, so I wrote a clone of Minesweeper to teach myself the new language. I put my demo online and it was well received. Despite the lack of modern standards it has been used as the basis of many apps, widgets, and other sites. It continues to grow, now up to a crazy 1.7 million games played per month just from my site.

I want to build a simple leader board with a 24-hour, 30 day, and an all time list. But does the all time list work at the beginner level? Will it quickly descend into an all 0 score board?

What I want to know: how often will a beginner minesweeper board be solvable in a single click.

To answer the question I wrote a fun routine.

The page generates a beginner level minesweeper board. It places the 10 bombs randomly, marking all adjacent cells as touching a bomb. Next it makes sure each non-bomb cell borders at least one empty cell (a square that doesn’t have any bomb neighbors), otherwise that cell won’t open with the single click. If it passes this test, then the set of empty cells are checked to make sure they are continuous (e.g., there are no islands of empty cells elsewhere). If the board passes this last test then the board is solvable in one click.

This is a reasonable way to answer my question, but it isn’t either a mathematical proof nor is it a complete answer. The proof is beyond my math skills, and there are 5.5×10^17 valid 8×8 beginner minesweeper boards, making testing the entire space impractical.

Running for 100 million iterations  yielded 664 hits, which comes to approximately 1 in 150,000 games. Right now there are 215,000 beginner games being played to the end (win or loose) each month, so a top 10 leader board would be filled with 0’s within 7 months.

So I have my answer: No, don’t do a beginner all time leader board.

What I found most astonishing was the ability to run 100 million iterations on my 3-year-old machine in only 3 minutes. I even ran 1 billion iterations of an intermediate size board in only 2.5 hours, and that is using only 1 of 4 CPUs. It is amazing how Javascript engines have improved.

EDIT: If you try the tool, be sure to use Google Chrome, and press Ctrl-Shift-J to see the console. You won’t see any output otherwise!

ANOTHER EDIT: It works fine in Firefox too, press Ctrl-Shift-K for the console. It however doesn’t work in IE at least through IE 10; although IE 8 and later supports the console it doesn’t support the grouping and time functions.