CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by...
-
date post
15-Jan-2016 -
Category
Documents
-
view
219 -
download
0
Transcript of CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by...
![Page 1: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/1.jpg)
CPE 481 - Minesweeper
Hafeez Jaffer
![Page 2: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/2.jpg)
Introduction- Rules of the game- History
- originally created by Robert Donner and Curt Johnson
![Page 3: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/3.jpg)
New Features
- open and save minefield
- more freedom in choosing minefield dimensions
![Page 4: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/4.jpg)
New Features Cont.
-Turn Rete engine on/off-Display Rete engine facts-Try all combinations (beta)
![Page 5: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/5.jpg)
Goal of the Assignment Create a JESS agent that will find
mines in a given Minefield minesweeper.clp
Found in the Jess directory, each rule that is written in this file will be loaded and executed by the MineSweeper program to determine mine locations
![Page 6: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/6.jpg)
Grading Criteria Logically deduce and flag mine
locations in a given solvable minefield (one that doesn't require guessing)
Solve all the test cases in the "testCases" directory
Solve expert minefields in an efficient and fast manner
![Page 7: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/7.jpg)
Point breakdown 5 points for implementing the
deffunctions "flagAllSurroundingUnknowns" and "revealAllSurroundingUnknowns"
5 points for performance 10 points for the test runs 5 points for the README file and
documentation of the source code
![Page 8: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/8.jpg)
Submission "minesweeper.clp" file
containing the JESS rules to solve a given minefield
A README file documenting how your agent deduces mine locations and any known limitations
![Page 9: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/9.jpg)
Test Cases This presentation contains 6 basic
test cases These may not be the ones I use to
test your program
![Page 10: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/10.jpg)
Test Case1
![Page 11: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/11.jpg)
Test Case1 Solution
A
B
D
C
A B C – 1A B – 1
B C D – 1 C D – 1
1 – 1 = 0.0 means all that’s left are not minesC is not a mine.1 – 1 = 0.0 means all that’s left are not minesB is not a mine.
![Page 12: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/12.jpg)
Test Case2
![Page 13: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/13.jpg)
Test Case2 Solution
A
B DC E
D E – 1D E C – 2
A B C D – 1E C D – 2
C is left after DE is taken out. C must be a mine. (2 – 1 = 1)
E is left after CD is taken out. C must be a mine.(2 – 1 = 1)
Jess functions used: Intersection, complement, and test
2 – 1 = 1, the number that’s left is equal to this, therefore mine
![Page 14: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/14.jpg)
Test Case3
![Page 15: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/15.jpg)
Test Case3 Solution
A B C F H I – 3 B C D J I – 5
B C D I J – 5 C D E J G K – 3
E
GF
H
A CB D
I J K
BCI was taken out,5 – 3 = 2. That’s the number remaining. If equal, all are mines. DJ are mines
CDJ was taken out,5 – 3 = 2. That’s the number remaining. If equal, all are mines. BI are mines
Jess functions used: Intersection, complement, and test
![Page 16: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/16.jpg)
Test Case4
![Page 17: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/17.jpg)
Test Case4 Solution
E
G
F
H
A CB D
I J K
C D F – 1C D F I J K – 3
B C H I J – 4A B C H I E G – 3
BCHI removed, 4 – 3 = 1, That’s the number remaining. So J is a mine. For the bottom, AEG are left. 3 – 4 = -1. This is less than or equal to 0. AEG are not mines.
Jess functions used: Intersection, complement, and test
![Page 18: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/18.jpg)
Test Case5
![Page 19: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/19.jpg)
Test Case5 Solution
A BC D
B can be revealed because there is only one mine left.B must be 1 so A and D can be revealed
![Page 20: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/20.jpg)
Test Case6
![Page 21: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/21.jpg)
Test Case6 Solution-Use the “Try all combinations” option from the menu
![Page 22: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/22.jpg)
Implementation Details - Deftemplates
(MineSquare (slot id) - integer (slot row) - integer (slot col) - integer (slot status ?status) - integer (multislot surroundingUnknowns) - integer list (slot numSurroundingFlags) - integer )
(MinefieldVariables (slot numberMines) - integer (slot mineHeight) - integer (slot mineWidth) - integer )
![Page 23: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/23.jpg)
Implementation Details - Defglobals
EMPTY_SQUARE (=0) FLAGGED_MINE (=-2) UNKNOWN (=-4)
![Page 24: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/24.jpg)
Implementation Details – GUI hooks
(reveal-square ?id) (flag-square ?id)
![Page 25: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/25.jpg)
Implementation Details – Jess commands
http://www.cs.vu.nl/~ksprac/2002/doc/Jess60/functions.html
length$ Returns the number of fields in a multifield value.
Subsetp Returns TRUE if the first argument is a subset of the second (i.e.,
all the elements of the first multifield appear in the second multifield); otherwise, returns FALSE.
complement$ Returns a new multifield consisting of all elements of the second
multifield not appearing in the first multifield.
intersection$ Returns the intersection of two multifields. Returns a multifield
consisting of the elements the two argument multifields have in common.
Test Returns true if the argument is true, false otherwise.
![Page 26: CPE 481 - Minesweeper Hafeez Jaffer. Introduction -Rules of the game -History -originally created by Robert Donner and Curt Johnson.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d3f5503460f94a183c7/html5/thumbnails/26.jpg)
Conclusion Any questions?