Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011
2 Agenda 1. The Minesweeper Game 2. Theoretical Background 3. Solving Agents 4. Evaluation 5. Extension 6. Summary
3 1. The Minesweeper Game
4
5 2. Theoretical Background NP-completeness (8-SAT) Solving approaches: Constraints Reinforcement learning
6 3. Solving Agents Random agent (RA)
7 3. Solving Agents Random agent (RA) Simple agent (SA) Only mines remain around a square => mark as mine All mines around a square are marked => open neighbors
8 3. Solving Agents Greedy agent (GA) Start with (0, 0) Search for mine and safe squares If nothing found Calculate for each square the density of mines on the squares around it For each square, take the maximum of the densities calculated for this If no opened neighbors => ½ Open the square with the minimum “probability” of mine 2/3 1/5
9 3. Solving Agents Constraints agent (CA) Start with (0, 0) Consider only the relevant squares Model the problem as constraints problem Mine square => 1; opened square => 0 Sum of mines around opened squares Number of mines in the game
10 3. Solving Agents Constraints agent (CA) Backtracking for 3000 results Calculate how many times each square is mine Mark mine squares and open safe squares If no such squares found, open the square with the lowest sum of mines …
11 3. Solving Agents Constraints agent (CA) Problem: Exponential algorithm Impossible to generate always all the solutions Time
12 3. Solving Agents Constraints agent (CA) Problem: Exponential algorithm Impossible to generate always all the solutions Time “Simple” constraints agent (SCA) Start with (0, 0) Search for mine and safe squares If nothing found, use constraints
13 4. Evaluation Observed variables Overall result Average squares revealed per game Time Tests ( games) Agent comparison on standard board Variation of board size Variation of mine density
14 4. Evaluation: Standard Game Problem of too many solution possibilities
15 4. Evaluation: Standard Game Backtracking is expensive
16 4. Evaluation: Board Size Better performance on larger and smaller boards Exception: backtracking
17 4. Evaluation: Board Size Larger boards require more time, especially when backtracking is used
18 4. Evaluation: Mine Density The higher the mine density, the worse the performance Greedy strategy is not good for few mines
19 4. Evaluation: Mine Density RA, SA, and GA: More mines require less time CA and SCA: More mines require more time
20 5. Extension Possibility to open 5% of the squares as joker RA: At the beginning of the game SA: In case no mine/safe squares are found GA: In case of two squares with the same mine “probability” CA and SCA: On start, in case of too many solutions of the problem, and when two squares are “safest”
21 5. Extension: Evaluation Jokers improve the performance … and make unsafe strategies inefficient
22 5. Extension: Evaluation Time increases because of the more moves
23 6. Summary Backtracking is expensive and for many solution possibilities inefficient Solution: Sets The Greedy strategy is not a good strategy The higher the mine density, the difficult the game Jokers help and make unsafe move strategies inefficient