pacworld
Class PackageState

java.lang.Object
  extended by agent.State
      extended by pacworld.PackageState

public class PackageState
extends State

Represents a state in the package world.


Constructor Summary
PackageState()
          Construct a new package state.
 
Method Summary
 boolean bumped(Agent a)
          Return true if the agent bumped into an obstacle on its previous move.
 void display()
          Print an output of the state to the screen.
 void dropPackage(Agent a, int dropX, int dropY)
           
 java.util.Collection<PacAgentRep> getAgentReps()
           
 int getAgentX(Agent a)
          Return the X location of the specified agent.
 int getAgentY(Agent a)
          Return the Y location of the specified agent.
 Location[] getDestinations()
           
 int getIdleCount()
           
static PackageState getInitState(java.util.List<Agent> agts, int numPackages, int numDests, int mapSize)
          Return a random initial state for the vacuum world.
static PackageState getInitState(long seed, java.util.List<Agent> agts, int numPackages, int numDests, int mapSize)
          Use the given seed to generate a pseudo-random initial state for the vacuum world.
 java.lang.Object[][] getMap()
          Returns the map.
 int getMapSize()
           
 int getMessageCount()
           
 java.lang.String[] getMessages()
           
 int getNonProductiveCount()
           
 int getNumPackages()
           
 java.lang.Object getObjectAt(int x, int y)
          Return the object located at the specified location.
 int getOrigNumPackages()
           
 int getPacCount()
           
 Package getPackageHeldByAgent(Agent a)
          Return the package (if any) held by the specified agent.
 java.util.List<Package> getPackages()
           
 long getTotalMessageLength()
           
 int getWorkCount()
           
 boolean hasObstacle(int x, int y)
          Return true if the specified location has an obstacle in it.
 boolean inBounds(int x, int y)
          Return true if the location is within bounds of the state's map.
 void pickup(Agent a, Package p)
          Modify the state so that the agent is holding the selected package.
 void printState()
           
 void repositionAgent(Agent a, int newX, int newY)
          Change the agent's position.
 void repositionPackage(Package p, int newX, int newY)
          Change a package's position.
 void setBump(Agent a, boolean bump)
          Set an indicator that the robot bumped into an obstacle during its previous move.
 void setGUI(PacGUI pg)
           
 void setIdleCount(int ic)
           
 void setMessage(Agent a, java.lang.String s)
          Set whatever message was said by the agent in its previous move.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PackageState

public PackageState()
Construct a new package state.

Method Detail

getInitState

public static PackageState getInitState(long seed,
                                        java.util.List<Agent> agts,
                                        int numPackages,
                                        int numDests,
                                        int mapSize)
Use the given seed to generate a pseudo-random initial state for the vacuum world.


getInitState

public static PackageState getInitState(java.util.List<Agent> agts,
                                        int numPackages,
                                        int numDests,
                                        int mapSize)
Return a random initial state for the vacuum world.


printState

public void printState()

getAgentX

public int getAgentX(Agent a)
Return the X location of the specified agent.


getAgentY

public int getAgentY(Agent a)
Return the Y location of the specified agent.


getPackageHeldByAgent

public Package getPackageHeldByAgent(Agent a)
Return the package (if any) held by the specified agent. If the agent is not holding a package, return NULL.


pickup

public void pickup(Agent a,
                   Package p)
Modify the state so that the agent is holding the selected package. If the package is already held by an agent, then do nothing.


repositionAgent

public void repositionAgent(Agent a,
                            int newX,
                            int newY)
Change the agent's position. Update both the list of agent locations and the map.


repositionPackage

public void repositionPackage(Package p,
                              int newX,
                              int newY)
Change a package's position. Update the package's location and the map.


setBump

public void setBump(Agent a,
                    boolean bump)
Set an indicator that the robot bumped into an obstacle during its previous move.


hasObstacle

public boolean hasObstacle(int x,
                           int y)
Return true if the specified location has an obstacle in it.


getObjectAt

public java.lang.Object getObjectAt(int x,
                                    int y)
Return the object located at the specified location. If there is no object there, returns null.


bumped

public boolean bumped(Agent a)
Return true if the agent bumped into an obstacle on its previous move.


inBounds

public boolean inBounds(int x,
                        int y)
Return true if the location is within bounds of the state's map.


dropPackage

public void dropPackage(Agent a,
                        int dropX,
                        int dropY)

getNumPackages

public int getNumPackages()

getOrigNumPackages

public int getOrigNumPackages()

getMapSize

public int getMapSize()

getIdleCount

public int getIdleCount()

setIdleCount

public void setIdleCount(int ic)

getPackages

public java.util.List<Package> getPackages()

getAgentReps

public java.util.Collection<PacAgentRep> getAgentReps()

getMessages

public java.lang.String[] getMessages()

getDestinations

public Location[] getDestinations()

getWorkCount

public int getWorkCount()

getPacCount

public int getPacCount()

getMessageCount

public int getMessageCount()

getTotalMessageLength

public long getTotalMessageLength()

getNonProductiveCount

public int getNonProductiveCount()

setMessage

public void setMessage(Agent a,
                       java.lang.String s)
Set whatever message was said by the agent in its previous move.


display

public void display()
Print an output of the state to the screen.

Specified by:
display in class State

setGUI

public void setGUI(PacGUI pg)

getMap

public java.lang.Object[][] getMap()
Returns the map. This is needed for the CustomPanel class.