Upload
vern
View
60
Download
0
Embed Size (px)
DESCRIPTION
CPE 481 - Minesweeper. Hafeez Jaffer. Introduction. Rules of the game History originally created by Robert Donner and Curt Johnson. New Features. - open and save minefield. - more freedom in choosing minefield dimensions. New Features Cont. Turn Rete engine on/off - PowerPoint PPT Presentation
Citation preview
CPE 481 - Minesweeper
Hafeez Jaffer
Introduction- Rules of the game- History
- originally created by Robert Donner and Curt Johnson
New Features
- open and save minefield
- more freedom in choosing minefield dimensions
New Features Cont.
-Turn Rete engine on/off-Display Rete engine facts-Try all combinations (beta)
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
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
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
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
Test Cases This presentation contains 6 basic
test cases These may not be the ones I use to
test your program
Test Case1
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.
Test Case2
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
Test Case3
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
Test Case4
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
Test Case5
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
Test Case6
Test Case6 Solution-Use the “Try all combinations” option from the menu
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 )
Implementation Details - Defglobals
EMPTY_SQUARE (=0) FLAGGED_MINE (=-2) UNKNOWN (=-4)
Implementation Details – GUI hooks
(reveal-square ?id) (flag-square ?id)
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.
Conclusion Any questions?