org.nlogo.agent
Class Agent

java.lang.Object
  extended by java.util.Observable
      extended by org.nlogo.agent.Agent
All Implemented Interfaces:
Comparable<Agent>, Agent
Direct Known Subclasses:
Link, Observer, Patch, Turtle

public abstract class Agent
extends Observable
implements Agent, Comparable<Agent>


Field Summary
 long id
           
 Object[] variables
           
 
Constructor Summary
Agent(World world)
           
 
Method Summary
abstract  String classDisplayName()
          Returns a displayable name of this type of agent (Turtle, Link, Patch, Observer)
 int compareTo(Agent a)
           
abstract  int getAgentBit()
           
abstract  Class<? extends Agent> getAgentClass()
           
abstract  Object getBreedVariable(String name)
           
abstract  Object getLinkBreedVariable(String name)
           
abstract  Object getLinkVariable(int vn)
           
abstract  Object getObserverVariable(int vn)
           
abstract  Patch getPatchAtOffsets(double dx, double dy)
           
abstract  Object getPatchVariable(int vn)
           
abstract  Object getTurtleOrLinkVariable(String varName)
           
abstract  Object getTurtleVariable(int vn)
           
abstract  Object getVariable(int vn)
          Returns the value of the variable in the given position of the agent variable array
 int getVariableCount()
           
 long id()
          Returns the id number of this agent.
abstract  void setBreedVariable(String name, Object value)
           
abstract  void setLinkBreedVariable(String name, Object value)
           
abstract  void setLinkVariable(int vn, double value)
           
abstract  void setLinkVariable(int vn, Object value)
           
abstract  void setObserverVariable(int vn, Object value)
           
abstract  void setPatchVariable(int vn, double value)
           
abstract  void setPatchVariable(int vn, Object value)
           
abstract  void setTurtleOrLinkVariable(String varName, Object value)
           
abstract  void setTurtleVariable(int vn, double value)
           
abstract  void setTurtleVariable(int vn, Object value)
           
abstract  void setVariable(int vn, Object value)
          Sets the variable in the position vn of the agent variable array to value
 ValueConstraint variableConstraint(int vn)
           
 void variableConstraint(int vn, ValueConstraint con)
           
 World world()
          Returns the world object associated with this agent
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.nlogo.api.Agent
shape, size
 

Field Detail

id

public long id

variables

public Object[] variables
Constructor Detail

Agent

public Agent(World world)
Method Detail

world

public World world()
Description copied from interface: Agent
Returns the world object associated with this agent

Specified by:
world in interface Agent

id

public long id()
Description copied from interface: Agent
Returns the id number of this agent. The who number in the case of a turtle, index into the array in the case of patches

Specified by:
id in interface Agent

compareTo

public int compareTo(Agent a)
Specified by:
compareTo in interface Comparable<Agent>

getVariableCount

public int getVariableCount()

getVariable

public abstract Object getVariable(int vn)
Description copied from interface: Agent
Returns the value of the variable in the given position of the agent variable array

Specified by:
getVariable in interface Agent
Parameters:
vn - the index into the agent variable array

setVariable

public abstract void setVariable(int vn,
                                 Object value)
                          throws AgentException,
                                 LogoException
Description copied from interface: Agent
Sets the variable in the position vn of the agent variable array to value

Specified by:
setVariable in interface Agent
Parameters:
vn - the index into the agent variable array
value - the new value for the variable
Throws:
AgentException - If value is the wrong type for the given variable or if you try to change variables that cannot be changed
LogoException

variableConstraint

public ValueConstraint variableConstraint(int vn)

variableConstraint

public void variableConstraint(int vn,
                               ValueConstraint con)

getObserverVariable

public abstract Object getObserverVariable(int vn)

getTurtleVariable

public abstract Object getTurtleVariable(int vn)
                                  throws AgentException
Throws:
AgentException

getBreedVariable

public abstract Object getBreedVariable(String name)
                                 throws AgentException
Throws:
AgentException

getLinkBreedVariable

public abstract Object getLinkBreedVariable(String name)
                                     throws AgentException
Throws:
AgentException

getLinkVariable

public abstract Object getLinkVariable(int vn)
                                throws AgentException
Throws:
AgentException

getPatchVariable

public abstract Object getPatchVariable(int vn)
                                 throws AgentException
Throws:
AgentException

getTurtleOrLinkVariable

public abstract Object getTurtleOrLinkVariable(String varName)
                                        throws AgentException
Throws:
AgentException

setObserverVariable

public abstract void setObserverVariable(int vn,
                                         Object value)
                                  throws AgentException,
                                         LogoException
Throws:
AgentException
LogoException

setTurtleVariable

public abstract void setTurtleVariable(int vn,
                                       Object value)
                                throws AgentException
Throws:
AgentException

setTurtleVariable

public abstract void setTurtleVariable(int vn,
                                       double value)
                                throws AgentException
Throws:
AgentException

setLinkVariable

public abstract void setLinkVariable(int vn,
                                     Object value)
                              throws AgentException
Throws:
AgentException

setLinkVariable

public abstract void setLinkVariable(int vn,
                                     double value)
                              throws AgentException
Throws:
AgentException

setBreedVariable

public abstract void setBreedVariable(String name,
                                      Object value)
                               throws AgentException
Throws:
AgentException

setLinkBreedVariable

public abstract void setLinkBreedVariable(String name,
                                          Object value)
                                   throws AgentException
Throws:
AgentException

setPatchVariable

public abstract void setPatchVariable(int vn,
                                      Object value)
                               throws AgentException
Throws:
AgentException

setPatchVariable

public abstract void setPatchVariable(int vn,
                                      double value)
                               throws AgentException
Throws:
AgentException

setTurtleOrLinkVariable

public abstract void setTurtleOrLinkVariable(String varName,
                                             Object value)
                                      throws AgentException
Throws:
AgentException

getPatchAtOffsets

public abstract Patch getPatchAtOffsets(double dx,
                                        double dy)
                                 throws AgentException
Throws:
AgentException

classDisplayName

public abstract String classDisplayName()
Description copied from interface: Agent
Returns a displayable name of this type of agent (Turtle, Link, Patch, Observer)

Specified by:
classDisplayName in interface Agent

getAgentClass

public abstract Class<? extends Agent> getAgentClass()

getAgentBit

public abstract int getAgentBit()