Making an Agent for the Wumpus Environment

The Wumpus Environment is designed for easy creation of agents. This tutorial will instruct how to begin creating an agent by giving some information about useful methods and classes to use.  Creating the agent is the same as with the Bot Environment, except you now extend WumpusAgent instead of Bot or BotSearch=2E

Keep in Mind...

To get the agent's current location, use getCurrentNode() instead of getBotLocation().  This is because getCurrentNode() takes care of the cost of inquiring about the node while getBotLocation() is used without cost by WumpusAgent.

The starting location for the agent in Wumpus World can be anywhere on the map, so you cannot assume that it will start at location (1,1).

When a map is opened or reset, the reset() method is called in the agent. If the programmer has added any variables or settings to the agent, they should be reset in this method, making sure to call super.reset() first.

Because the environment has changed significantly for the Wumpus World environment, refer to this tutorial instead of the Javadocs for information about Node, WumpusAgent, and Bot.

Because your agent extends WumpusAgent, which extends Bot, all constants listed here (i.e. SAFE, HIT_WALL, etc.) can be used without having to prefix them with Bot or WumpusAgent.  Also, NORTH, EAST, SOUTH, and WEST are also located in Bot, so you do not have to prefix them with SBConstants anymore.

The following point values are used for this assignment:
Performance Value Management

For your convenience, the management of life points, movement costs, search costs, and gold points are taken care of for you.  You can get the values of each of these by calling the following methods:

getMovementCost() Returns the total movement cost of all moves
getSearchCost() Returns the total search costs of getting nodes and asking hints
getLifePoints() Returns the number of life points left of the agent
getGoldPoints() Returns 10,000 if the gold was found, 0 otherwise.

Also, you can find the performance value of the agent by calling the following method:

getPerformanceValue() Returns the performance value, calculated by the equation:
Performance Value =3D (Life Points) - (Search Cost) - (Movement Cost) + (Gold Points)

The performance cost is also displayed in the logger after every agent action.

New Agent Movement Methods

Several modifications have been made to the movement of the agent.  The following methods have been added for your convenience:

moveNorth() Turns the agent to face north and moves forward
moveEast() Turns the agent to face east and moves forward
moveSouth() Turns the agent to face south and moves forward
moveWest() Turns the agent to face west and moves forward

If desired, you can still use turnLeft(), turnRight(), turnTo(int), and moveForward().

A lot happens now when moveForward() is called.  When an agent arrives on a node, the following occurs:
The agent can know about what happened by checking the return value of moveForward().  moveForward() returns the following values, as defined in Bot:

Learning About the Environment

In order to find the gold intelligently, the agent needs to understand its environment.  However, in the Wumpus World, many of the methods in the Node class have been restricted as part of the game.  Now, only the following methods can be used to learn about a particular Node object:

getX(), getY()
Returns the integer x or y coordinate of the node in the map.
getIsTraveled()
Returns true if the agent has traveled on the node before, false otherwise.
getBotIsHere()
Returns true if the agent is currently on this node, false otherwise.
toString() Returns the coordinates of the node in the String, "(x,y)"

You may get the Node the agent is currently on by calling getCurrentNode().

Most information in the Wumpus World is obtained about adjacent nodes.  In a particular node, the agent might "feel a breeze," which means that one of the adjacent nodes contains a pit.  The following methods give general information about adjacent nodes:

nearMinion() Returns true if a node adjacent to the agent's current location contains a Wumpus minion, false otherwise.
nearPit() Returns true if a node adjacent to the agent's current location contains a pit, false otherwise.
nearWumpus() Returns true if a node adjacent to the agent's current location contains the Wumpus, false otherwise.
nearGold() Returns true if a node adjacent to the agent's current location contains the gold, false otherwise.
nearMinion(Node) Returns true if a node adjacent to the given node contains a Wumpus minion, false otherwise.
nearPit(Node) Returns true if a node adjacent to the given node contains a pit, false otherwise.
nearWumpus(Node) Returns true if a node adjacent to the given node contains the Wumpus, false otherwise.
nearGold(Node) Returns true if a node adjacent to the given node contains gold, false otherwise.

Finally, an agent can ask for hints on where the gold is.  You may now call these hint methods directly without SBFunctions, as they are defined in the WumpusAgent base class.

