This project contains a simulator and agent for a Wumpus World. Wumpus World is a problem discussed in Artificial Intelligence: A Modern Approach, a university textbook on artificial intelligence.
The simulator and user interface is written in Java. The logic for controlling the agent is implemented in Prolog. The open source Projog library is used to integrate Java with Prolog.
The images used by the application are taken from Bootstrap Icons, which is licensed under the MIT license.
You can build the application using the command:
./mvnw package
You can then run the application using the command:
java -jar target/prolog-wumpus-world-0.1.0-SNAPSHOT.jar
The world consists of a 4x4 grid of squares. The squares can contain the following items:
- Agent. The agent moves around the 4x4 grid. The agent has an arrow that they can fire once.
- Gold. If the agent enters a square that contains the gold then the agent can take it.
- A wumpus. If the agent enters the square that contains the wumpus, and the wumpus is alive, then the agent is eaten and cannot continue. If the agent fires the arrow and the square immediately in front of the agent contains the wumpus then the wumpus dies.
- Pits. If the agent enters a square that contains a pit then the agent falls into it and cannot continue.
- Walls. If the agent attempts to enter a square that contains a wall then they will not be able to.
The wumpus, pits and walls are static - they remain in the same square they were allocated to when the world was created.
The aim of the problem is to navigate the agent around the world to:
- Find the square that contains the gold.
- Take the gold.
- Return to the square that the agent started from.
- Climb out of the world.
To interact with the world the agent can perform the following actions:
FORWARD
Move into the square directly in front of where the agent is facing.RIGHT
Turn right.LEFT
Turn left.TAKE
Take the gold. Can only do this if in the same square as the gold.FIRE
Fire the arrow. Can only do this if have not already fired the arrow.CLIMB
Climb out of the world. Can only do this if located in the square the agent started from.
To help the agent reason about the world it receives percepts. The percepts the agent can receive are:
STENCH
Indicates that the agent is next to a square that contains the wumpus or in the square that contains the wumpus.BREEZE
Indicates that the agent is next to a square that contains a pit.GLITTER
Indicates that the agent is in the same square as the gold.BUMP
Indicates that the agent's previous action (to move forward) caused them to bump into a wall.BREEZE
Indicates that the agent's previous action (to fire the arrow) killed the wumpus.
If someone would like to implement their own logic to navigate the agent around the world then they can do so by:
If implementing the logic using Prolog then they can replace the logic in src/main/resources/prolog/wumpus.pl
. They will need to provide a reset_agent_state/0
predicate which resets the agent's game state and a process/2
predicate. The first argument of process/2
will be a list of percepts. The second argument will be a variable that should be unified with an atom that indicates which action the agent should perform next.
If implementing the logic in a different language than Prolog then they will need to implement their own version of org.projog.wumpus.GameController
. They will then need to alter org.projog.wumpus.WumpusWorld
to create an instance of their implementation instead of PrologGameController
.