1 / 28

CS162 Week 5

CS162 Week 5. Kyle Dewey. Overview. Assignment 2b pain points Assignment 3a. Assignment 2b Pain Points. Assignment 3a. Goal. Write a Minesweeper solver Given a board in some state, infer Which spaces must be mines Which spaces must be clear. Minesweeper.

Download Presentation

CS162 Week 5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS162 Week 5 • Kyle Dewey

  2. Overview • Assignment 2b pain points • Assignment 3a

  3. Assignment 2b Pain Points

  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. Adjacency • Based on horizontal, vertical, and both diagonal axes Blue cells are adjacent to the red cell

  9. Adjacency • Based on horizontal, vertical, and both diagonal axes Blue cells are adjacent to the red cell

  10. Adjacency • Based on horizontal, vertical, and both diagonal axes Blue cells are adjacent to the red cell

  11. 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

  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

  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 = ...

  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 = 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 = 0 + 0 ...

  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 = 0 + 0 + 0 ...

  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 = 0 + 0 + 0 + 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 = 0 + 0 + 0 + 0 + 0 ...

  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 + 0 + 0 + 0 + 0 + 0 ...

  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 = 0 + 0 + 0 + 0 + 0 + 0 + 0 ...

  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 = 0 + 0 + 0 + 0 + 0 + 0 + 0 + X

  24. 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 + 0 + 0 + 0 + 0 + 0 + 0 + X 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

More Related