
Advanced Minesweeper - pcopley
http://datagenetics.com/blog/june12012/index.html
======
lotharbot
I would say the goal is not to have the highest probability of triggering a
cascade, but rather, some combination of:

\- high probability of triggering a cascade

\- high probability of that cascade being "useful", that is, of being able to
work outward from the cascade you opened. (Clicking on the empty corner and
getting 1-3-1 on its borders means you still have to guess to escape the
corner.)

\- high probability of _not_ leaving difficult areas for the end. (Coin flips
are most likely to occur in corners and edges; in the middle of the board, you
usually have information from multiple directions. It's still possible to be
forced to guess in the middle, but it happens far less often.)

As a result, the strategy I've chosen on expert boards (based on experience,
without particularly robust statistical backing) is to click the corners
sequentially until I get one that allows me to open up more than a few
squares. I occasionally lose a game on the second or third click this way, but
I don't lose very many on late coin flips.

------
breadbox
Speaking as someone who has spent WAY too much time playing minesweeper --
Early on I came to a similar conclusion (though without doing the actual math)
and started clicking on corners initially. I soon discovered, as most people
do, that corners are much more likely to expand out into a tiny opening that
you can only follow for a short time before you're forced to make a "coin
toss" move. If the goal is to make a _usable_ blob, clicking in the middle is
best.

~~~
powrtoch
Speaking as the same sort of person (96 secs on expert :-) ), I agree that the
most useful strategy is to click in the middle. This is because the cost of
restarting is practically nothing for your first few clicks (no sunk time
costs), so what you should really be optimizing is trying to get the most
information about the board as soon as possible. All the more so because
_optimally_ your whole game will proceed logically from that first cascade.
Bigger cascades are less likely to dead end, meaning you'll be less likely to
have to guess at random again later (when you actually will have sunk time
costs).

~~~
pessimizer
Wouldn't bigger cascades be _more_ likely to deadend, due to the average
density of what's leftover increasing?

~~~
powrtoch
My fault for being ambiguous about the word "bigger", thanks for pointing this
out. It's true that you're not looking for a large area per se. What you want
is a large perimeter. The best starting click would be a whole lot of thin
tentacles stretching out across the board, not a giant square-ish clump.

That is, you're trying to maximize _information_. A large rectangular area
doesn't give you nearly as much information about the board as a tentacle-y
one, because most of the squares don't tell you anything but their own value.

------
Zimahl
Although I have no idea since I have never seen the code, I'm pretty sure
there's no way to hit a bomb on your first click. I'm played enough (MS
Windows) Minesweeper and have never, ever hit a bomb on the first click.

As a side note, Minesweeper the first game I ever programmed was for my intro
C class in college using SRGP[1] as the graphics library. Thinking back, it
was a tough project. The Minesweeper logic wasn't so bad but doing the
graphics was the most work. In hindsight, it shouldn't have taken more than a
couple hours to code but took everyone a fair amount of time. Of course we
didn't know what they hell we were doing. Fun stuff.

EDIT: After searching around it appears there is code to prevent the first-
click bomb in a rather novel way[2].

