Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall

  • Slides: 23
Download presentation
Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

Minesweeper Solver Marina Maznikova Artificial Intelligence II Fall 2011

Agenda 1. 2. 3. 4. 5. 6. The Minesweeper Game Theoretical Background Solving Agents

Agenda 1. 2. 3. 4. 5. 6. The Minesweeper Game Theoretical Background Solving Agents Evaluation Extension Summary 2

1. The Minesweeper Game 3

1. The Minesweeper Game 3

1. The Minesweeper Game 4

1. The Minesweeper Game 4

2. Theoretical Background n NP-completeness (8 -SAT) n Solving approaches: ¨ Constraints ¨ Reinforcement

2. Theoretical Background n NP-completeness (8 -SAT) n Solving approaches: ¨ Constraints ¨ Reinforcement learning 5

3. Solving Agents n Random agent (RA) 6

3. Solving Agents n Random agent (RA) 6

3. Solving Agents n Random agent (RA) n Simple agent (SA) ¨ Only mines

3. Solving Agents n Random agent (RA) n Simple agent (SA) ¨ Only mines remain around a square => mark as mine ¨ All mines around a square marked => open neighbors 7

3. Solving Agents n Greedy agent (GA) ¨ Start with (0, 0) ¨ Search

3. Solving Agents n Greedy agent (GA) ¨ Start with (0, 0) ¨ Search for mine and safe squares ¨ If nothing found 2/3 n Calculate for each square the density of mines on the squares around it n For each square, take the maximum of the densities calculated for this n If no opened neighbors => ½ n Open the square with the minimum 2/3 “probability” of mine 1/5 8

3. Solving Agents n Constraints agent (CA) ¨ Start with (0, 0) ¨ Consider

3. Solving Agents n Constraints agent (CA) ¨ Start with (0, 0) ¨ Consider only the relevant squares ¨ Model the problem as constraints problem Mine square => 1; opened square => 0 n Sum of mines around opened squares n Number of mines in the game n 9

3. Solving Agents n Constraints agent (CA) ¨ Backtracking for 3000 results ¨ Calculate

3. Solving Agents n 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 00100000 … 01111101 12322202 10

3. Solving Agents n Constraints agent (CA) ¨ Problem: Exponential algorithm Impossible to generate

3. Solving Agents n Constraints agent (CA) ¨ Problem: Exponential algorithm Impossible to generate always all the solutions n Time n 11

3. Solving Agents n Constraints agent (CA) ¨ Problem: Exponential algorithm n Impossible to

3. Solving Agents n Constraints agent (CA) ¨ Problem: Exponential algorithm n Impossible to generate always all the solutions n Time n “Simple” constraints agent (SCA) ¨ Start with (0, 0) ¨ Search for mine and safe squares ¨ If nothing found, use constraints 12

4. Evaluation n Observed variables ¨ Overall result ¨ Average squares revealed per game

4. Evaluation n Observed variables ¨ Overall result ¨ Average squares revealed per game ¨ Time n Tests (20. 000 games) ¨ Agent comparison on standard board ¨ Variation of board size ¨ Variation of mine density 13

4. Evaluation: Standard Game Problem of too many solution possibilities 14

4. Evaluation: Standard Game Problem of too many solution possibilities 14

4. Evaluation: Standard Game Backtracking is expensive 15

4. Evaluation: Standard Game Backtracking is expensive 15

4. Evaluation: Board Size Better performance on larger and smaller boards Exception: backtracking 16

4. Evaluation: Board Size Better performance on larger and smaller boards Exception: backtracking 16

4. Evaluation: Board Size Larger boards require more time, especially when backtracking is used

4. Evaluation: Board Size Larger boards require more time, especially when backtracking is used 17

4. Evaluation: Mine Density The higher the mine density, the worse the performance Greedy

4. Evaluation: Mine Density The higher the mine density, the worse the performance Greedy strategy is not good for few mines 18

4. Evaluation: Mine Density CA and SCA: More mines require more time RA, SA,

4. Evaluation: Mine Density CA and SCA: More mines require more time RA, SA, and GA: More mines require less time 19

5. Extension n Possibility to open 5% of the squares as joker ¨ RA:

5. Extension n 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” 20

5. Extension: Evaluation Jokers improve the performance … and make unsafe strategies inefficient 21

5. Extension: Evaluation Jokers improve the performance … and make unsafe strategies inefficient 21

5. Extension: Evaluation Time increases because of the more moves 22

5. Extension: Evaluation Time increases because of the more moves 22

6. Summary n Backtracking is expensive and for many solution possibilities inefficient ¨ Solution:

6. Summary n Backtracking is expensive and for many solution possibilities inefficient ¨ Solution: n n n 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 23