Programming Assignment 4: Wumpus world in Prolog

Table of Contents

Problem Domain

You will be considering the Wumpus world introduced in Russell and Norvig (2009) Chapter 7. For this programming assignment you’ll use Prolog’s ability to do inference in order to write an agent that will make safe moves within its world.

Project Infrastructure

You will need to download and install your own version of SWI-Prolog. It is freely available from for major operating systems. Major Linux distributions have copies available within their package system.


The code for this project consists of several Prolog files, some of which you will need to read and understand in order to complete the assignment. You can download all the code and supporting files as a zip archive.

Files you'll edit: This is an empty skeleton program. Your assignment is to flesh out the details.
Files you want to look at: The main file that describes the wumpus world. Useful for implementing the algorithms.

Running the code

Start SWI-Prolog:
Load the world simulator:
?- [wumpus_world].
Load the agent:
?- [my_agent].
Run the agent:
?- evaluate_agent(1, Score, Time).
Correct to: "wumpus:evaluate_agent(1, Score, Time)"? y

If you read the output, you’ll see the default agent just moves forward. It does this in the world shown in Russell and Norvig’s Figure 7.2, which causes the agent’s dead rather soon. (You use ˆD to exit the programming environment.)

You will need to edit produce a more rational movement. To do this you will need to define an intelligent run_agent(Percept,Action). The percepts are provided as a list of five elements [Stench, Breeze, Glitter, Bump, Scream], where you receive a “yes” or a “no” in the respective position. There is also an init_agent function which you can use for initialization.

The simulator knows the total state of the world, while your agent will know only what it senses through its perceptions. Initially the agent knows only the perceptions in position (1,1) and in order to acquire other information must be moved in other cells of the grid. Your agent must maintain its own state, containing all the information that gradually becomes available. The state will have to be update with the new perceptions every time an action is executed, and this information must be represented so as to permit reasoning (via interference) as to what operations are safe.


Submit your assignment via TAMU eCampus using these submission instructions

  • Files to include in zip file:
    • The code you wrote for this assignment.
    • A short README.txt file with the following information:
      • Name: (Your name)
      • UIN: (Your TAMU UIN)
      • A description of how to run the submission.
      • A list of the resources used (e.g., online forums, links to example code on the web, etc.).
      • A statement of the Aggie Code of Honor.
      • Additional comments: ...

You may discuss this openly with your friends and classmates, but are expected to write your own code and compile your submission independently. If in doubt about whether a resource you used should be included in the list of resources, err on the side of caution and include it.

Academic Integrity: "An Aggie does not lie, cheat, or steal, or tolerate those who do." For additional information please visit:

Getting Help: You are not alone! If you find yourself stuck on something, contact the TA for help. Office hours are there for your support; please use them. If you can't make our office hours, let us know and we will schedule more. We want these projects to be rewarding and instructional, not frustrating and demoralizing. But, we don't know when or how to help unless you ask.