Somewhat OT... Computer playing Minesweeper

Heiko Wundram heikowu at ceosg.de
Wed Jul 14 22:48:17 EDT 2004


Am Donnerstag, 15. Juli 2004 04:34 schrieb John Doe:
> I expect you'd get much better performance by randomly selecting the
> first get() in solve().  As it is, for the first get, you iterate over
> every possible combination of fields of the apropriate size, only to
> learn that they are all equally likely, since you have no information.

As I said before, the program does not iterate over all possible states, but 
only over those states that can be created by placing mines surrounding 
already discovered fields. In the case you mention, there is only one 
possible state, and that is returned by __iterConsistentStates(), as there 
are no discovered fields. The time it takes to calculate this state is 
negligible, concerning the whole runtime.

I've already thought about what you said, but I kept it as is, as IMHO it's 
much cleaner to just have a loop which always does the same thing, and not 
special-case the first time round.

> As for your percentage accuracy, I think another poster had a point,
> in that while your first random get is capable of causing a Boom, in
> most implementations of Minesweeper, it cannot.  You are throwing in
> an extra 15% failure rate, right there on your 16x16 with 40 mines.

Okay, I already replied to that poster, that I didn't think that other 
Minesweepers were always giving you a free first shot. But, at least for 
Windows Minesweeper, I checked, and yes, it gives you that first free shot, 
always. I'll try and incorporate that... Maybe the numbers will get closer 
then, but still: 1/0.85*65% <> 80%...

Heiko.



More information about the Python-list mailing list