23
Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

Embed Size (px)

Citation preview

Page 1: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

Minesweeper Solver

Marina Maznikova

Artificial Intelligence II Fall 2011

Page 2: 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

Page 3: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

3

1. The Minesweeper Game

Page 4: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

4

1. The Minesweeper Game

Page 5: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

5

2. Theoretical Background

NP-completeness (8-SAT)

Solving approaches: ConstraintsReinforcement learning

Page 6: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

6

3. Solving Agents

Random agent (RA)

Page 7: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

7

3. Solving Agents

Random agent (RA)

Simple agent (SA)Only mines remain around

a square => mark as mineAll mines around a square

are marked => open neighbors

Page 8: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

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

2/3

1/5

Page 9: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

9

3. Solving Agents

Constraints agent (CA)Start with (0, 0)Consider only the relevant squaresModel the problem as constraints problem

Mine square => 1; opened square => 0 Sum of mines around opened squares Number of mines in the game

Page 10: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

10

3. Solving Agents

Constraints agent (CA)Backtracking for 3000 resultsCalculate how many times

each square is mineMark mine squares and open

safe squares If no such squares found,

open the square with the lowest sum of mines

0 0 1 0 0 0 0 0

0 1 1 1 1 1 0 1

1 1 1 1 1 1 0 1

1 2 3 2 2 2 0 2

Page 11: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

11

3. Solving Agents

Constraints agent (CA)Problem: Exponential algorithm

Impossible to generate always all the solutions Time

Page 12: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

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

Page 13: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

13

4. Evaluation

Observed variablesOverall resultAverage squares revealed per gameTime

Tests (20.000 games)Agent comparison on standard boardVariation of board sizeVariation of mine density

Page 14: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

14

4. Evaluation: Standard Game

Problem of too many solution possibilities

Page 15: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

15

4. Evaluation: Standard GameBacktracking is expensive

Page 16: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

16

4. Evaluation: Board SizeBetter performance

on larger and smaller boards

Exception: backtracking

Page 17: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

17

4. Evaluation: Board SizeLarger boards require more time, especially when backtracking is

used

Page 18: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

18

4. Evaluation: Mine DensityThe higher the mine density, the worse the performance

Greedy strategy is not good for

few mines

Page 19: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

19

4. Evaluation: Mine Density

RA, SA, and GA: More mines

require less time

CA and SCA: More mines

require more time

Page 20: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

20

5. Extension

Possibility to open 5% of the squares as jokerRA: At the beginning of the gameSA: In case no mine/safe squares are foundGA: 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”

Page 21: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

21

5. Extension: EvaluationJokers improve the performance

… and make unsafe strategies inefficient

Page 22: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

22

5. Extension: EvaluationTime increases because of the more moves

Page 23: Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

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