|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ascape.model.AscapeObject
org.ascape.model.Agent
public class Agent
The base class for all modeled objects in ascape.
Note that an ascape agent is actually a superset of the general
understanding of a software 'agent'. Ascape agents need not be
mobile or autonomous, but are always capable of being so.
For instance, a lattice cell is a subclass of this class and within its
own lattice has no opportunity to move, obviously. The same cell, however,
may move upon some other lattice or collection of agents.
To represent agent state simply provide member variables along with
getters and setters in subclasses, and create StatCollectors to make aggregate values available.
To provide behavior add rules to the parent scape. A simple way to do this is to
override the scapeCreated
method. There are a number of rules that
act simply to call a cooresponding method or methods in Agent. For instance,
METABOLISM_RULE
will call the metabolism
method on
the appropriate agents
.
ITERATE_RULE
is added to the parent scape by default, and calls the
iterate
method, but it is typically preferrable to use more granular
and flexible rules. To get rid of this iterate rule, overide scapeCreated
, or
call clearRules
on the parent scape. You should do this whenever
agent level processing is not required for a given scape; it can take time to iterate
through some scapes, and there is no way for the engine to determine at runtime that
an iterate method is a non-op.
Field Summary | |
---|---|
static Rule |
DEATH_RULE
A rule calling the death method of the target agent. |
static Rule |
FISSIONING_RULE
A rule calling the fissioning method of the target agent. |
static Rule |
FORCE_DIE_RULE
A rule calling the die method of the target agent. |
static Rule |
FORCE_FISSION_RULE
A rule calling the fission method of the target agent. |
static Rule |
FORCE_MOVE_RULE
An rule calling the move method of the target agent, causing the agent to move regradless of what the movement condition method returns. |
static Rule |
INITIALIZE_RULE
A rule causing the target and all its children scapes to be initialized. |
static Rule |
ITERATE_AND_UPDATE_RULE
A rule calling the iterate method on each agent in a scape and then the update method on each agent in a seperate, subsequent step. |
static Rule |
ITERATE_RULE
An rule calling the iterate method of the target agent. |
static Rule |
METABOLISM_RULE
An rule calling the metabolism method of the target agent. |
static Rule |
MOVEMENT_RULE
An rule calling the default movement method of the target agent. |
static Rule |
PLAY_OTHER
A rule causing the target agent to interact with another agent in its scape using the Agent.play() method. |
static Rule |
UPDATE_RULE
A rule calling the update method of the target agent. |
Fields inherited from class org.ascape.model.AscapeObject |
---|
ARBITRARY_SEED, name, scape |
Constructor Summary | |
---|---|
Agent()
|
Method Summary | |
---|---|
void |
clearDeleteMarker()
Resets the marker for deletion. |
java.lang.Object |
clone()
Clones the agent. |
void |
death()
Perform the death rule; if the death condition is met, kill the agent. |
boolean |
deathCondition()
Conditions under which this agent should die. |
void |
die()
"Kill" the agent. |
void |
execute(Rule rule)
Causes the provided rule to be executed upon this agent. |
void |
execute(Rule[] rules)
Causes the provided rules to be executed upon this agent. |
void |
fission()
Override to reproduce agent, creating a new agent. |
boolean |
fissionCondition()
Conditions under which this agent should fission. |
void |
fissioning()
Perform the fissioning rule; if the fission condition is met, fission. |
java.awt.Color |
getColor()
This agent's default color, used by many simple views. |
java.awt.Color |
getColor(java.lang.Object object)
Provides the default color for an agent. |
java.awt.Image |
getImage()
This agent's default image, used by many simple views. |
java.awt.Image |
getImage(java.lang.Object object)
Provides the default image for an agent. |
int |
getIteration()
Returns the current count of iteration. |
Scape |
getRoot()
Gets the rootmost parent scape for this agent. |
void |
initialize()
Initialize any values. |
boolean |
isDelete()
Is this agent marked for deletion?. |
boolean |
isInitialized()
Has this agent been initialized? |
void |
iterate()
Iterate this agent. |
void |
markForDeletion()
Sets the agent to be deleted when the next deletion sweep occurs. |
void |
metabolism()
Performs default metabolism for this agent. |
void |
move()
Override to move this agent based on movement condition. |
void |
movement()
Perform the movement rule; by default, if the movement condition is met, move. |
boolean |
movementCondition()
Conditions under which this agent should move. |
void |
play(Agent agent)
Interact in some way with the supplied agent. |
void |
scapeCreated()
Notifies the prototype agent that a new scape has been created, allowing rules to be added directly from an agent class. |
protected void |
setInitialized(boolean initialized)
Sets the initialization state of the agent. |
void |
setScape(Scape scape)
Sets the scape for this agent. |
java.lang.String |
toString()
A string representation of this agent. |
void |
update()
Update this agent. |
Methods inherited from class org.ascape.model.AscapeObject |
---|
diffDeep, diffDeep, diffDeepBFS, diffDeepDFS, diffDeepValidate, diffDeepVisit, equalsDeep, equalsDeep, equalsDeep, getComparisonStream, getName, getRandom, getRandomSeed, getScape, randomInRange, randomInRange, randomIs, randomToLimit, reseed, setComparisonStream, setName, setRandom, setRandomSeed |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Rule INITIALIZE_RULE
public static final Rule UPDATE_RULE
public static final Rule ITERATE_AND_UPDATE_RULE
public static final Rule DEATH_RULE
public static final Rule FORCE_DIE_RULE
public static final Rule FISSIONING_RULE
public static final Rule FORCE_FISSION_RULE
public static final Rule METABOLISM_RULE
public static final Rule MOVEMENT_RULE
public static final Rule FORCE_MOVE_RULE
public static final Rule PLAY_OTHER
public static final Rule ITERATE_RULE
Constructor Detail |
---|
public Agent()
Method Detail |
---|
public void scapeCreated()
public boolean deathCondition()
death()
public void death()
deathCondition()
,
DEATH_RULE
public void die()
public boolean fissionCondition()
fission()
public void fissioning()
fissionCondition()
,
FISSIONING_RULE
public void fission()
public boolean movementCondition()
movement()
public void movement()
movementCondition()
,
MOVEMENT_RULE
public void move()
movement()
public void metabolism()
METABOLISM_RULE
public void play(Agent agent)
Cell.PLAY_NEIGHBORS_RULE
,
Cell.PLAY_RANDOM_NEIGHBOR_RULE
,
PLAY_OTHER
public void iterate()
scapeCreated()
,
ITERATE_RULE
public void update()
UPDATE_RULE
public void initialize()
public void execute(Rule[] rules)
rules
- an array of rules to be executedpublic void execute(Rule rule)
rule
- a rule to be executedpublic Scape getRoot()
public int getIteration()
public java.awt.Color getColor()
public java.awt.Color getColor(java.lang.Object object)
public java.awt.Image getImage()
public java.awt.Image getImage(java.lang.Object object)
public boolean isInitialized()
public void setScape(Scape scape)
setScape
in class AscapeObject
scape
- the scape this agent is belongs toprotected void setInitialized(boolean initialized)
public boolean isDelete()
public void markForDeletion()
public void clearDeleteMarker()
public java.lang.String toString()
toString
in class AscapeObject
public java.lang.Object clone()
initialize()
or b) preform a deep clone of that object by overriding this method. If you do
not do one of these things, you will end up sharing members across agents. This can be a very
diffuclt problem to debug!
clone
in class AscapeObject
|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |