Package osm :: Module agent :: Class Agent
[show private | hide private]
[frames | no frames]

Class Agent

FSM --+
      |
     Agent

Known Subclasses:
ActorVisual, Animation, AnimationPlayer, Movement, ScriptableAgent

Agent is an FSM with message handling capabilities. In addition to states and actions, Agent supports incoming and outcoming boxes of messages and a set of message handlers.

In the absence of incoming messages Agent works as an FSM. When Agent finds a command in its inBox, it runs a handler function (if any). Message handlers can change FSM state. To send a command to an Agent other objects call functions sendCommand or postCommand (named by win32 functions). Only Dispatcher(s) or Collective that have the Agent as a member can send commands to it. Also Agent can post messages (reports) into its outBox using sendReport function. Only Agent's owner (a Collective) or Dispatchers, to which Agent reports to, can check outBox for reports.

Such organization divides responsibilities between objects in the game and establishes communication flow: Collectives and Dispatchers send commands to Agents, Agents send reports back.
Method Summary
  __init__(self, name)
  clearInBox(self, timeInc)
Removes messages with delay=0 from inBox.
  clearOutBox(self, timeInc)
Removes all messages with delay=0 from outBox.
  executeCommands(self)
Calls handler for each message in the incoming box.
  postCommand(self, type, delay, paramsDict)
Places command into inBox.
  sendCommand(self, type, delay, paramsDict)
Sends a command with immediate invocation of a handler, if the handler is available.
  sendReport(self, type, delay, paramsDict)
Places report message into outBox.
  trace(self, args)
  update(self, timeInc)
Handles all incoming messages and then updates FSM.
    Inherited from FSM
  setAction(self)
Looks for the action by key=self.currState, sets it if found.
  setState(self, state)
Sets the current action function in addition to just changing the state variable.
  updateAction(self, timeInc)
Calls current action function if it is set.

Method Details

clearInBox(self, timeInc=1)

Removes messages with delay=0 from inBox. Timed messages are preserved for later porcessing.

clearOutBox(self, timeInc=1)

Removes all messages with delay=0 from outBox. Timed messages are preserved for later porcessing.

executeCommands(self)

Calls handler for each message in the incoming box. If the handler not found, the message is ignored.

postCommand(self, type, delay=0, paramsDict=None)

Places command into inBox.

sendCommand(self, type, delay=0, paramsDict=None)

Sends a command with immediate invocation of a handler, if the handler is available.

sendReport(self, type, delay=0, paramsDict=None)

Places report message into outBox.

update(self, timeInc=1)

Handles all incoming messages and then updates FSM.
Overrides:
osm.fsm.FSM.update

Generated by Epydoc 2.1 on Sun Feb 06 20:29:51 2005 http://epydoc.sf.net