agentland.behavior
Class BehaviorCoordinatorAgent

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--metaglue.AgentAgent
                          |
                          +--agentland.util.GoodAgent
                                |
                                +--agentland.resource.ManagedAgent
                                      |
                                      +--agentland.behavior.BehaviorCoordinatorAgent
All Implemented Interfaces:
Agent, BehaviorCoordinator, Good, Managed, MetagluePrimitives, Remote, Serializable, Spy

public class BehaviorCoordinatorAgent
extends ManagedAgent
implements BehaviorCoordinator

The BehaviorCoordinatorAgent is the crux of the Reactive Behavioral System. It serves as the interface between the outside perceptual world and all the behaviors. A Behavior must be registered with the Behavior Coordinator of a Room to receive information about the Room.
The Behavior Coordinator is what keeps track of which bevs are inactive, listening, active leaf, active overriden. It decides which behaviors receive the events.

See Also:
BehaviorAgent, ManagedAgent, BehaviorCoordinator, Serialized Form

Inner classes inherited from class metaglue.AgentAgent
AgentAgent.Attribute
 
Fields inherited from class agentland.resource.ManagedAgent
rm, society
 
Fields inherited from class agentland.util.GoodAgent
alert, notifier
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Fields inherited from interface metaglue.Agent
ALIVE, DIED, NO_METAGLUE, NOT_RUNNING, STARTING
 
Constructor Summary
BehaviorCoordinatorAgent()
          Creates a new BehaviorCoordinatorAgent instance.
 
Method Summary
 void addBev(BehaviorID bid)
          How a Behavior is registered with the Coordinator.
 Vector getActiveBevs()
          Returns the collection of active behaviors
 String getBevNames()
          Returns a String representation of the status of all the bevs registered with the bev coord.
 String getEvents()
          Returns a String Representation of the Events that the bev coord listens for.
 Vector getInactiveBevs()
          Returns the collection of inactive behaviors
 Vector getLeafBevs()
          Returns the collection of leaf behaviors.
 Vector getListeningBevs()
          Returns the collection of listening behaviors
 String getTree()
          Returns a String Representation of the current active bev tree.
 boolean isBevActive(BehaviorID bevID)
          Returns true if the Behavior with BehaviorID bevID is currently active.
 void tell(Secret secret)
          (This is how the Behavior Coordinator ever gets anything done.)
 void updateBev(BehaviorID bevID, int oldstate, int newstate)
          A Behavior calls this method to tell the coordinator about a change in its state.
 
Methods inherited from class agentland.resource.ManagedAgent
connect, getAlert, getNeed, isAvailable, isAvailable, reliesOn, reliesOn, replace, replace, request, request, request, requestAgent, requestAgent, resources, resourcesByAgentID, setNeed, tiedTo, yank, yank, yank
 
Methods inherited from class agentland.util.GoodAgent
addSpy, addSpy, alert, alertString, beep, error, getHistory, getHistoryElement, getPersistentMap, log, notify, removeSpy, removeSpy, resetHistory, safeRely, safeRely, safeRely, setNiceLogName
 
Methods inherited from class metaglue.AgentAgent
addMonitor, alive, defrost, defrostAll, defrostBoolean, defrostInt, defrostString, fixAttribute, fixAttribute, freeze, freeze, freeze, freezeAll, freezeVar, getAgentID, getAttribute, getCatalog, getCatalogID, getDesignation, getFrozenVariables, getLogLevel, getMetaglueAgent, getMetaglueAgentID, getOccupation, getProperties, getSociety, log, log, lookupClass, obtainMetaglueAgent, obtainMetaglueAgent, obtainMetaglueAgentByName, reliesOn, reliesOnSynch, removeFrozen, replaceExceptionHandler, setFreezeName, setLogLevel, setLogName, shutdown, startAgent, startAgentOn, startAgentOn, startup, status, tiedTo, tiedTo, tiedTo, tiedTo, tieToDesignation, whereAreYou
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface agentland.resource.Managed
getNeed, replace, replace, resources, yank, yank
 
