CSE 4308/5360 - Assignments - Programming Assignment 3

Due date:
Monday, October 27, 2008, 11:59pm.

Task

The task in this programming assignment is to implement, a knowledge base and an inference engine for the wumpus world. First of all, you have to create a knowledge base (stored as a text file) storing the rules of the wumpus world, i.e., what we know about pits, monsters, breeze, and stench. Second, you have to create an inference engine, that given a knowledge base and a statement determines if, based on the knowledge base, the statement is definitely true, definitely false, or of unknown truth value.

Command-line Arguments

The program should be invoked from the commandline as follows:
check_true_false wumpus_rules.txt [additional_knowledge_file] [statement_file]
For example:
check_true_false wumpus_rules.txt kb1.txt statement1.txt

Output

Your program should create a text file called "result.txt". Depending on what your inference algorithm determined about the statement being true or false, the output file should contain one of the following four outputs: Notice that the sample code provided below stores the words "result unknown" to the result.txt file. Also, the "both true and false" output should be given when the knowledge base (i.e., the info stored in wumpus_rules.txt AND in the additional knowledge file) entails both the statement from statement_file AND the negation of that statement.

Syntax

The wumpus rules file and the additional knowledge file contain multiple lines. Each line contains a logical statement. The knowledge base constructed by the program should be a conjunction of all the statements contained in the two files. The sample code (as described later) already does that. The statement file contains a single line, with a single logical statement.

Statements are given in prefix notation. Some examples of prefix notation are:

(or M_1_1 B_1_2)
(and M_1_2 S_1_1 (not (or M_1_3 M_1_4)))
(if M_1_1 (and S_1_2 S_1_3))
(iff M_1_2 (and S_1_1 S_1_3 S_2_2))
(xor B_2_2 P_1_2)
P_1_1
B_3_4
(not P_1_1)
Statements can be nested, as shown in the above examples.

Note that:

There are six connectives: and, or, xor, not, if, iff. No other connectives are allowed to be used in the input files. Here is some additional information:

The only symbols that are allowed to be used are: NO OTHER SYMBOLS ARE ALLOWED. Also, note that i and j can take values 1, 2, 3, and 4. In other words, there will be 16 unique symbols of the form M_i_j, 16 unique symbols of the form S_i_j, 16 unique symbols of the form P_i_j, and 16 unique symbols of the form B_i_j, for a total of 64 unique symbols.

The Wumpus Rules

Here is what we know to be true in any wumpus world, for the purposes of this assignment (NOTE THAT THESE RULES ARE NOT IDENTICAL TO THE ONES IN THE TEXTBOOK):
  1. If there is a monster at square (i,j), there is stench at all adjacent squares.
  2. If there is stench at square (i,j), there is a monster at one of the adjacent squares.
  3. If there is a pit at square (i,j), there is breeze at all adjacent squares.
  4. If there is breeze at square (i,j), there is a pit at one or more of the adjacent squares.
  5. There is one and only one monster (no more, no fewer).
  6. Squares (1,1), (1,2), (2,1), (2,2) have no monsters and no pits.
  7. The number of pits can be between 1 and 11.
  8. We don't care about gold, glitter, and arrows, there will be no information about them in the knowledge base, and no reference to them in the statement.

Sample code

Files check_true_false.cpp and check_true_false.h implement a system that reads text files containing information for the knowledge base and the statement whose truth we want to check. Feel free to use that code and build on top of it. Also feel free to ignore that code and start from scratch in Java, C++, or Lisp.

Extracting symbols and evaluating sets of assignments

Note that, as stated below in the grading specifications, you need to include, in your code, specific functions that perform the following:

Choices for Inference

You can implement any inference algorithm you want. Efficiency will not be considered for grading (except for the extra credit competition). You are also free to use first-order logic instead of propositional logic. However, you should note that the sample code uses propositional logic, and that in general it will probably be easier if you stick to propositional logic. Also, EVEN IF YOU DECIDE TO USE FIRST-ORDER LOGIC, YOUR PROGRAM STILL HAS TO WORK WITH INPUT FILES THAT USE PROPOSITIONAL LOGIC AS EXPLAINED ABOVE.

Efficiency

Brute-force enumeration of all possible assignments to the Boolean variables will be too inefficient to produce answers in a reasonable amount of time. You should look closely at question 3 of the third written assignment, and integrate the answer to that question into your implementation. If you do that correctly, your program should produce answers in a reasonable amount of time (like a few seconds) when the agent has already visited 10 or more squares (and has added the information collected from those squares to the knowledge base that you will use as input).

Efficiency Contest

This contest is not part of the CSE 4308 assessment, and is for extra credit only. People who wish to participate should explicitly state that in their submitted readme.txt file. We will test participating submissions by timing them on several different inputs. The five submissions with the fastest average time will be awarded 30, 25, 20, 15, and 10 extra credit points respectively. Submissions will be automatically excluded if their wumpus_rules.txt file is not correct, or if any of the answers they provide is wrong.

Interim report

The interim report is optional for this assignment. Still, you are welcome to submit one, as an e-mail message that you should send by Monday, October 20, 11:59pm, containing the following: Although the interim report is optional for this assignment, starting early and identifying potential bottlenecks by the deadline for the interim report is probably a good strategy for doing well in this assignment.

Grading

The assignment will be graded out of 100 points. There is also extra credit. Extra credit points are used at the end of the semester, after grade thresholds have been determined, to adjust cumulative course scores and possibly give higher grades when the adjusted cumulative scores reach the threshold for a higher grade. The upper limit on extra credit points for this assignment is 30. However, the extra credit points cannot be counted towards the requirement of achieving a score of at least 60% on the CSE4308 assessment.

Late submissions incur an initial penalty of 10 points, plus additional 10 points for each full 24 hours between the deadline and the submission.

How to submit

Implementations in LISP, C, C++, and Java will be accepted. If you would like to use another language, please first check with the instructor via e-mail. Points will be taken off for failure to comply with this requirement.

Submit a ZIPPED directory called programming3.zip (no other forms of compression accepted, contact the instructor or TA if you do not know how to produce .zip files) via e-mail to BOTH THE INSTRUCTOR AND THE TA, with subject "CSE 4308 - Programming Assignment 2", or "CSE 5360 - Programming Assignment 2", depending on the course you are actually registered for. THE ATTACHMENT SHOULD NOT EXCEED 800KB in size (contact the instructor if for some reason you find it hard to comply with the 800KB limit). The directory should contain source code, and your wumpus_rules.txt file. Including binaries that work on omega (for Java and C++) is optional and encouraged. The submission should also contain a file called readme.txt, which should specify precisely:

Insufficient or unclear instructions will be penalized by up to 20 points. Code that does not run on omega machines gets AT MOST half credit (50 points).

Submission checklist