0

I have to build a Minesweeper solver, but don't really know where to start. The problem is, I have to utilize some metaheuristic algorithm, like ant colony optimization, simulated annealing, genetic programming etc. I have found some related materials on the Internet, but I'm not really sure which of them are useful and which are not, since nothing is a "perfect fit". It looks like I'll have to adjust some metaheuristic algorithm on my own, without following some article written by people who have done it before. That's why I want to know all the things I need to know before I start.

  1. How do I formulate my problem to make it suitable for using metaheuristics to solve it? I know it's basically a CSP (constraint satisfaction problem) but don't know how to use that knowledge to find a suitable algorithm for solving it.
  2. Which metaheuristics would be suitable for solving my problem (and why)?
  3. Are there any things specific to my problem that I should be aware of?
iCanLearn
  • 336
  • 1
  • 4
  • 17

2 Answers2

3

"ant colony optimization, simulated annealing, genetic programming" ... big words, but I am not sure how you would use any of them!

I suggest having two solvers:

  1. Perfect solver: Where there is a perfect answer without any doubt and solving it.
  2. Imperfect solver: Where there is doubt and you would like to find the least harmful solution.

Apply the perfect solver first, and if it fails, apply the imperfect solver.

Perfect solver needs to find all the combinatorial possibilities and checking out which of them work. In reality it is not that difficult, since you would be considering 1-5 tiles at once (as a human solver I restrict myself to that many tiles usually), there are only at most 32 combinations which is easy to check.

For imperfect solver, you can consider all the combinations, find out valid combinations, calculate probability of mine at different locations using the valid combinations and pick the one with least mine probability.

Come to think of it these two approaches are the same! In perfect solver you would be choosing the tile with 0 mine probability. So, to summarize:

  1. Pick 1-10 unmarked tiles that are contiguous or connected by at most one gap, and each one of them are connected to at least one revealed non-mine location.
  2. Find all the valid combinations
  3. If the probability of mine is 0 at any location, choose that option immediately.
  4. Or, keep track of location with minimum mine probability.
  5. Go to step 1

Step 1 is not as bad as it sounds, because there can be only a few combinations that satisfy both the conditions (contiguous and adjacent to a solved non-mine location).

ElKamina
  • 7,747
  • 28
  • 43
  • Yeah, but that's not really a metaheuristic... Or is it? As far as my understanding of that word goes, it's not. The trouble is, I *have* to use metaheuristics. If it's not doable, I must say I'm an awkward position. – iCanLearn Oct 06 '12 at 14:43
  • @iCanLearn You are in awkward position, because this problem doesn't need metaheuristics! You can invent ways to stuff it, but that is necessary. – ElKamina Oct 06 '12 at 14:47
  • Yeah, that's what I was afraid of. I won't accept your answer because it doesn't really help me, but I will upvote it. – iCanLearn Oct 06 '12 at 14:56
0

Metaheuristics might not the best algorithm for Minesweeper - at least not for the easy parts.

Instead, a simple rule engine with inference could probably already tag many of the bombs and reveal the free spots. The inference is needed to reason further once a bomb has been tagged, with that information. For inspiration, see drools's conway's game of life example.

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120