FJK Home | CPE/CSC 480 | Syllabus | Schedule | Lecture Notes | Assignments | Labs | Project | Teams |
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.
Keep in Mind...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. |
getPerformanceValue() | Returns the performance value, calculated by the equation: Performance Value = (Life Points) - (Search Cost) - (Movement Cost) + (Gold Points) |
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, in the following order of priority:
- It is checked if the agent hit a wall
- It is checked if the agent entered a node with a Wumpus minion in it
- If so, the agent loses 1,000 life points and is notified
- It is checked if the agent entered a node with a pit or the Wumpus
- If so, the agent loses all remaining life points and the game ends
- It is checked if the agent entered a node with the gold
- If so, the agent gains 10,000 gold points and the game ends
- Messages are logged according to what happened to the agent
- Agent hits a wall: "* Bonk! That's a wall! *"
- Agent finds a Wumpus minion: "* You were attacked! *"
- Agent falls into a pit or finds the Wumpus: "* You died! *"
- Agent finds the gold: "* You found the gold! *
There is a known limitation with this environment if an agent encounters a Wumpus minion next to a wall and then moves into the wall. This will cause the HURT value to be returned and the HIT_WALL value to be lost to the agent. However, all of the maps included with this environment make sure not to have a Wumpus minion adjacent to a wall.
- HURT: The agent encountered a Wumpus minion
- DIED: The agent encountered a pit or a Wumpus
- HIT_WALL: The agent hit a wall in the direction it moved
- SAFE: The agent encountered no problems moving
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 agent 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.
getDistanceToGold() Returns the integer number of nodes away the gold is from the agent's current node, disregarding walls or additional costs. getDirectionOfGold() Returns the integer direction of where the gold is from the agent's current node. getDistanceToGold(Node) Returns the integer number of nodes away the gold is from the given node, disregarding walls or additional costs. getDirectionOfGold(Node) Returns the integer direction of where the gold 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:
fireArrow(int) | Returns an integer representing if the arrow hit anything between the agent and the first wall the arrow encounters or would encounter in the direction specified. |
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:
getBelief(int type) Returns the integer belief of the given integer type that the agent has specified for the agent's current node. getBelief(Node, int type) Returns the integer belief of the given integer type that the agent has specified for the given node. getBelief(int direction, int type) Returns the integer belief of the given integer type the agent has specified for the node adjacent to the agent's current location in the given integer direction. getBelief(Node, int direction, int type) Returns the integer belief of the given integer type the agent has specified for the node adjacent to the given node in the given integer direction. setBelief(int type, int belief) Sets the integer belief of the given integer type for the agent's current node. setBelief(Node, int type, int belief) Sets the integer belief of the given integer type for the given node. setBelief(int direction, int type, int belief) Sets the integer belief of the given integer type for the node adjacent to the agent's current location in the given integer direction. setBelief(Node, int direction, int type, int belief) Sets the integer belief of the given integer type for the node adjacent to the given node in the given integer direction.
The integer belief types are as follows:
The integer belief values are as follows:
- SAFE_HERE
- MINION_HERE
- PIT_HERE
- WUMPUS_HERE
- GOLD_HERE
- WALL_HERE
As a note, the agent must set a belief for a node before it can get the belief for that node. Also, a node can have any and all of the belief types specified about it, not being limited to one.
- UNKNOWN: All node beliefs are set to this at initialization, because the agent does not know anything yet
- NO: The agent believes a belief type is false for a particular node
- MAYBE: The agent is not sure if a belief type is true or false for a particular node
- YES: The agent believes a belief type is true for a particular node
For example, if the agent thinks that the node north of where the agent currently is could contain the Wumpus, it could call setBelief(NORTH, WUMPUS_HERE, MAYBE). Also, if the agent arrives on a node and finds that it does not contain anything on it, it could call setBelief(SAFE_HERE, YES). Finally, if the agent wanted to remember if the eastern adjacent node to node 'myNode' might have a pit in it, it could call getBelief(myNode, EAST, PIT_HERE).
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 setBelief(NORTH, WUMPUS_HERE, MAYBE), then "W?" will appear on the agent's map north of where the agent currently is. Also, if the agent calls setBelief(SAFE_HERE, YES), then nothing will appear on the agent's map because the agent has already been to its current location. Even though nothing will visually appear on the map if the agent has been there already, it can still be useful for your agent to store its beliefs regardless.
For your own reference, the priority of belief types that appears on the map is in the following order from highest to lowest priority: WALL_HERE, GOLD_HERE, WUMPUS_HERE, PIT_HERE, MINION_HERE, SAFE_HERE. 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 or else the agent may become confused because of conflicting information (depending on your implementation). In general, when a new belief is set, it does not affect other belief types, so make sure that your agent's beliefs are updated correctly.
FJK Home | CPE/CSC 480 | Syllabus | Schedule | Lecture Notes | Assignments | Labs | Project | Teams |
Franz Kurfess |