[1] <http://www.niksula.cs.hut.fi/~tik86120/X_srgp.html> [2]
[http://www.sanchitkarve.com/blog/2009/01/does-minesweeper-
ch...](http://www.sanchitkarve.com/blog/2009/01/does-minesweeper-cheat/)

~~~
randomdrake
As far as I can recall, hitting a bomb on the first click is possible. But, if
the source code proves my memory wrong, it certainly wouldn't be the first
time.

~~~
archangel_one
I wonder if this is an enhancement in Vista Minesweeper? I'm almost certain
that it used to be possible to land on a mine with your first click in older
versions.

~~~
Aeons
Yes.

------
pessimizer
Another priority with the first click is that you won't be entirely surrounded
by mines and wires, wires being indeterminate, entangled chains of unrevealed
spaces.

I'm pretty sure a probability can be worked out for rate of occurrence and
length of a wire - but with the corner strategy, you're minimizing the likely
amount of perimeter by 3/4. That's got to make a "coin flip" situation more
likely, which has to be weighed against the more likely reveal.

If you don't get a reveal on the first click, you end up just clicking again a
few times and restarting if you reveal a mine. Doesn't waste more than a
second in any case. Not sure if that's really meaningful unless there's a no
restart rule, or you're being graded by the percentage of games finished that
are started.

~~~
pessimizer
Realized people may not know what I'm talking about when I mention wires:
<http://web.mat.bham.ac.uk/R.W.Kaye/minesw/minesw.pdf>

Paper on minesweeper configurations being NP-complete. Wires in the paper are
wires when approached from all directions, but I'm abusing the term a bit when
I also include entangled squares around the perimeter of a minesweeper opening
- which have only been approached from one direction.

I think of minesweeper as a bunch of soap bubbles that are popped until you
reach wires, which if they connect board boundary to board boundary, or
connect to another wire that does that, or connect to themselves, end the
skill game and create a probability game. Been meaning to play around with 2D
areas that are surrounded by wire rings, but too lazy.

The idea of randomness carved by rules creating stable shapes intrigues me. I
play minesweeper too much. Expert: 78, 95 non-flagging, lawl.

------
webjprgm
This seems totally wrong to me. Of course the probability of surrounding
squares being _all_ safe is higher in the corner simply because there are
_fewer surrounding squares_!

To make it more fair, calculate the probability that 3+ adjacent squares would
be safe, since that's how many you get in the corner. Then the math shows that
center is better because there are more neighboring squares that could be
potentially blank.

More useful would be the probability of having a cascade continue on past
adjacent squares to squares adjacent to those, with the "winner" being
whichever location is most likely to make the largest exposed bubble.

My strategy is generally click a few places in the center quickly. If I die, I
don't have much invested and just start over. If I find a large bubble, then I
can play.

~~~
milfot
Absolutely agree!

..and from my experience, three clicks is about optimum for speed and opening
the board. All my sub 80s games have opened 'gashes' across the board, the
three clicks gives you the best chance of jumping the 'wire' (as the other guy
put it)..

If you are going to have to play the odds at some point anyway, may as well do
it at the start before you invest 50s of your life in some pointless activity.

------
mrgriscom
I think it's nowhere near that simple. You don't just want to open up a
cascade, but a _quality_ cascade that gives enough information to work with to
identify which cells are mines, or, failing that, won't involve a risky guess.
A '1' in the corner means each neighboring cell is a 1 in 3 risk, while a '1'
in the middle is only 1 in 8.

shameless plug: a minesweeper solver I wrote
[<http://mrgris.com/projects/minesweepr/demo/player/>]

------
pavel_lishin
Someone ought to write something to empirically test this assertion by
clicking on the various possible locations.

~~~
lojack
I'd be willing to bet that in the real world a corner is actually the worst
choice. It may be the most likely to get blank spaces, but its probably also
more likely to box you in, and only gives you one direction of attack.

------
esalman
My shortest time on the advanced mode of windows version is 62 seconds. I'm
sure many of you'd beat that.

------
gojomo
Would it be possible to make a 3D Minesweeper game inside Minecraft?

~~~
Dove
Inside Minecraft proper, it would be prohibitively difficult. Redstone doesn't
really support programming that complex (keeping 3D state, cleared areas,
randomizing the board, etc.).

With a couple new blocks, though -- a new game control, the mine blocks
themselves -- it would be a moderately easy mod. Putting dynamic textures on
the blocks to display numbers wouldn't be (in principle) any harder than some
of the grass mods, and there's an onDestroy hook for the block you could use
to clear space.

I wonder how hard 3D minecraft would be.

[Edit: Ha! It's been done! <http://www.youtube.com/watch?v=eV6n0UWJM2Q>
<http://www.youtube.com/watch?v=DW71giahaLM>

This is why we google things before building them.]

[Edit edit: Oh, nuts. Those are both still 2D. This is why we review google
results before deciding not to build something.]

~~~
Dove
_I wonder how hard 3D minecraft would be._

Er, wow. Hard.

<http://egraether.com/mine3d/>

------
slig
There're some gems on DataGenetics' blog. Highly recommended.

~~~
stanzyamith
Yes, especially:

Benford's Law <http://www.datagenetics.com/blog/march52012/index.html>

Hangman <http://www.datagenetics.com/blog/april12012/index.html>

Yahtzee <http://www.datagenetics.com/blog/january42012/index.html>

Risk <http://www.datagenetics.com/blog/november22011/index.html>

Plus others ...

