version: $Id: project3.txt,v 1.3 2006/11/12 19:48:36 ioerger Exp $ CPSC 625 Fall 2006 Final Project In this project, you will be implementing a knowledge-based decision-making procedure for an agent in a simulation of the Wumpus World in Prolog. You will have to download and install your own local version of SWI Prolog. (http://www.swi-prolog.org/). Attached are two files: wumpus.pl, and agent.pl. wumpus.pl defines how the wumpus world works, computes the effects of actions, determines what senses are perceived, and keeps track of the score. You may not manipulate wumpus.pl, nor use any of the internal state information. agent.pl is a starter file that defines a simple decision-making procedure based only on the senses the agent perceives, which you should extend or modify with your own rules. Important functions wumpus.pl that you can call are: reset, show, and do. reset generates a new random configuration of the world. Show will give a simple visual representation, and print out some info like what direction the agent is facing and what it is holding. However, this information is not available to the agent; the agent only has access to the basic senses (like stench, glitter, and bump). calling do(Action) will change the state, retract and assert new senses, and show the result. In agent.pl, a simple driver is called go(N), where you can specify a certain number of steps. It calls decide(Action) to pick the most desirable action in the current state and execute it (call do). Right now, it just picks up gold when it can, and otherwise does a random move (forward, or turn left or right). Your job is to flesh out decide so the agent makes more intelligent decisions and gets the highest score possible. You might to choose a different stopping criterion for go, such as going until either the score has become >100 or =-1000, or stopping once both gold has been collected and wumpus killed, as opposed to just going a finite number of steps. Part of this task requires inferring (and remembering) the effects of actions. The case of holding(gold) is given as an example. There is a rule which infers it when see glitter and the action is pickup(gold); if satisfied, holding(gold) is asserted (and since there is no putdown action, it remains true thereafter). In agent.pl, and clock (counter) called now(X) is provided called, which gets incremented with each action taken. You can use this to remember time-specific facts, like when a room was visited or when the wumpus was killed. The action(Act,Time) is an example of this, which is automatically asserted by my_do, which is a wrapper around do. Here are the specific rules of this version of the wumpus world. There is 1 gun (U), 1 gun (G), 1 wumpus (W), and more than one pits (P). The cave will have dimensions MxN (don't assume 4x4), but the agent will initially be in a random (!) location. Therefore, you will have to rely on 'bump' for feedback, and keep track of (relative) location on your own (perhaps as "offsets" from initial coordinate like 0,0). I'm not sure if this helps, but you can assume the agent will be facing north to start with. The actions available are: forward, turn(left), turn(right), shoot, pickup(gold), pickup(gun). You have to be in the same room to pick something up. It will be carried (even both at the same time - there is no exclusion) thereafter, and there is no putdown operation. The gun only has 1 bullet, so it can only be fired once, and to kill the wumpus, you have to be adjacent to it and facing it. The senses, which are the only feedback about the state you may use are: glitter, breeze, stench, see_gun, bump, scream. As in the book, stench and breeze are felt in rooms adjacent to the wumpus or a pit, respectively. You only see glitter (or gun) if you are in the same room as the gold (gun). You may not query the state to determine any other information, such as the location of the agent, wumpus, gold, or pits. Nor may you query what direction you are facing, what you are holding, whether the wumpus is alive, etc. You have to keep track of all this yourself, based on the sense and your actions. Reset will NOT guarantee that all objects are initially in unique locations. However, overlaps should be rare, and we'll consider them uninteresting special cases. Don't bother designing rules for them; you can even ignore them if you like (just reset again). The score(N) of the agent is updated as follows: +100 for picking up gold or shooting the wumpus, -1000 for enter room with the wumpus or a cave, and -1 otherwise (time-penalty for each step). See the attached transcript for an example. (Note, this is an example of selecting the actions manually using 'do'. Ultimately, you will want your agent to run in an automated mode using 'go'.)