Download presentation
Presentation is loading. Please wait.
1
CS162 Week 5 Kyle Dewey
2
Overview Assignment 2b pain points Assignment 3a
3
Assignment 2b Pain Points
-Difficulty level? -Which things were hard? Easy?
4
Assignment 3a
5
Goal Write a Minesweeper solver Given a board in some state, infer
Which spaces must be mines Which spaces must be clear
6
Minesweeper Grid of initially unrevealed tiles
Revealing a tile exposes: A mine A blank space A number stating how many mines are adjacent to the revealed tile
7
Minesweeper
8
Blue cells are adjacent
Adjacency Based on horizontal, vertical, and both diagonal axes Blue cells are adjacent to the red cell
9
Blue cells are adjacent
Adjacency Based on horizontal, vertical, and both diagonal axes Blue cells are adjacent to the red cell
10
Blue cells are adjacent
Adjacency Based on horizontal, vertical, and both diagonal axes Blue cells are adjacent to the red cell
11
Blue cells are adjacent
Adjacency Based on horizontal, vertical, and both diagonal axes Blue cells are adjacent to the red cell
12
Success/Failure Success: all non-mine positions have been uncovered
Failure: a cell containing a mine was uncovered
13
Utilizing Numbers In certain cases, it is possible use revealed numbers to reason about mine positions 1 ??? In this case, the single unrevealed tile must be a mine
14
Minesweeper as a CSP CSP = constraint satisfaction problem
For every number N, it must be the case that the sum of the mines in all adjacent cells is equal to N 1 ???
15
Minesweeper as a CSP CSP = constraint satisfaction problem
For every number N, it must be the case that the sum of the mines in all adjacent cells is equal to N 1 ??? 1 = ...
16
Minesweeper as a CSP CSP = constraint satisfaction problem
For every number N, it must be the case that the sum of the mines in all adjacent cells is equal to N 1 ??? 1 = 0 ...
17
Minesweeper as a CSP CSP = constraint satisfaction problem
For every number N, it must be the case that the sum of the mines in all adjacent cells is equal to N 1 ??? 1 =
18
Minesweeper as a CSP CSP = constraint satisfaction problem
For every number N, it must be the case that the sum of the mines in all adjacent cells is equal to N 1 ??? 1 =
19
Minesweeper as a CSP CSP = constraint satisfaction problem
For every number N, it must be the case that the sum of the mines in all adjacent cells is equal to N 1 ??? 1 = 0 ...
20
Minesweeper as a CSP CSP = constraint satisfaction problem
For every number N, it must be the case that the sum of the mines in all adjacent cells is equal to N 1 ??? 1 =
21
Minesweeper as a CSP CSP = constraint satisfaction problem
For every number N, it must be the case that the sum of the mines in all adjacent cells is equal to N 1 = 0 ... 1 ???
22
Minesweeper as a CSP CSP = constraint satisfaction problem
For every number N, it must be the case that the sum of the mines in all adjacent cells is equal to N 1 = 1 ???
23
Minesweeper as a CSP CSP = constraint satisfaction problem
For every number N, it must be the case that the sum of the mines in all adjacent cells is equal to N 1 = X 1 ???
24
(the unknown spot has a mine)
Minesweeper as a CSP CSP = constraint satisfaction problem For every number N, it must be the case that the sum of the mines in all adjacent cells is equal to N 1 = X 1 ??? simplify X = 1 (the unknown spot has a mine)
25
Minesweeper as a CSP For each number, there is one equation
The equations collectively form a system of equations which can be solved to derive a solution
26
Additional Constraints
Each unknown square can have a value of either 0 or 1 (no mine or mine) The total number of mines in unknown squares + the total number of previously inferred mines = the predefined number of mines on the board
27
In CLP CLP = constraint logic programming
The aforementioned problem can be represented and solved directly with ease We will provide template code which already performs most of the board manipulation You must implement code to add constraints
28
Template Code
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.