Cognitive Controller Editor

Create panel > Helpers > Object Type rollout > Crowd > Setup rollout > Cognitive Controllers

Select a Crowd object. > Modify panel > Setup rollout > Cognitive Controllers

The Cognitive Controller editor lets you combine behaviors into states. More importantly, it lets you sequence different behaviors and behavior combinations using state diagrams, where conditionals written in MAXScript impose changes in behavior. For example, you can specify that a character or object is to wander aimlessly until it comes within a certain distance of another object, whereupon it heads straight for that object. Or you can specify that one character is to avoid another only when the second character is avoiding the first.

Note: The MAXScript conditionals used in the cognitive controller typically consist of a single line of code. You can load and save them separately as .ms files, but they are also stored within the .max scene file in which they reside.

The editor interface consists of an icon-based toolbar above a window that contains the state diagram. When you first open the editor, no state diagrams exist. Begin by clicking the New button to create a new state diagram.

Tip: If you find yourself consistently assigning two or more behaviors to delegates or teams, you can save time by combining the behaviors into a single-state cognitive controller, or "behavior module," and assigning that instead. The only disadvantage is that you can't animate the weights of behaviors used in the cognitive controller, but you can work around that by using transitions.

Note: Crowd doesn't let you use multiple cognitive controllers with a delegate. You can assign them, but when you solve, the software notifies you that it will use only the first assigned cognitive controller.

See also

Procedure

To set up and use a cognitive controller

This procedure describes a typical setup routine for creating and using a cognitive controller. The procedure assumes basic knowledge of crowd simulation setup. For more information about crowd setup, see Crowd Helper Object and Setup Rollout.

  1. Create a scene containing a crowd object and one or more delegates.

  2. Create at least two behaviors.

  3. Open the Cognitive Controller editor.

  4. Click the New button to create a cognitive controller.

  5. character studio gives the controller the default name of CogControl. It's recommended that you give more descriptive names to cognitive controllers, such as "Seek/Wander". Do this by clicking on the name in the text box and editing it from the keyboard.

    Creating a new cognitive controller automatically places you in Create State mode.

  6. Click in the editor window to create and place a state. Continue clicking in different places to add as many states as necessary.

  7. Right-click a state to open the State editor.

  8. Again, it's recommended that you give more descriptive names to states, which you can do in the State editor. Click the name (State or State#) in the text box and edit it from the keyboard.

    Next, define a behavior or behaviors for each state.

  9. Click the Add button.

  10. In the Select Behaviors dialog, choose one or more behaviors.

    If you choose multiple behaviors, you can specify different weights for each in the State editor. For example, you can combine a Seek behavior at full weight with a Wander behavior at half weight, so that the delegate will meander slightly as it seeks the target.

  11. Close the Select Behaviors dialog, and then close the State editor.

  12. Repeat steps 6-9 as necessary to define behaviors for the other states in the controller.

    Next, use Create Transition to define the sequence of states during the simulation.

  13. Decide on the sequence in which the states are to occur.

  14. Click the Create Transition button.

  15. Drag a line from one state to the next in the order that they are to execute. Click a state to create a transition from itself to itself.

    An arrow appears, pointing from the "source" state to the "destination" state.

    Each state can have any number of incoming and outgoing transitions. Specify different transition conditions for each to create as complex a state diagram as necessary.

    Next, use the State Transition editor to define a conditional for each transition.

  16. Right-click a transition line.

  17. In the State Transition editor dialog, enter the name of the transition condition, and then click the Edit MAXScript button.

  18. Use the MAXScript editor window to enter or load a script that defines the condition(s) under which the transition is to occur.

    Typically, this is a function that tests a condition and returns 1 (if true) or 0 (if false), for example:

    fn test1 del t = (
    if (del.simpos.x <= 40 and del.duration > 50) then 1 else 0
    )

    In plain English, the above statement says that if the delegate's position on the X axis is less than or equal to 40, and it has been in the current state for more than 50 frames, then the transition should occur. However, if either condition is false, or both are, then the delegate should stay in the current state (or test any other transitions). Following is a list of its keywords:

  19. Use the State Transition editor to set other parameters such as priority and duration.

  20. Use the Behavior Assignments and Teams dialog to assign the cognitive controller to delegates or teams.

    Note: Crowd doesn't let you use multiple cognitive controllers with a delegate. You can assign them, but when you solve, the software notifies you that it will use only the first assigned cognitive controller.

Interface

Create State: Lets you create new states in the diagram. Click this button, and then click in the state diagram area to add states. A state appears as a rectangular box containing the name of the state.

The first state you add is, by default, the first state in the controller that executes when the simulation is run. This is indicated by its red color; states you add subsequently are colored blue. To set a different state to execute first, use the Set Start State function.

You specify a state's name and behaviors by editing the state. To edit a state, right-click it. This opens the State dialog.

Create Transition: Lets you link states with transitions. Click this button, and then drag between two states to create the transition, starting with the earlier state. The transition appears as a black arrow pointing from the first state to the second. Alternatively, if you click a state with the Create Transition tool active, you create a transition that loops back to the state itself.

Right-click a transition to specify its characteristics and conditions by editing the transition. This opens the State Transition dialog.

Set Start State: Normally the state that executes first in a cognitive controller is the one that was added first. Use this tool to choose a different state to execute first. The start state is red; the rest are blue.

Typically you would use this when you have a circular sequence of states, and you want to change which state executes initially.

Move State: Lets you move states around in the window by dragging them.

Select State/Transition: Lets you select states and transitions for subsequent deletion. Selected states have white outlines, and selected transition lines are white.

You can select multiple states by dragging a box around them. You can select multiple states and transitions by holding the CTRL key as you click.

Delete State/Transition: Lets you delete states and transitions. First select the state(s) and/or transition(s) to delete, and then click this button.

(Name): Shows the name of the current state diagram. To display and/or edit another, choose it from the list.

To change a state diagram's name, click the name in the box and use the keyboard to edit the text.

New: Adds a new cognitive controller. By default, cognitive controllers are named CogControl followed by a number, but you can change this to anything you like.

Delete: Deletes the current cognitive controller. This is an undoable operation.

 

 

 


Comments