Methods inherited from interface agentland.util.Good
getHistory, getHistoryElement, resetHistory
 
Methods inherited from interface metaglue.Agent
addMonitor, alive, getAgentID, getMetaglueAgentID, shutdown, startup, whereAreYou
 

Constructor Detail

BehaviorCoordinatorAgent

public BehaviorCoordinatorAgent()
                         throws RemoteException
Creates a new BehaviorCoordinatorAgent instance.
Adds and activates the Default Behavior Agent.
Throws:
RemoteException - if an error occurs
Method Detail

addBev

public void addBev(BehaviorID bid)
            throws RemoteException
How a Behavior is registered with the Coordinator.
Specified by:
addBev in interface BehaviorCoordinator
Parameters:
bid - the BehaviorID of the Behavior to be registered
Throws:
RemoteException - if an error occurs

getBevNames

public String getBevNames()
                   throws RemoteException
Returns a String representation of the status of all the bevs registered with the bev coord.
Sample Output:

Registered Bevs:
***
***
***
***

Inactive Bevs:
***

Listening Bevs:
***

Active Bevs:
***
***

Leaf Active Bevs:
***

Specified by:
getBevNames in interface BehaviorCoordinator
Returns:
the String representation
Throws:
RemoteException - if an error occurs

getTree

public String getTree()
               throws RemoteException
Returns a String Representation of the current active bev tree.

Doesn't work yet!

Specified by:
getTree in interface BehaviorCoordinator
Returns:
the String representation
Throws:
RemoteException - if an error occurs

getEvents

public String getEvents()
                 throws RemoteException
Returns a String Representation of the Events that the bev coord listens for.
Specified by:
getEvents in interface BehaviorCoordinator
Returns:
the String representation
Throws:
RemoteException - if an error occurs

isBevActive

public boolean isBevActive(BehaviorID bevID)
                    throws RemoteException
Returns true if the Behavior with BehaviorID bevID is currently active. I'm not sure if it works... I don't really use it. (I should delete it...)
Specified by:
isBevActive in interface BehaviorCoordinator
Parameters:
bevID - a BehaviorID value
Returns:
a boolean value
Throws:
RemoteException - if an error occurs

tell

public void tell(Secret secret)
(This is how the Behavior Coordinator ever gets anything done.)

After getting an event, this method passes it to all the leaf active bevs (which in turn passes it up the active behavioral tree). Then it passes the secret to all the listening bevs, and checks whether any of them get activated. Finally, it cycles through the inactive bevs and checks whether any of them should be listening.

Specified by:
tell in interface Spy
Overrides:
tell in class GoodAgent
Parameters:
secret - the event to be passed (as a Secret)

updateBev

public void updateBev(BehaviorID bevID,
                      int oldstate,
                      int newstate)
A Behavior calls this method to tell the coordinator about a change in its state.

0 - inactive
1 - listening
2 - active leaf
3 - active, non-leaf (i.e., overriden)

Specified by:
updateBev in interface BehaviorCoordinator
Parameters:
bevID - the BehaviorID of the behavior that's telling the bev coord about the change in its state
oldstate - the old state, as an int value
newstate - the new state, as an int value

getLeafBevs

public Vector getLeafBevs()
Returns the collection of leaf behaviors.
Specified by:
getLeafBevs in interface BehaviorCoordinator
Returns:
a Vector of BehaviorIDs

getActiveBevs

public Vector getActiveBevs()
Returns the collection of active behaviors
Specified by:
getActiveBevs in interface BehaviorCoordinator
Returns:
a Vector of BehaviorIDs

getListeningBevs

public Vector getListeningBevs()
Returns the collection of listening behaviors
Specified by:
getListeningBevs in interface BehaviorCoordinator
Returns:
a Vector of BehaviorIDs

getInactiveBevs

public Vector getInactiveBevs()
Returns the collection of inactive behaviors
Specified by:
getInactiveBevs in interface BehaviorCoordinator
Returns:
a Vector of BehaviorIDs