FJK Home CPE 481 Syllabus Schedule Lecture Notes Assignments Project Other Links
CPE 481 Knowledge-Based Systems Winter 2003

CPE 481Knowledge-Based SystemsWinter 2003 Assignment 2: Wumpus World in Jess

Points 35
Deadline March 6
Most of you will remember (fondly, I hope ;-) the Wumpus World environment that we used in CPE 480 for the explanation of various concepts about Artificial Intelligence and intelligent agents. In this assignment, you will utilize Jess to represent knowledge about the Wumpus World, and to reason about it.

The Wumpus World

The basic setup for this assignment is the Wumpus World as introduced in Chapter 7.4 of the 480 textbook Artificial Intelligence: A Modern Approach by Stuart Russell and Peter Norvig;
Prentice Hall, 1995. ISBN 0-13-103805-2. (Note: In the meantime, the second edition of this book is out. As far as I can tell after a quick look at it, this particular chapter has not changed much.)

The Wumpus World in Jess

The core system for the Wumpus World is available through the file ww.jess, in combination with some sample files that provide facts for a particular instance of the Wumpus World, such as cave0.jess, cave1.jess, cave2.jess, cave3.jess. The log below shows an example of the WW simulator for the cave0.jess instance. It assumes that you're running Jess from the directory that contains the Wumpus World files.
% jess
Jess, the Java Expert System Shell
Copyright (C) 1998 E.J. Friedman Hill and the Sandia Corporation
Jess Version 6.0b3 11/2/2001
This copy of Jess will expire in 8 day(s).
Jess> (batch ww.jess)
TRUE
Jess> (batch cave0.jess)
TRUE
Jess> (reset)
TRUE
Jess> (run)
GENESIS...
Xena enters the caves at (1,1).
Adding adj asserts for a 4 by 4  world.
SIMULATING...
SENSING...
Xena notices (1,2) nearby.
Xena notices (2,1) nearby.
Xena sees no glitter.
Xena feels no breeze in (1,1).
Xena smells nothing.
THINKING...
...

Related Work

Over the last few years, some other people have developed implementations of the Wumpus World. Most of them use Java, not Jess.

Your Tasks

The example system works fine in most of the provided cave instances, but not for cave3.jess. You need to modify the system as described below.

Improve the Hunter's Reasoning Ability

Jess is not an ideal language for formal, logical reasoning. The current code has these rules to draw conclusions from sensing a stench in a cave.
(defrule evaluate-stench
  (task think)
  (cave (x ?x)(y ?y)(stench TRUE))
  (adj ?x ?y ?x2 ?y2)
  ?f <- (cave (x ?x2)(y ?y2)(has-wumpus UNKNOWN))
  =>
  (printout t "With stench in (" ?x "," ?y "), maybe the wumpus is in (" ?x2  "," ?y2 ")." crlf)
  (modify ?f (has-wumpus MAYBE)))
It marks every adjacent cave to the stench as possibly containing a wumpus (except for caves that we already know are wumpus free or have a wumpus in them). But, we need to make a stronger statement. Not only could one of the caves have a living wumpus, one of them must have it. As we learn more information about the cave, we may be in a situation in which there is only one adjacent cave left that might have a wumpus. If so, then it does have a wumpus. Your task is to add a rule or rules to allow the system to deduce the exact location of the wumpus when possible. Do the same for pits. You might find Jess's query facility useful in this.

New Top Level Goal -- Killing the Wumpus

The hunter in the current system has just one goal -- to explore the caves until she finds and picks up the gold, then leave the caves. Extend the system to add another goal -- killing the wumpus. To do this, we suggest you add another slot to the hunter to represent the number of arrows she has:

(deftemplate hunter "A hunter"
  (slot agent (default "Xena"))
  (slot x (type INTEGER))
  (slot y (type INTEGER))
  (slot gold (default 0)(type INTEGER))
  (slot alive (default TRUE))
  (slot arrows (type INTEGER)(number 1))

Add a new action, shoot, which uses up an arrow. If the hunter is in a cave immediately adjacent to a cave with a wumpus, then that wumpus will die a horrible, and deserved, death. Dead wumpi will continue to stink, but the are not dangerous. If the hunter enters a cave with a wumpus corpse, she will not die, although the stench will be hard to get out of her clothes. The goal of the hunter is now to find some gold and kill the wumpus (in either order) and then leave the caves.

Improve the Hunters Ability to Go to a Given Location.

Study the hunters behavior in the world defined by cave3.jess. You will notice that the technique we've used to get the hunter to a distant cave does not work and she is stuck in a cave and can't figure out what to do. Add improved rules to deal with such cases so that the hunter can form a goal to go to a distant cave and will do so, if possible.

Extra Credit: Allow the Wumpus to Move

In this variation, both the hunter and the wumpus can move. If both end up on the same square, the hunter gets eaten. The wumpus also can fall into pits, and can hear the hunter from adjacent squares. It does not perceive any smells. You can give the wumpus different motivations: it could just amble around the environment and snack on a hunter if it happens to encounter one, or it could have an explicit goal to go after the hunter. Please state the motivation your wumpus uses in your documentation. If you decide to tackle this, create another version of the file ww.jess according to the naming conventions below.

Submission

You should hand in two (or three) versions of the modified ww.jess file, named ww-username-1.jess, ww-username-2.jess, ww-username-3.jess. You should develop the versions incrementally: Version 2 should utilize the modifications of version 1. However, if you are unable to complete a working solution for one version, you can develop an independent solution for the other version(s). If this is the case, you need to clearly state that in your documentation. In addition to the code, you also need to submit transcripts (log files) or your agent's journey through the sample caves.
I will use the following grading guidelines:


FJK Home CPE 481 Syllabus Schedule Lecture Notes Assignments Project Other Links
© 2025
Franz Kurfess