mil.navy.nps.relate
Class Agent

java.lang.Object
  extended bymil.navy.nps.relate.Thing
      extended bymil.navy.nps.relate.Agent
Direct Known Subclasses:
CTFAgent

public abstract class Agent
extends Thing

This abstract class implements the RELATE Agent.

Since all Agents are objects, or things, Agent extends Thing, giving it the ability to update and draw itself. By the definition:

  • an agent "...perceives its environment through sensors and acts upon that environment through effectors to achieve one or more goals."

    To satisfy these requirements, the developer must first establish a method for the agent to gather information about the environment it exists in. This information is stored in the sensedEnvironment data member. This class allows the developer to do this by defining the abstract getSensedEnvironment() and setSensedEnvironment() methods to interact with the simulation environment directly. These methods should utilize the sensorList hashtable to define what each agent is capable of sensing, and only allow the agent to sense the specific attributes of the environment that its current sensor list can detect or discern.

    Next, the agent must select an appropriate action. Two things are needed for this: actions that can be selected, and a method or methods to select these actions. The actions each agent can take are simulation-dependent and must be defined by the developer. For simpler simulations, actions can be built into the Agent class itself. An Action interface is provided as a tool for the developer designing more complex simulations. The mechanism for selecting actions is based upon the relationships each agent forms, and the associated roles and goals that the agent attempts to fulfill.

    Agents have a relationship hashtable that the developer must fill with the class names of all the potential relationships that the agent can form. This can be accomplished by using the addRelationshipName() method.

    Since:
    JDK1.3
    Version:
    1.0, 17 Aug 00
    Author:
    Michael R. Dickson, Kimberly A. Roddy

    Field Summary
     RelationshipManager relationshipManager
              A "singleton" object that handles all relationships for this agent.
     
    Fields inherited from class mil.navy.nps.relate.Thing
    entityID, entityName
     
    Constructor Summary
    Agent(long pID, java.lang.String pName)
              Constructor for this Agent
     
    Method Summary
     void addRelationshipName(java.lang.String pRelationshipName)
              Adds the passed in class name of the relationship in question.
     void addRelationshipNames(java.util.Vector pRelationshipNames)
              Adds the passed in class name vector of the agents possible relationships.
     void addRole(Role pRole)
              Adds the passed in role to the role vector.
    abstract  void assignCredit()
              Assigns credit to current goal set.
     void checkForRelationships()
              checkForRelationships() calls the relationshipManagers method of the same name.
     Goal getActiveGoal()
              Gets the active goal object.
     Role getActiveRole()
              Gets the active role object.
     long getAgentID()
              Gets the Agent's ID by using the super's getEntityID method
     java.lang.String getAgentName()
              Gets the Agent's name by using the super's getEntityName method
     java.util.Hashtable getGoalList()
              Gets the Agent's goalList
     Goal getPastActiveGoal()
              Gets the Agents past active goal
     Personality getPersonality()
              Gets the Agent's personality
     java.util.Hashtable getRelationshipTable()
              Gets the Agent's relationship Hashtable
     java.util.Vector getRoleVector()
              Gets the Agent's role vector
    abstract  SensedEnvironment getSensedEnvironment()
              Gets the SensedEnvironment.
     java.util.Hashtable getSensorList()
              Gets the Agent's sensorList
     void removeRelationshipName(java.lang.String pRelationshipName)
              Removes the associated relationship corresponding to the passed in relationship class name from the relationship hashtable.
     boolean removeRole(Role pRole)
              Removes the passed in role from the role vector.
     void setActiveGoal(Goal pGoal)
              Sets the active goal
    protected  void setAgentID(long pID)
              Sets the Agent's ID by using the super's setEntityID method
    protected  void setAgentName(java.lang.String pAgentName)
              Sets the Agent's name by using the super's SetEntityName method
     void setPastActiveGoal(Goal pGoal)
              Sets the Agents past active goal
     void setPersonality(Personality pPersonality)
              Sets the Agent's personality
    abstract  void setSensedEnvironment(SensedEnvironment pPEnv)
              Sets the agents SensedEnvironment to the passed in object
     void setSensorList(java.util.Hashtable pSensorList)
              Sets the Agent's sensorList
     
    Methods inherited from class mil.navy.nps.relate.Thing
    drawSelf, getEntityID, getEntityName, setEntityID, setEntityName, step
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    relationshipManager

    public RelationshipManager relationshipManager
    A "singleton" object that handles all relationships for this agent. Used as a conduit to forming or joining all possible realtionships this agent can be a part of.

    Constructor Detail

    Agent

    public Agent(long pID,
                 java.lang.String pName)
    Constructor for this Agent

    Method Detail

    getSensedEnvironment

    public abstract SensedEnvironment getSensedEnvironment()
    Gets the SensedEnvironment.

    Returns:
    A SensedEnvironment containing the perceived environement.

    setSensedEnvironment

    public abstract void setSensedEnvironment(SensedEnvironment pPEnv)
    Sets the agents SensedEnvironment to the passed in object


    assignCredit

    public abstract void assignCredit()
    Assigns credit to current goal set. This should call assignCredit() in all of the agents held goals. The result of these calls will assign weights to all goals. These weights will determine the current active goal for each goaltype held.


    addRelationshipName

    public void addRelationshipName(java.lang.String pRelationshipName)
    Adds the passed in class name of the relationship in question. The integer 32 is set as the element in the hashtable. This integer is used by various classes to check to see if the agent is actually a member of a relationship. If the agent is a member, a relationship object replaces the integer.


    addRelationshipNames

    public void addRelationshipNames(java.util.Vector pRelationshipNames)
    Adds the passed in class name vector of the agents possible relationships. The integer 32 is set as the element in the hashtable. This integer is used by various classes to check to see if the agent is actually a member of a relationship. If the agent is a member, a relationship object replaces the integer.


    removeRelationshipName

    public void removeRelationshipName(java.lang.String pRelationshipName)
    Removes the associated relationship corresponding to the passed in relationship class name from the relationship hashtable. Replaces the relationship object with an integer.


    addRole

    public void addRole(Role pRole)
    Adds the passed in role to the role vector. It then adds the new Role's Goals to the goalList.

    Parameters:
    pRole - The new Role being assigned

    removeRole

    public boolean removeRole(Role pRole)
    Removes the passed in role from the role vector. It then removes the roles associated goals from the goalList.

    Parameters:
    pRole - The Role that is to be removed
    Returns:
    The success of the removal operation

    checkForRelationships

    public void checkForRelationships()
    checkForRelationships() calls the relationshipManagers method of the same name. This is the mechanism that allows the agent to join or form a designeted relationship.


    getActiveRole

    public Role getActiveRole()
    Gets the active role object.

    Returns:
    The active Role for this Agent.

    getActiveGoal

    public Goal getActiveGoal()
    Gets the active goal object.

    Returns:
    The active Goal for this Agent.

    setActiveGoal

    public void setActiveGoal(Goal pGoal)
    Sets the active goal

    Parameters:
    pGoal - The Agents new active goal.

    getPastActiveGoal

    public Goal getPastActiveGoal()
    Gets the Agents past active goal

    Returns:
    This Agent's past active Goal.

    setPastActiveGoal

    public void setPastActiveGoal(Goal pGoal)
    Sets the Agents past active goal

    Parameters:
    pGoal - The Agent's past active goal.

    getGoalList

    public java.util.Hashtable getGoalList()
    Gets the Agent's goalList

    Returns:
    goalList

    getSensorList

    public java.util.Hashtable getSensorList()
    Gets the Agent's sensorList

    Returns:
    sensorList

    setSensorList

    public void setSensorList(java.util.Hashtable pSensorList)
    Sets the Agent's sensorList

    Parameters:
    pSensorList -

    getAgentID

    public long getAgentID()
    Gets the Agent's ID by using the super's getEntityID method

    Returns:
    agentID

    setAgentID

    protected void setAgentID(long pID)
    Sets the Agent's ID by using the super's setEntityID method


    getPersonality

    public Personality getPersonality()
    Gets the Agent's personality

    Returns:
    personality

    setPersonality

    public void setPersonality(Personality pPersonality)
    Sets the Agent's personality


    getRelationshipTable

    public java.util.Hashtable getRelationshipTable()
    Gets the Agent's relationship Hashtable

    Returns:
    relationshipTable

    getAgentName

    public java.lang.String getAgentName()
    Gets the Agent's name by using the super's getEntityName method

    Returns:
    agentName

    setAgentName

    protected void setAgentName(java.lang.String pAgentName)
    Sets the Agent's name by using the super's SetEntityName method


    getRoleVector

    public java.util.Vector getRoleVector()
    Gets the Agent's role vector

    Returns:
    roleVec