POV-Ray : Newsgroups : povray.off-topic : Monte Carlo Minesweeper Server Time
5 Nov 2024 00:28:53 EST (-0500)
  Monte Carlo Minesweeper (Message 1 to 5 of 5)  
From: Kevin Wampler
Subject: Monte Carlo Minesweeper
Date: 4 Apr 2009 02:49:53
Message: <49d70311@news.povray.org>
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

Preview of image 'monte_carlo_minesweeper2.png'
monte_carlo_minesweeper2.png


 

From: Chambers
Subject: Re: Monte Carlo Minesweeper
Date: 4 Apr 2009 06:16:36
Message: <49d73384$1@news.povray.org>
Really cool - where's the program, again? :)

-- 
...Chambers
www.pacificwebguy.com


Post a reply to this message

From: andrel
Subject: Re: Monte Carlo Minesweeper
Date: 4 Apr 2009 08:24:11
Message: <49D7516B.7070302@hotmail.com>
On 4-4-2009 8:49, Kevin Wampler wrote:
> 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.

The lower one has at least 5 positions where you will end up having a 
50% change and no additional information. The change of surviving this 
minefield are therefore below 3%. Possibly much below that if you have 
had to guess before arriving at the current position. That is not good 
for a game. Perhaps you can employ something like this to find grids 
that can be solved with a reasonable chance.


Post a reply to this message

From: Kevin Wampler
Subject: Re: Monte Carlo Minesweeper
Date: 4 Apr 2009 21:13:05
Message: <49d805a1$1@news.povray.org>
andrel wrote:
> The lower one has at least 5 positions where you will end up having a 
> 50% change and no additional information. The change of surviving this 
> minefield are therefore below 3%.

It's not quite as bad as it looks since the groups on the upper right 
are actually connected to the large unsolved section, so it should be 
possible to solve them indirectly by starting at the lower probability 
blocks on the lower right.  The two on the left there's nothing you can 
do about though.

> Perhaps you can employ something like this to find grids 
> that can be solved with a reasonable chance.

I've thought about this too since the 50% guess patterns are pretty 
annoying.  I probably won't end up actually getting around to it unless 
I get a spurt of renewed interest, but it's a neat idea.


Post a reply to this message

From: Kevin Wampler
Subject: Re: Monte Carlo Minesweeper
Date: 4 Apr 2009 21:15:30
Message: <49d80632$1@news.povray.org>
Chambers wrote:
> Really cool - where's the program, again? :)

If you're interested I can post the source, although I'll want to 
comment it and clean it up a touch first.  It's not very complicated 
though, just 700 lines of python, most of which is the user interface.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.