vs.plotagent
Class BasicPlotAgent

java.lang.Object
  extended by jade.core.Agent
      extended by jade.gui.GuiAgent
          extended by vs.rationalagent.RationalAgent
              extended by vs.plotagent.BasicPlotAgent
All Implemented Interfaces:
jade.core.TimerListener, java.io.Serializable, java.lang.Runnable, IAgent, IExplainable, IPlotAgent, IRationalAgent

public class BasicPlotAgent
extends RationalAgent
implements IPlotAgent, IExplainable

Plot Monitor agent

Author:
swartjes Created on 20-jul-2005
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class jade.core.Agent
jade.core.Agent.Interrupted
 
Field Summary
static int GETSUGGESTIONS
           
static java.lang.String PROLOG_FILE
           
static int SHOWFABULA
           
static int STATUS_READY
           
static int STATUS_STORY_OVER
           
static int STATUS_WAITING
           
 
Fields inherited from class vs.rationalagent.RationalAgent
CHARACTER_SERVICE, CLEAR_KB, CONSULT, EXIT, LOAD_KB, PLOT_SERVICE, QUERY_KB, SAVE_KB, TEST_KB, TRACER_SERVICE, WORLD_SERVICE
 
Fields inherited from class jade.core.Agent
AP_ACTIVE, AP_DELETED, AP_IDLE, AP_INITIATED, AP_MAX, AP_MIN, AP_SUSPENDED, AP_WAITING, D_ACTIVE, D_MAX, D_MIN, D_RETIRED, D_SUSPENDED, D_UNKNOWN
 
Constructor Summary
BasicPlotAgent()
           
 
Method Summary
 void buildAgentRelations()
          Builds a network of relations with other agents using the Directory Facilitator (DF) to subscribe to services the Plot Agent is interested in.
 java.util.Set<FabulaCausality> explainCausalities()
          Explain the motivations, the causalities or enablements that the interfaced class produced.
 java.util.Set<FabulaElement> explainElements()
          Explain the fabula elements that the interfaced class produced
 ICharacterManager getCharacterManager()
          Retrieves the Character Manager
 IFabulaBuilder getFabulaBuilder()
          Retrieves the Fabula Builder
 IInspirationModule getInspirationModule()
          Retrieves the Inspiration module
 IPerceptionManager getPerceptionManager()
          Retrieves the Perception Manager
 IPlotGoalManager getPlotGoalManager()
          Retrieves the Plot Goal Manager
 IThreadManager getThreadManager()
          Retrieves the Episode Manager
 int getTime()
          Gets the world time (in time steps)
 jade.core.AID getWorldAgent()
          Getter for World Agent
 void handleIncomingAction(StoryAction act)
          If the Plot Agent receives an Action from a character agent, this method handles this by sending a REQUEST to the World Agent to execute the Action.
 void handleSubscription(jade.domain.FIPAAgentManagement.DFAgentDescription dfds)
          Deals with incoming subscriptions or UNsubscriptions from both world agents and character agents.
 void nextRound()
          Starts the next time step
 void setup()
          override jade.core.Agent.setup
 void setWorldAgent(jade.core.AID worldAgent)
          Setter for World Agent
 void takeDown()
          overrides jade.core.Agent.takeDown
 
Methods inherited from class vs.rationalagent.RationalAgent
addEventListener, findServiceType, fireEvent, genCID, getAgent, getCodec, getKnowledgeManager, getOntology, getSniffer, getStoryDomain, getTracer, removeEventListener, setTracer, trace, trace, writeConsole, writeGui
 
Methods inherited from class jade.gui.GuiAgent
postGuiEvent
 
Methods inherited from class jade.core.Agent
addBehaviour, blockingReceive, blockingReceive, blockingReceive, blockingReceive, changeStateTo, clean, doActivate, doClone, doDelete, doMove, doSuspend, doTimeOut, doWait, doWait, doWake, getAgentState, getAID, getAMS, getArguments, getContainerController, getContentManager, getCurQueueSize, getDefaultDF, getHap, getHelper, getLocalName, getName, getO2AObject, getProperty, getQueueSize, getState, here, join, notifyChangeBehaviourState, notifyRestarted, postMessage, putBack, putO2AObject, receive, receive, removeBehaviour, restartLater, restore, restoreBufferedState, run, send, setArguments, setEnabledO2ACommunication, setGenerateBehaviourEvents, setQueueSize, waitUntilStarted, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface vs.rationalagent.IRationalAgent
getKnowledgeManager, writeGui
 
Methods inherited from interface vs.IAgent
addEventListener, findServiceType, fireEvent, genCID, getAgent, getCodec, getLocalName, getOntology, getTracer, removeEventListener, setTracer, trace, trace
 

Field Detail

STATUS_WAITING

public static final int STATUS_WAITING
See Also:
Constant Field Values

STATUS_READY

public static final int STATUS_READY
See Also:
Constant Field Values

STATUS_STORY_OVER

public static final int STATUS_STORY_OVER
See Also:
Constant Field Values

