CPE 481 Minesweeper Hafeez Jaffer Introduction Rules of

  • Slides: 26
Download presentation
CPE 481 - Minesweeper Hafeez Jaffer

CPE 481 - Minesweeper Hafeez Jaffer

Introduction - Rules of the game - History - originally created by Robert Donner

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

New Features Cont. -Turn Rete engine on/off -Display Rete engine facts -Try all combinations (beta)

Goal of the Assignment n n Create a JESS agent that will find mines

Goal of the Assignment n n Create a JESS agent that will find mines in a given Minefield minesweeper. clp n Found in the Jess directory, each rule that is written in this file will be loaded and executed by the Mine. Sweeper program to determine locations

Grading Criteria n n n Logically deduce and flag mine locations in a given

Grading Criteria n n n Logically deduce and flag mine locations in a given solvable minefield (one that doesn't require guessing) Solve all the test cases in the "test. Cases" directory Solve expert minefields in an efficient and fast manner

Point breakdown n n 5 points for implementing the deffunctions "flag. All. Surrounding. Unknowns"

Point breakdown n n 5 points for implementing the deffunctions "flag. All. Surrounding. Unknowns" and "reveal. All. Surrounding. Unknowns" 5 points for performance 10 points for the test runs 5 points for the README file and documentation of the source code

Submission n "minesweeper. clp" file n n containing the JESS rules to solve a

Submission n "minesweeper. clp" file n n 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 n n This presentation contains 6 basic test cases These may not

Test Cases n n This presentation contains 6 basic test cases These may not be the ones I use to test your program

Test Case 1

Test Case 1

Test Case 1 Solution ABC– 1 AB– 1 BCD– 1 1 – 1 =

Test Case 1 Solution ABC– 1 AB– 1 BCD– 1 1 – 1 = 0. 0 means all that’s left are not mines C is not a mine. 1 – 1 = 0. 0 means all that’s left are not mines B is not a mine. A B C D

Test Case 2

Test Case 2

Test Case 2 Solution DE– 1 DEC– 2 ABCD– 1 E CD– 2 2

Test Case 2 Solution DE– 1 DEC– 2 ABCD– 1 E CD– 2 2 – 1 = 1, the number that’s left is equal to this, therefore mine 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) A B C D Jess functions used: Intersection, complement, and test E

Test Case 3

Test Case 3

Test Case 3 Solution ABCFHI– 3 BCDJI– 5 BCDIJ – 5 CDEJGK– 3 BCI

Test Case 3 Solution ABCFHI– 3 BCDJI– 5 BCDIJ – 5 CDEJGK– 3 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 A B F H I C Jess functions used: Intersection, complement, and test D E G J K

Test Case 4

Test Case 4

Test Case 4 Solution CDF– 1 CDFIJK– 3 BCHIJ– 4 ABCHIEG– 3 BCHI removed,

Test Case 4 Solution CDF– 1 CDFIJK– 3 BCHIJ– 4 ABCHIEG– 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. A E B G H C D I F K Jess functions used: Intersection, complement, and test J

Test Case 5

Test Case 5

Test Case 5 Solution B can be revealed because there is only one mine

Test Case 5 Solution B can be revealed because there is only one mine left. B must be 1 so A and D can be revealed AB CD

Test Case 6

Test Case 6

Test Case 6 Solution -Use the “Try all combinations” option from the menu

Test Case 6 Solution -Use the “Try all combinations” option from the menu

Implementation Details - Deftemplates (Mine. Square (slot id) - integer (slot row) - integer

Implementation Details - Deftemplates (Mine. Square (slot id) - integer (slot row) - integer (slot col) - integer (slot status ? status) - integer (multislot surrounding. Unknowns) - integer list (slot num. Surrounding. Flags) - integer ) (Minefield. Variables (slot number. Mines) - integer (slot mine. Height) - integer (slot mine. Width) - integer )

Implementation Details - Defglobals n n n EMPTY_SQUARE (=0) FLAGGED_MINE (=-2) UNKNOWN (=-4)

Implementation Details - Defglobals n n n EMPTY_SQUARE (=0) FLAGGED_MINE (=-2) UNKNOWN (=-4)

Implementation Details – GUI hooks n n (reveal-square ? id) (flag-square ? id)

Implementation Details – GUI hooks n n (reveal-square ? id) (flag-square ? id)

Implementation Details – Jess commands n http: //www. cs. vu. nl/~ksprac/2002/doc/Jess 60/functions. html n

Implementation Details – Jess commands n http: //www. cs. vu. nl/~ksprac/2002/doc/Jess 60/functions. html n length$ n n Subsetp n n Returns a new multifield consisting of all elements of the second multifield not appearing in the first multifield. intersection$ n n 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$ n n Returns the number of fields in a multifield value. Returns the intersection of two multifields. Returns a multifield consisting of the elements the two argument multifields have in common. Test n Returns true if the argument is true, false otherwise.

Conclusion n Any questions?

Conclusion n Any questions?