wworld
Class Environment

java.lang.Object
  |
  +--wworld.Environment

public class Environment
extends java.lang.Object

This class contains the information about the objects and agents that are contained within the wumpus world grid. It provides methods to retrieve and manipulate the information contained within it.


Constructor Summary
Environment()
          Constructor
 
Method Summary
 java.util.Vector[][] getGridImage()
          Returns the gridImage representing the Wumpus World environment.
 java.util.Vector getObjectAtLocation(int x, int y)
          Returns the vector of objects at grid location (x, y).
 int getSize()
          Returns the dimension of the world.
 int getWumpusAt(GridPoint gp)
          Returns an integer indicating the position of a wumpus at a certain gridpoint, if at all the location contains a wumpus.
 int getWumpusFacing(GridPoint gp)
          Returns the direction or facing of the wumpus if there is a wumpus at (x, y).
 boolean isDeadly(GridPoint gp)
          Determines if a grid location is deadly for any agent entering it.
 boolean isGoldAt(GridPoint gp)
          Returns true if there is gold at the grid location gp.
 boolean isGoldAt(int x, int y)
          Returns true if there is gold at the location (x,y)
 boolean isObstacleAt(int x, int y)
          Returns true if there is a obstacle at location (x, y).
 boolean isPitAt(int x, int y)
          Returns true if there is a pit at location (x, y).
 boolean isPitNear(GridPoint gp)
          Returns true if there is a pit in the 4 squares surrounding the grid point.
 boolean isValid(GridPoint gp)
          Determines whether a given gridpoint is within the bounds of the world.
 boolean isWumpusAt(int x, int y)
          Returns true if there is a wumpus at (x, y).
 boolean isWumpusNear(GridPoint gp)
          Returns true if there is a wumpus in the 4 squares surrounding the grid point.
 void printEnvironment()
          Prints out the summary of the environment on standard output.
 void processWumpi()
          Positions the wumpii to their next calculated location.
 void readWorld(java.io.BufferedReader in)
          Reads in the environment from the input stream in and sets the gridimage according to the objects in the world
 void readWorldFromFile(java.lang.String fileName)
          Populates the environment after reading it from file.
 void removeGoldAt(GridPoint gp)
          Removes gold pieces at location gp.
 void setSize(int s)
          Sets the size of the world.
 void setWumpusTargets()
          Sets targets for wumpii which have a mode that requires them to move to other locations with specific properties.
 boolean shootAtWumpus(GridPoint pt, int orientation)
          Processes the shooting of a wumpus from a location pt by an agent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Environment

public Environment()
Constructor

Method Detail

getSize

public int getSize()
Returns the dimension of the world.

Returns:
worldsize.

getGridImage

public java.util.Vector[][] getGridImage()
Returns the gridImage representing the Wumpus World environment.

Returns:
wumpus world.

printEnvironment

public void printEnvironment()
Prints out the summary of the environment on standard output.


setSize

public void setSize(int s)
Sets the size of the world.


isValid

public boolean isValid(GridPoint gp)
Determines whether a given gridpoint is within the bounds of the world.

Returns:
TRUE if gridpoint within bounds, FALSE otherwise.

isDeadly

public boolean isDeadly(GridPoint gp)
Determines if a grid location is deadly for any agent entering it. A location is deadly if there is a wumpus or a pit at that location.

Returns:
TRUE if wumpus or pit is at the gridpoint, FALSE otherwise.

getObjectAtLocation

public java.util.Vector getObjectAtLocation(int x,
                                            int y)
Returns the vector of objects at grid location (x, y).

Parameters:
x - and y parameters of the location
Returns:
Vector of objects at location (x,y).

readWorld

public void readWorld(java.io.BufferedReader in)
               throws java.io.IOException
Reads in the environment from the input stream in and sets the gridimage according to the objects in the world

java.io.IOException

setWumpusTargets

public void setWumpusTargets()
Sets targets for wumpii which have a mode that requires them to move to other locations with specific properties. For e.g. wumpus with mode GO_TO gold requires a target location with gold in it.


isWumpusAt

public boolean isWumpusAt(int x,
                          int y)
Returns true if there is a wumpus at (x, y).

Returns:
TRUE if wumpus is at (x,y), FALSE otherwise.

getWumpusFacing

public int getWumpusFacing(GridPoint gp)
Returns the direction or facing of the wumpus if there is a wumpus at (x, y). Returns -99 otherwise.

Returns:
facing of the wumpus or -99 if no wumpus.

isWumpusNear

public boolean isWumpusNear(GridPoint gp)
Returns true if there is a wumpus in the 4 squares surrounding the grid point.

Returns:
TRUE if wumpus is in surrounding locations, FALSE otherwise.

getWumpusAt

public int getWumpusAt(GridPoint gp)
Returns an integer indicating the position of a wumpus at a certain gridpoint, if at all the location contains a wumpus.


processWumpi

public void processWumpi()
Positions the wumpii to their next calculated location. Called at the end of each step in the simulator.


shootAtWumpus

public boolean shootAtWumpus(GridPoint pt,
                             int orientation)
Processes the shooting of a wumpus from a location pt by an agent.

Returns:
TRUE if wumpus is shot, FALSE otherwise.

isPitAt

public boolean isPitAt(int x,
                       int y)
Returns true if there is a pit at location (x, y).

Returns:
TRUE if pit is found at (x,y), FALSE otherwise.

isPitNear

public boolean isPitNear(GridPoint gp)
Returns true if there is a pit in the 4 squares surrounding the grid point.

Returns:
TRUE if pit is in surrounding gridpoints, FALSE otherwise.

isGoldAt

public boolean isGoldAt(GridPoint gp)
Returns true if there is gold at the grid location gp.

Returns:
TRUE if the gold is present at the given location, FALSE otherwise.

isGoldAt

public boolean isGoldAt(int x,
                        int y)
Returns true if there is gold at the location (x,y)

Returns:
TRUE if the gold is present at the given location, FALSE otherwise.

isObstacleAt

public boolean isObstacleAt(int x,
                            int y)
Returns true if there is a obstacle at location (x, y).

Returns:
TRUE if the obstacle is at (x,y), FALSE otherwise.

removeGoldAt

public void removeGoldAt(GridPoint gp)
Removes gold pieces at location gp.


readWorldFromFile

public void readWorldFromFile(java.lang.String fileName)
Populates the environment after reading it from file.