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

bumped

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


display

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

Specified by:
display in class State

dropPackage

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

getAgentReps

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

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.


getDestinations

public Location[] getDestinations()

getIdleCount

public int getIdleCount()

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.


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.


getMap

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


getMapSize

public int getMapSize()

getMessageCount

public int getMessageCount()

getMessages

public java.lang.String[] getMessages()

getNonProductiveCount

public int getNonProductiveCount()

getNumPackages

public int getNumPackages()

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.


getOrigNumPackages

public int getOrigNumPackages()

getPacCount

public int getPacCount()

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.


getPackages

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

getTotalMessageLength

public long getTotalMessageLength()

getWorkCount

public int getWorkCount()

hasObstacle

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


inBounds

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


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.


printState

public void printState()

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.


setGUI

public void setGUI(PacGUI pg)

setIdleCount

public void setIdleCount(int ic)

setMessage

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