Here's a fun, frivolous, and simple little program I wrote recently
which seemed just interesting enough to share. The idea is to write an
AI assistant for the game of minesweeper. The trickiness is that
sometimes every available square has a chance of having a mine on it, so
running a basic constraint satisfaction algorithm on it won't give you
any useful information.
Instead, you can generate a sequence of random mine assignments which
are each consistent with the numbers on the currently visible squares
and then calculate a running average of the probability that each square
has a mine. In some cases this probability is 100% or 0%, in which case
it (with high likelihood) gives you the same result as a standard
logical deduction would, but in other cases the probabilities are very
useful for making a move.
It's fun to watch the colors flicker around and then quickly converge to
an answer, and to see the ways in which different patterns interact with
each other. Attached are a couple of screenshots. Blue is low
probability and red is high probability. Squares with 100% or 0%
probability are highlighted with a white border.
Post a reply to this message
Attachments:
Download 'monte_carlo_minesweeper1.png' (10 KB)
Download 'monte_carlo_minesweeper2.png' (12 KB)
Preview of image 'monte_carlo_minesweeper1.png'
![monte_carlo_minesweeper1.png](/povray.off-topic/attachment/%3C49d70311%40news.povray.org%3E/monte_carlo_minesweeper1.png?preview=1)
Preview of image 'monte_carlo_minesweeper2.png'
![monte_carlo_minesweeper2.png](/povray.off-topic/attachment/%3C49d70311%40news.povray.org%3E/monte_carlo_minesweeper2.png?preview=1)
|