edu.sc.ants
Class Environment.RunningThingContainer

java.lang.Object
  |
  +--edu.sc.ants.Environment.RunningThingContainer

public class Environment.RunningThingContainer
extends java.lang.Object

Contains all the running things (i.e. agents) objects, their threads, and messages (mbox)


Field Summary
(package private)  int currentID
          Each agent gets a currentID taken from this variable.
(package private)  java.util.Vector runningThings
          Contains all the running things
 
Constructor Summary
(package private) Environment.RunningThingContainer()
           
 
Method Summary
 void addAgent(Environment e, int x, int y, double h, java.lang.String type)
          Create a new agent and add it to the environment
 boolean deleteAgent(int id)
          Delete an agent with the given ID.
 boolean deleteAgent(java.lang.String type)
          Delete the agent that was last picked.
(package private)  Environment.RunningThing getAgent(int agentID)
          Look for an agent.
(package private)  Observation getAgentLocation(int agentID)
          Look for an agent.
(package private)  Observation getAgentLocationCopy(int agentID)
          Look for an agent.
 java.util.Vector getCloseAgents(int agentID, double range)
          Get all the agents that are close to agentID, including itself
 java.util.Vector getCloseRunningThings(int agentID, double range)
          Get all the agents that are close to agentID, not including agentID
 int getCurrentID()
          Get the value of currentID.
(package private)  Message getMessage(int agentID)
          Get the message of the given agent
 java.util.Vector getRunningThings()
          Get the value of runningThings.
 void setCurrentID(int v)
          Set the value of currentID.
 void setRunningThings(java.util.Vector v)
          Set the value of runningThings.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

runningThings

java.util.Vector runningThings
Contains all the running things

currentID

int currentID
Each agent gets a currentID taken from this variable. This variable only increases. Even if agents are deleted the new ones will get bigger numbers so as not to confuse them with the dead ones.
Constructor Detail

Environment.RunningThingContainer

Environment.RunningThingContainer()
Method Detail

getRunningThings

public java.util.Vector getRunningThings()
Get the value of runningThings.
Returns:
Value of runningThings.

setRunningThings

public void setRunningThings(java.util.Vector v)
Set the value of runningThings.
Parameters:
v - Value to assign to runningThings.

getCurrentID

public int getCurrentID()
Get the value of currentID.
Returns:
Value of currentID.

setCurrentID

public void setCurrentID(int v)
Set the value of currentID.
Parameters:
v - Value to assign to currentID.

addAgent

public void addAgent(Environment e,
                     int x,
                     int y,
                     double h,
                     java.lang.String type)
Create a new agent and add it to the environment

deleteAgent

public boolean deleteAgent(java.lang.String type)
Delete the agent that was last picked.
Parameters:
type - the type of the agent to be deleted
Returns:
true if one was deleted, false if no agents of the given type were found.

deleteAgent

public boolean deleteAgent(int id)
Delete an agent with the given ID.
Parameters:
id - of the agent we want to delete.
Returns:
true if one was deleted, false if no agents of the given type were found.

getAgent

Environment.RunningThing getAgent(int agentID)
Look for an agent.
Parameters:
agentID - the ID of the agent to look for.
Returns:
the RunningThing that encapsulates that agent.

getMessage

Message getMessage(int agentID)
Get the message of the given agent

getAgentLocation

Observation getAgentLocation(int agentID)
Look for an agent.
Parameters:
agentID - the ID of the agent to look for.
Returns:
an observation that contains agentID's real location. Returns null if agentID does not exist.

getAgentLocationCopy

Observation getAgentLocationCopy(int agentID)
Look for an agent.
Parameters:
agentID - the ID of the agent to look for.
Returns:
an copy of the observation that contains agentID's real location. Returns null if agentID does not exist.

getCloseRunningThings

public java.util.Vector getCloseRunningThings(int agentID,
                                              double range)
Get all the agents that are close to agentID, not including agentID
Parameters:
agentID - the agent in the middle
range - the radius of the agent's radar.
Returns:
A vector of RunningThing, containing all the agents in the radius range

getCloseAgents

public java.util.Vector getCloseAgents(int agentID,
                                       double range)
Get all the agents that are close to agentID, including itself
Parameters:
agentID - the agent in the middle
range - the radius of the agent's radar.
Returns:
A vector of Observation, containing all the agents in the radius range