getDistanceToGoal() Returns the integer number of nodes away the goal is from the agent's current node, disregarding walls or additional costs.
getDirectionOfGoal() Returns the integer direction of where the goal is from the agent's current node.
getDistanceToGoal(Node) Returns the integer number of nodes away the goal is from the given node, disregarding walls or additional costs.
getDirectionOfGoal(Node) Returns the integer direction of where the goal is from the given node.

Wumpus Slaying

Sometimes it may be difficult (or impossible) to get to the gold by going around the Wumpus and Wumpus minions.  Your agent has the ability to fire an arrow in any direction, and it will travel until it hits the Wumpus, a Wumpus minion, or a wall (either a regular wall or the map boundaries).  The follow methods fire an arrow:

fireArrowNorth() Returns an integer representing if the arrow hit anything between the agent and the first wall north of the agent.
fireArrowEast() Returns an integer representing if the arrow hit anything between the agent and the first wall east of the agent.
fireArrowSouth() Returns an integer representing if the arrow hit anything between the agent and the first wall south of the agent.
fireArrowWest() Returns an integer representing if the arrow hit anything between the agent and the first wall west of the agent.

The integer values that are returned when firing an arrow are as follows:

Reasoning with Belief

When your agent is performing its reasoning, it is making assumptions or convictions about the environment.  These are called beliefs in the Wumpus Environment.  The agent is able to get and set its beliefs about its current location, the nodes adjacent to its current location, a distant node, and the nodes adjacent to a distant node through using the following methods:

get[TYPE]HereBelief() Returns the integer belief that the agent's current node contains the [TYPE]
get[TYPE]HereBelief(Node) Returns the integer belief that the given node contains the [TYPE]
get[DIRECTION][TYPE]HereBelief() Returns the integer belief that the [DIRECTION] adjacent node to the agent's current node contains the [TYPE]
get[DIRECTION][TYPE]HereBelief(Node) Returns the integer belief that the [DIRECTION] adjacent node to the given node contains the [TYPE]
set[TYPE]HereBelief(int) Sets the integer belief that the agent's current node contains the [TYPE]
set[TYPE]HereBelief(Node, int) Sets the integer belief that the given node contains the [TYPE]
set[DIRECTION][TYPE]HereBelief(int) Sets the integer belief that the [DIRECTION] adjacent node to the agent's current node contains the [TYPE]
set[DIRECTION][TYPE]HereBelief(Node,int) Sets the integer belief that the [DIRECTION] adjacent node to the given node contains the [TYPE]

The values that [TYPE] can take are as follows:
The values that [DIRECTION] can take are as follows:
The integer belief values are as follows:
For example, if the agent thinks that the node above where the agent currently is contains the Wumpus, it could call setNorthernWumpusHereBelief(MAYBE).  Also, if the agent arrives on a node and finds that it does not contain anything on it, it could call setSafeHereBelief(YES).  Finally, if the agent wanted to remember if the eastern adjacent node to node 'A' might have a pit in it, it could call getEasternPitHereBelief(A).

The benefit of using these methods to remember your agent's beliefs is that they will be reflected on the agent's map in the environment for nodes that the agent has not been to yet (on black tiles).  For example, if the agent calls setNorthernWumpusHereBelief(MAYBE), then "W?" will appear on the agent's map north of where the agent currently is.  Also, if the agent calls setSafeHereBelief(YES),  then nothing will appear on the agent's map because the agent has already been to its current location.  Even though nothing will appear on the map if the agent has been there already, it may still be useful for your agent to store its beliefs regardless.

For your own reference, the priority of [TYPE] that appears on the map is in the following order from highest to lowest priority: Wall, Gold, Wumpus, Pit, Minion, Safe.  This is to ensure that if the agent believes, for example, that a node may contain a Wumpus or a Wumpus minion, a "W?" will appear on the map since the Wumpus belief is more significant than displaying belief about a Wumpus minion.  This is mainly for the user's benefit since the agent knows if there are several beliefs on a particular node via the belief accessor methods.

Something important to keep in mind, if the agent's beliefs change about a particular node, remember to update ALL beliefs on that node accordingly.  For example, if the agent sets the belief about a node to be that it is definately safe, but previously it said that the node may have a Wumpus minion on it, the agent must then set the belief about the Wumpus minion on the node to NO; when a new belief is set, it does not overwrite previous beliefs, so make sure that your agent's beliefs are updated correctly.