elge.agent
Class AgentContainer

java.lang.Object
  |
  +--elge.agent.Agent
        |
        +--elge.agent.AgentContainer
Direct Known Subclasses:
World, WorldAgent

public class AgentContainer
extends Agent

AgentContainer is extended Agent class so, it can hold other agents. It registres itself to its agency, and every added agent has the same agency. Also the life cycle of the AgentContainer is changed.

Ii firstly runs it own life method, and than it calls life method of every agent included in it.

This structure is for making the agents as a group of smaller agents. For example an agent can consist of agents like memory, spectator, action_chooser and so on. Then only change of the one agent can change the whole behavior.

Author:
Pavol Žibrita

Field Summary
protected  AgentRepresentation agents
          This is where the agents are stored.
protected  Agency innerAgency
          InnerAgency is used for the agents included in the container.
 
Fields inherited from class elge.agent.Agent
actualSituation, agency, agencyClass, agentClassCounter, id, name, registered
 
Constructor Summary
AgentContainer()
          Creates a new instance of AgentContainer
AgentContainer(Agency agency)
          Creates a new instance of AgentContainer with agency.
AgentContainer(Agent agent)
          Create new instance and adds one Agent to the agent container
AgentContainer(AgentContainer agentContainer)
          Create new instance from another AgentContainer.
AgentContainer(String name)
          Creates a new instance of AgentContainer with a name.
AgentContainer(String name, Agency agency)
          Creates a new instance of AgentContainer with name and agency
AgentContainer(String name, Agency agency, Agency innerAgency)
          Creates a new instance of AgentContainer with name, agency and inner agency to use.
AgentContainer(String name, Agency agency, Agency innerAgency, AgentRepresentation wr)
          Creates a new instance of AgentContainer with name, agency, inner agency and world representaion
AgentContainer(Vector agents)
          Create new instance and Agents from the vector includes in.
 
Method Summary
 void add(Agent agent)
          adds an agent to the system and sets it the agency.
 void add(Enumeration agents)
          add agents contained in the enumeration.
 void add(Iterator agents)
          add agents contained in the iterator.
 void agentsLife()
          This method runs the life method of all agents inside the container.
 void del(Agent agent)
          removes the agent from the container.
 int getAgentCount()
          Returns the number of Agents in the AgentContainer
 AgentRepresentation getAgents()
          use this method to get the agents from this container.
 void life()
          The life cycle of the AgentContainer is different, because it should handle the angents it sonsist of, and not himeself (but yo may want to do this anyway).
 void setAgents(AgentRepresentation lt)
          Sets AgentRepresentation to this container.
 
Methods inherited from class elge.agent.Agent
ask, ask, ask, createDefaultAgency, createUniqueID, getAgency, getFullName, getID, getName, chooseAction, init, life, memorize, restart, sense, setAgency, setAgency, setAgency, setID, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

innerAgency

protected Agency innerAgency
InnerAgency is used for the agents included in the container.


agents

protected AgentRepresentation agents
This is where the agents are stored.

Constructor Detail

AgentContainer

public AgentContainer()
Creates a new instance of AgentContainer


AgentContainer

public AgentContainer(String name)
Creates a new instance of AgentContainer with a name.

Parameters:
name - name of the agent.

AgentContainer

public AgentContainer(Agency agency)
Creates a new instance of AgentContainer with agency.

Parameters:
agency - agency to use.

AgentContainer

public AgentContainer(String name,
                      Agency agency)
Creates a new instance of AgentContainer with name and agency

Parameters:
name - name of the agent
agency - agency to use

AgentContainer

public AgentContainer(String name,
                      Agency agency,
                      Agency innerAgency)
Creates a new instance of AgentContainer with name, agency and inner agency to use.

Parameters:
name - name of the agent
agency - agency to use.
innerAgency - agency to use for included agents

AgentContainer

public AgentContainer(String name,
                      Agency agency,
                      Agency innerAgency,
                      AgentRepresentation wr)
Creates a new instance of AgentContainer with name, agency, inner agency and world representaion

Parameters:
name - name fo the agent
agency - agency to use
innerAgency - agency to use for included agents
wr - AgentRepresentation to use for the agents storage.

AgentContainer

public AgentContainer(Vector agents)
Create new instance and Agents from the vector includes in.

Parameters:
agents - Vector of Agents

AgentContainer

public AgentContainer(Agent agent)
Create new instance and adds one Agent to the agent container

Parameters:
agent - an Agent

AgentContainer

public AgentContainer(AgentContainer agentContainer)
Create new instance from another AgentContainer. It gets the agents and sets them the local agency.

Parameters:
agentContainer - an AgentContainer
Method Detail

add

public void add(Agent agent)
adds an agent to the system and sets it the agency.

Parameters:
agent - agent to add

del

public void del(Agent agent)
removes the agent from the container.

Parameters:
agent - agent to remove

add

public void add(Iterator agents)
add agents contained in the iterator.

Parameters:
agents - iteration of agents.

add

public void add(Enumeration agents)
add agents contained in the enumeration.

Parameters:
agents - enumeration of agents.

getAgents

public AgentRepresentation getAgents()
use this method to get the agents from this container.

Returns:
returns the AgentRepresentation of agents

setAgents

public void setAgents(AgentRepresentation lt)
Sets AgentRepresentation to this container.

Parameters:
lt - the AgentRepresentation. Can contain agents..

getAgentCount

public int getAgentCount()
Returns the number of Agents in the AgentContainer

Returns:
the number of agents.

life

public void life()
The life cycle of the AgentContainer is different, because it should handle the angents it sonsist of, and not himeself (but yo may want to do this anyway).

Overrides:
life in class Agent

agentsLife

public void agentsLife()
This method runs the life method of all agents inside the container. it is called from the life method.