An agent's behavior can contain any number of methods. A method is a segment of the agent's behavior that contains a set of rules. A trigger is at the head of every method and determines when the method will be called. Triggers that label method boxes in the Visual AgenTalk language behavior editors include:
- While running: the agent's main method is labeled with the While Running trigger. This method is repeatedly called once at each simulation cycle (time step) while the simulation is running.
- On <method_name>: a user-defined method that gets called by the agent that contains it or any other agent using the Message or the Broadcast action. Upon receiving such a message, an agent calls the method referred to in the message and carries out the actions associated with the first rule whose conditions are all met in that method.
When programming an agent, it is recommended that you divide the agent's behavior into "chunks." It is natural to do this when describing an agent's activity in words. At different times an agent might walk, run, sit, speak, or act in any number of ways. If you focus on walking, you may wish to create one method to describe how an agent walks. You may even wish to create another method to describe how an agent takes a step. We suggest that you divide groups of rules into named methods that make sense for the agents in your specific simulation.
- When Creating A New Agent: This trigger executes the enclosed rules whenever a new agent is created in a worksheet using the Draw tool, the Volume Insert tool, or the New action. The When Creating New Agent trigger is usually used to initialize the agent's state.
- On Mouse Click: The Mouse Click trigger is used to program an agent to respond to a modified or unmodified mouse click.
The rules located in a method labeled with a Mouse Click trigger are executed whenever the executing agent senses the designated mouse click (modified or unmodified), whether the simulation is running or not. The Mouse Click trigger increases the number of ways in which you can interact with your agents in the world.
- On Mouse Hover: ???
The behavior editor for a new agent or an agent with no behavior comes up with a single method containing the While Running trigger and one empty rule.