SHOWFABULA

public static final int SHOWFABULA
See Also:
Constant Field Values

GETSUGGESTIONS

public static final int GETSUGGESTIONS
See Also:
Constant Field Values

PROLOG_FILE

public static final java.lang.String PROLOG_FILE
See Also:
Constant Field Values
Constructor Detail

BasicPlotAgent

public BasicPlotAgent()
Method Detail

buildAgentRelations

public void buildAgentRelations()
Builds a network of relations with other agents using the Directory Facilitator (DF) to subscribe to services the Plot Agent is interested in. These are World Agents (WORLD service) and Character Agents (CHARACTER service). NOTE: unfortunately, it is not possible to send ONE subscription message specifying we want to listen to world agents OR character agents. When we add two ServiceDescriptions to the ACL message, it is interpreted as a query for agents that provide both the world_service AND the character_service, and obviously that is not the intention. Therefore, we need TWO subscription messages. However, for some reason these are part of the same protocol (more concretely, they have the same reply-with value. That means that incoming messages from the DF to inform us that there is a new agent with the requested service, is non-deterministically handled by either the first or the second InitiateSubscriptionBehaviour. That is the reason why checking the service type is done in a separate method (the handleSubscription() method of BasicPlotAgent), and not in the behaviours themselves. SECOND NOTE: the Plot Agent doesn't subscribe to agents _leaving_ the system. JADE doesn't support this. therefore, extra attention should be paid to checking whether agents are still there, i.e., if a REQUEST is answered by a FAILURE, some cleanup should be done.


explainCausalities

public java.util.Set<FabulaCausality> explainCausalities()
Description copied from interface: IExplainable
Explain the motivations, the causalities or enablements that the interfaced class produced.

Specified by:
explainCausalities in interface IExplainable
Returns:
a set of causality declarations describing an explanation for fabula elements.

explainElements

public java.util.Set<FabulaElement> explainElements()
Description copied from interface: IExplainable
Explain the fabula elements that the interfaced class produced

Specified by:
explainElements in interface IExplainable
Returns:
a set of fabula elements produced by the interfaced class

getCharacterManager

public ICharacterManager getCharacterManager()
Description copied from interface: IPlotAgent
Retrieves the Character Manager

Specified by:
getCharacterManager in interface IPlotAgent

getFabulaBuilder

public IFabulaBuilder getFabulaBuilder()
Description copied from interface: IPlotAgent
Retrieves the Fabula Builder

Specified by:
getFabulaBuilder in interface IPlotAgent

getInspirationModule

public IInspirationModule getInspirationModule()
Description copied from interface: IPlotAgent
Retrieves the Inspiration module

Specified by:
getInspirationModule in interface IPlotAgent

getPerceptionManager

public IPerceptionManager getPerceptionManager()
Description copied from interface: IPlotAgent
Retrieves the Perception Manager

Specified by:
getPerceptionManager in interface IPlotAgent

getPlotGoalManager

public IPlotGoalManager getPlotGoalManager()
Description copied from interface: IPlotAgent
Retrieves the Plot Goal Manager

Specified by:
getPlotGoalManager in interface IPlotAgent

getThreadManager

public IThreadManager getThreadManager()
Description copied from interface: IPlotAgent
Retrieves the Episode Manager

Specified by:
getThreadManager in interface IPlotAgent

getTime

public int getTime()
Description copied from interface: IRationalAgent
Gets the world time (in time steps)

Specified by:
getTime in interface IRationalAgent
Returns:
the time

getWorldAgent

public jade.core.AID getWorldAgent()
Getter for World Agent

Specified by:
getWorldAgent in interface IPlotAgent
Returns:
AID of the World agent

handleIncomingAction

public void handleIncomingAction(StoryAction act)
If the Plot Agent receives an Action from a character agent, this method handles this by sending a REQUEST to the World Agent to execute the Action.

Specified by:
handleIncomingAction in interface IPlotAgent
Parameters:
act - the Action sent by the character agent

handleSubscription

public void handleSubscription(jade.domain.FIPAAgentManagement.DFAgentDescription dfds)
Deals with incoming subscriptions or UNsubscriptions from both world agents and character agents. Dispatches character agent subscriptions to the CharacterManager, and handles world agent subscriptions directly.

Specified by:
handleSubscription in interface IPlotAgent
Parameters:
dfds - the agent description of the agent whose presence the plot agent is subscribed to

nextRound

public void nextRound()
Description copied from interface: IPlotAgent
Starts the next time step

Specified by:
nextRound in interface IPlotAgent

setup

public void setup()
override jade.core.Agent.setup

Overrides:
setup in class RationalAgent

setWorldAgent

public void setWorldAgent(jade.core.AID worldAgent)
Setter for World Agent

Specified by:
setWorldAgent in interface IPlotAgent
Parameters:
worldAgent - the AID of the World Agent

takeDown

public void takeDown()
Description copied from class: RationalAgent
overrides jade.core.Agent.takeDown

Overrides:
takeDown in class RationalAgent