|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--elge.agent.Agent
Agent is a very base class for this environment (Later maybe an interface). Other entities are subclasses of this class.
Agent is defined with its own life cycle invoked with method
life()
. The method runs 3 standartd other methods,
sense()
, memorize()
and chooseAction()
.
To modify the agent behavior, override these methods.
ELGE GUI uses beans standarts to determine properties, so every method pair with get and set prefix will make the parameter available in the GUI.
Field Summary | |
protected Situation |
actualSituation
actualSituation is used to store the Situation that has the agent sensed in his life cycle. |
protected Agency |
agency
Agency is the agency from parent, or only for this agent. |
protected static Class |
agencyClass
What agency is the agent using. |
protected static Hashtable |
agentClassCounter
Use to generate unique ID's for diferent agent classes. |
protected long |
id
The ID of agent. |
protected String |
name
Name of the agent. |
protected boolean |
registered
this is agent's internal state variable to know, it the agent has already be registred in the agency. |
Constructor Summary | |
Agent()
Creates a new instance of Agent |
|
Agent(Agency agency)
Creates agent with agency |
|
Agent(String name)
Creates agent with name name |
|
Agent(String name,
Agency agency)
Creates agent with name and agency |
Method Summary | |
Situation |
ask(Agent to,
String message,
Object params)
like ask(java.lang.String) but tries to ask a specific agent agent |
Situation |
ask(String message)
ask is the method to comunicate to other agents. |
Situation |
ask(String message,
Object params)
As ask, but with some inner Context - params. |
static Agency |
createDefaultAgency()
Creates a default agency from the agencyClass |
static long |
createUniqueID(Class cls)
Used to create uniqe ID's for agent instances, but as it is not realy needed, other part of system uses this method. |
Agency |
getAgency()
Return agency. |
String |
getFullName()
This method should be used to fully identify the agent in the system. |
long |
getID()
id of the agent. |
String |
getName()
Returns name of the agent. |
protected void |
chooseAction()
The last method that is called for the life cycle of agent. |
void |
init()
This method performs initializing of the agent. |
void |
life()
This method performs the agent life cycle. |
void |
life(int times)
Like life, instead the life is called times times. |
protected void |
memorize()
Second method for the life cycle of agent. |
void |
restart()
This method performs restarting the agent. |
protected void |
sense()
First method for the agent life cycle. |
void |
setAgency(Agency agency)
Sets the agency for this agent and also calls register agent on it. |
void |
setAgency(Agent agent)
this mehotd calls setAgency for the param agent, and sets it the agency of this agent. |
void |
setAgency(Enumeration agents)
Like setAgency(elge.agent.Agency) but for enumeration of agents |
void |
setID(long id)
sets the id for the agent. |
void |
setName(String name)
Sets the name for the agent. |
String |
toString()
Converts the agento to string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected Agency agency
protected Situation actualSituation
sense()
protected boolean registered
protected String name
protected long id
getFullName()
protected static Class agencyClass
protected static Hashtable agentClassCounter
Constructor Detail |
public Agent()
public Agent(String name)
name
name
- name of the agentpublic Agent(Agency agency)
agency
agency
- the agency to use to comunicatepublic Agent(String name, Agency agency)
name
and agency
name
- name of the agentagency
- agency for comunicationMethod Detail |
public static long createUniqueID(Class cls)
cls
- class for which to get next id.
getID()
,
setID(long)
public static Agency createDefaultAgency()
agencyClass
public void setAgency(Agency agency)
agency
- set agency to the agent.Agency.register(elge.agent.Agent)
public void setName(String name)
name
- name of the agentpublic String getName()
public String getFullName()
public long getID()
setID(long)
,
getFullName()
public void setID(long id)
id
- id to set for this agent.getID()
,
getFullName()
public void setAgency(Agent agent)
agent
- agent to set the agency,public void setAgency(Enumeration agents)
setAgency(elge.agent.Agency)
but for enumeration of agents
agents
- Enumeration of agents..
ClassCastException
- if enumeration contains noninstances of class Agentpublic Agency getAgency()
protected void sense()
protected void memorize()
protected void chooseAction()
public void life()
public void restart()
public void init()
public void life(int times)
times
- how many times to call the life cycle.public Situation ask(String message)
message
- message ident string
Agency
public Situation ask(String message, Object params)
message
- action to choose.params
- context in the action is executed.
public Situation ask(Agent to, String message, Object params)
ask(java.lang.String)
but tries to ask a specific agent agent
to
- agent to ask the messagemessage
- message ident stringparams
- some parameters
public String toString()
toString
in class Object
getFullName()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |