org.ascape.model
Class LocatedAgent

java.lang.Object
  extended by org.ascape.model.AscapeObject
      extended by org.ascape.model.Agent
          extended by org.ascape.model.LocatedAgent
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Location, HasName, RandomFunctions
Direct Known Subclasses:
Cell, MomentumAgent

public class LocatedAgent
extends Agent
implements Location

An agent that has a location in continuous space.

Since:
2.0
Version:
3.0
Author:
Miles Parker
See Also:
Serialized Form

Field Summary
protected  int agentSize
          Default agent size.
protected  Coordinate coordinate
          The coordinate location of this cell within the relevant scape.
static Rule MOVE_RANDOM_LOCATION_RULE
          A rule causing the taget agent to move to a random location.
static Rule RANDOM_WALK_RULE
          A rule causing the taget agent to take a random walk.
protected  int thisUpdate
           
 
Fields inherited from class org.ascape.model.Agent
DEATH_RULE, FISSIONING_RULE, FORCE_DIE_RULE, FORCE_FISSION_RULE, FORCE_MOVE_RULE, INITIALIZE_RULE, ITERATE_AND_UPDATE_RULE, ITERATE_RULE, METABOLISM_RULE, MOVEMENT_RULE, PLAY_OTHER, UPDATE_RULE
 
Fields inherited from class org.ascape.model.AscapeObject
ARBITRARY_SEED, name, scape
 
Constructor Summary
LocatedAgent()
           
 
Method Summary
 double calculateDistance(Coordinate target)
          Return the distance between this agent and the supplied coordinate.
 double calculateDistance(LocatedAgent target)
          Return the distance between this agent and the supplied agent.
 int countWithin(Conditional condition, boolean includeSelf, double distance)
          Returns the number of agents within the specified distance of the agent that meet some condition.
 int countWithin(Conditional condition, double distance)
          Returns the number of agents within the specified distance of the agent that meet some condition.
 int countWithin(double distance)
          Returns the number of agents within the specified distance of the agent.
 LocatedAgent findMaximumWithin(DataPoint data, boolean includeSelf, double distance)
           
 LocatedAgent findNearest()
          Returns the closest agent.
 LocatedAgent findNearest(Conditional condition)
          Returns the closest agent that meet some condition.
 LocatedAgent findNearest(Conditional condition, boolean includeSelf, double distance)
          Returns the closest agent within the specified distance from this agent that meet some condition.
 LocatedAgent findNearest(Conditional condition, double distance)
          Returns the closest agent within the specified distance from this agent that meet some condition.
 LocatedAgent findNearest(double distance)
          Returns the closest agent within the specified distance from this agent.
 java.util.List findWithin(Conditional condition, boolean includeSelf, double distance)
          Returns all agents within the specified distance of the agent that meet some condition.
 java.util.List findWithin(Conditional condition, double distance)
          Returns all agents within the specified distance of the agent that meet some condition, excluding this agent.
 java.util.List findWithin(double distance)
          Returns all agents within the specified distance of the agent, excluding this agent.
 java.util.List findWithin(double distance, boolean includeSelf)
          Returns all agents within the specified distance of the agent, excluding this agent.
 int getAgentSize()
           
 Coordinate getCoordinate()
          Gets a coordinate the location of this cell within the relevant scape.
 boolean hasWithin(Conditional condition, boolean includeSelf, double distance)
          Returns the number of agents within the specified distance of the agent that meet some condition.
 boolean hasWithin(Conditional condition, double distance)
          Returns the number of agents within the specified distance of the agent that meet some condition.
 boolean hasWithin(double distance)
          Returns the number of agents within the specified distance of the agent.
 void initialize()
          Initialize any values.
 boolean isUpdateNeeded(int within)
          Has a view update been requested for this cell?
 void moveAway(Coordinate target)
          Moves distance 1.0 toward the specified coordinate.
 void moveAway(Coordinate target, double distance)
          Moves distance 1.0 toward the specified coordinate.
 void moveAway(LocatedAgent target)
          Moves distance 1.0 toward the specified agent.
 void moveTo(Coordinate coordinate)
          Moves to the coordiante specified.
 void moveToRandomLocation()
          Moves this agent to a random unoccupied location on the host scape.
 void moveToward(Coordinate target)
          Moves distance 1.0 toward the specified coordinate.
 void moveToward(Coordinate target, double distance)
          Moves distance 1.0 toward the specified coordinate.
 void moveToward(LocatedAgent target)
          Moves distance 1.0 toward the specified agent.
 void randomWalk()
          Moves a set distance in a random direction.
 void requestUpdate()
          Indicate to all views of this cell that an update is needed.
 void requestUpdateNext()
          Indicate to all views of this cell that an update is needed next iteration.
 void setAgentSize(int agentSize)
           
 void setCoordinate(Coordinate coordinate)
          Returns the extent of the nth dimension.
 java.lang.String toString()
          A string representation of this cell.
 
Methods inherited from class org.ascape.model.Agent
clearDeleteMarker, clone, death, deathCondition, die, execute, execute, fission, fissionCondition, fissioning, getColor, getColor, getImage, getImage, getIteration, getRoot, isDelete, isInitialized, iterate, markForDeletion, metabolism, move, movement, movementCondition, play, scapeCreated, setInitialized, setScape, update
 
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
 
Methods inherited from interface org.ascape.model.space.Location
clearDeleteMarker, clone, isDelete, markForDeletion
 

Field Detail

MOVE_RANDOM_LOCATION_RULE

public static final Rule MOVE_RANDOM_LOCATION_RULE
A rule causing the taget agent to move to a random location. Move random location rules can only be applied to agents in continuous space or to cell occupants.


RANDOM_WALK_RULE

public static final Rule RANDOM_WALK_RULE
A rule causing the taget agent to take a random walk. The agent attempts to take a random step in a random direction. If the cell at the random location already has an occupant, nothing happens. Note the difference between this rule and RANDOM_WALK_AVAILABLE_RULE. Random walk rules can only be applied to agents in continuous space or to cell occupants.


coordinate

protected Coordinate coordinate
The coordinate location of this cell within the relevant scape.


thisUpdate

protected int thisUpdate

agentSize

protected int agentSize
Default agent size. For now, agent image will simply by a circle, with radius of agentSize.

Constructor Detail

LocatedAgent

public LocatedAgent()
Method Detail

initialize

public void initialize()
Description copied from class: Agent
Initialize any values. This method will be called automatically when the parent scape is initialized or started, so override this to provide initial values, location, etc... Any parent models of this agent's scape can be assumed to be initialized. Of course, other agents within the scape should be assumed not to have been initialized.

Specified by:
initialize in interface Location
Overrides:
initialize in class Agent

requestUpdate

public void requestUpdate()
Indicate to all views of this cell that an update is needed. Should be called whenever the cell state has changed in a way that might affect how it is drawn.


requestUpdateNext

public void requestUpdateNext()
Indicate to all views of this cell that an update is needed next iteration. Called when a paint action in the current iteration might need cleanup in the next cycle.


isUpdateNeeded

public boolean isUpdateNeeded(int within)
Has a view update been requested for this cell?


getCoordinate

public Coordinate getCoordinate()
Gets a coordinate the location of this cell within the relevant scape. Warning, may be null for members of graphs.

Specified by:
getCoordinate in interface Location
Returns:
the coordinate

setCoordinate

public void setCoordinate(Coordinate coordinate)
Returns the extent of the nth dimension.

Specified by:
setCoordinate in interface Location
Parameters:
coordinate - the new coordinate

findNearest

public LocatedAgent findNearest()
Returns the closest agent.


findNearest

public LocatedAgent findNearest(double distance)
Returns the closest agent within the specified distance from this agent.

Parameters:
distance - the distance agents must be within to be included

findNearest

public LocatedAgent findNearest(Conditional condition)
Returns the closest agent that meet some condition.

Parameters:
condition - the condition the agent must meet to be included

findNearest

public LocatedAgent findNearest(Conditional condition,
                                double distance)
Returns the closest agent within the specified distance from this agent that meet some condition.

Parameters:
condition - the condition the agent must meet to be included
distance - the distance agents must be within to be included

findNearest

public LocatedAgent findNearest(Conditional condition,
                                boolean includeSelf,
                                double distance)
Returns the closest agent within the specified distance from this agent that meet some condition.

Parameters:
condition - the condition the agent must meet to be included
includeSelf - if the calling agent should be included in the search
distance - the distance agents must be within to be included

findWithin

public java.util.List findWithin(double distance)
Returns all agents within the specified distance of the agent, excluding this agent.

Parameters:
distance - the distance agents must be within to be included

findWithin

public java.util.List findWithin(double distance,
                                 boolean includeSelf)
Returns all agents within the specified distance of the agent, excluding this agent.

Parameters:
distance - the distance agents must be within to be included

findWithin

public java.util.List findWithin(Conditional condition,
                                 double distance)
Returns all agents within the specified distance of the agent that meet some condition, excluding this agent.

Parameters:
condition - the condition the agent must meet to be included
distance - the distance agents must be within to be included

findWithin

public java.util.List findWithin(Conditional condition,
                                 boolean includeSelf,
                                 double distance)
Returns all agents within the specified distance of the agent that meet some condition.

Parameters:
includeSelf - if this agent should be included in the search
condition - the condition the agent must meet to be included
distance - the distance agents must be within to be included

findMaximumWithin

public LocatedAgent findMaximumWithin(DataPoint data,
                                      boolean includeSelf,
                                      double distance)

countWithin

public int countWithin(double distance)
Returns the number of agents within the specified distance of the agent.

Parameters:
distance - the distance agents must be within to be included

countWithin

public int countWithin(Conditional condition,
                       double distance)
Returns the number of agents within the specified distance of the agent that meet some condition.

Parameters:
condition - the condition the agent must meet to be included
distance - the distance agents must be within to be included

countWithin

public int countWithin(Conditional condition,
                       boolean includeSelf,
                       double distance)
Returns the number of agents within the specified distance of the agent that meet some condition.

Parameters:
includeSelf - whether or not this agent should be included in the count
condition - the condition the agent must meet to be included
distance - the distance agents must be within to be included

hasWithin

public boolean hasWithin(double distance)
Returns the number of agents within the specified distance of the agent.

Parameters:
distance - the distance agents must be within to be included

hasWithin

public boolean hasWithin(Conditional condition,
                         double distance)
Returns the number of agents within the specified distance of the agent that meet some condition.

Parameters:
condition - the condition the agent must meet to be included
distance - the distance agents must be within to be included

hasWithin

public boolean hasWithin(Conditional condition,
                         boolean includeSelf,
                         double distance)
Returns the number of agents within the specified distance of the agent that meet some condition.

Parameters:
includeSelf - if this agent should be included in the search
condition - the condition the agent must meet to be included
distance - the distance agents must be within to be included

moveToward

public void moveToward(LocatedAgent target)
Moves distance 1.0 toward the specified agent.

Parameters:
target - the agent to move toward

moveToward

public void moveToward(Coordinate target)
Moves distance 1.0 toward the specified coordinate.

Parameters:
target - the agent to move toward

moveToward

public void moveToward(Coordinate target,
                       double distance)
Moves distance 1.0 toward the specified coordinate.

Parameters:
target - the agent to move toward
distance - the distance to move

moveAway

public void moveAway(LocatedAgent target)
Moves distance 1.0 toward the specified agent.

Parameters:
target - the agent to move toward

moveAway

public void moveAway(Coordinate target)
Moves distance 1.0 toward the specified coordinate.

Parameters:
target - the agent to move toward

moveAway

public void moveAway(Coordinate target,
                     double distance)
Moves distance 1.0 toward the specified coordinate.

Parameters:
target - the agent to move toward
distance - the distance to move

moveToRandomLocation

public void moveToRandomLocation()
Moves this agent to a random unoccupied location on the host scape. It is an error to call this method on a cell in a non-continous scape unless the cell is a cell occupant.


randomWalk

public void randomWalk()
Moves a set distance in a random direction. It is an error to call this method on a cell in a non-continuous space unless the cell is a cell occupant. (distance 1 may be replaced with a veolcity.


moveTo

public void moveTo(Coordinate coordinate)
Moves to the coordiante specified. It is an error to call this method on a cell in a non-continuous space unless the cell is a cell occupant. In other words, the default behavior of this method is to throw an exception.

Parameters:
coordinate -

calculateDistance

public double calculateDistance(LocatedAgent target)
Return the distance between this agent and the supplied agent.


calculateDistance

public double calculateDistance(Coordinate target)
Return the distance between this agent and the supplied coordinate.


getAgentSize

public int getAgentSize()

setAgentSize

public void setAgentSize(int agentSize)

toString

public java.lang.String toString()
A string representation of this cell.

Overrides:
toString in class Agent


Copyright © 1998-2008 The Brookings Institution, NuTech Solutions, Metascape, LLC All Rights Reserved.