Simulation with AnyLogic/Agent-Based Modeling/Step 10. Adding agent animations

''' Step 10. Adding Agent Animations '''

Now we will create a simple animation of our model to visualize the process. We want to draw agents on our presentation. Agents will be displayed relative to the coordinates they have in the modeled environment.Product adopters and potential adopters will be shown with the shapes of different colors.

Draw a shape depicting a person


 * 1) Open the Person class diagram by double-clicking the Person item in the Project view.
 * 2) Zoom the diagram in, say to 400% scale. [[File:Step 10. Adding agent animations1.png]]
 * 3) Drag the diagram a little bit down and to the right with the right mouse button pressed.
 * 4) Draw the agent shape like shown in the following figure: [[File:Step 10. Adding agent animations2.png]]
 * 5) Draw it using a curve. Therefore, choose the Curve [[File:Step 10. Adding agent animations3.gif]] element from the Presentation stencil of the Palette view (this stencil contains shapes and controls you can add on your presentation) and successively click at each curve point on the diagram and finally double-click to finish drawing.
 * 6) Place the shape right in the upper left corner in the point (0,0) (the coordinates of the mouse cursor are shown in the status bar): [[File:Step 10. Adding agent animations4.png]]
 * 7) Zoom the diagram out.
 * 8) Click on the agent shape and open the Dynamic properties of the shape. In the Fill Color property, type

The expression checks, whether the person is a potential adopter (the PotentialAdopter state of the agent's statechart is active). Adopters will be displayed with red points, potential adopters – with blue ones.

Modify the model to set up agent animations properly

The point where we place our shape will be the upper left corner of the agent's environment area. Agents with (0,0) coordinates will be placed there.
 * 1) Open the Main class diagram by double-clicking the Main item in the Project view.
 * 2) Select the people object in the graphical editor. On the General page of its Properties view, click the Create Presentation button. You will see the agent shape appeared in the upper left corner.
 * 3) Drag this shape down to the place shown in the following figure:
 * 1) Select the environment object.
 * 2) Open the Advanced tab of the environments Properties view. Define the dimensions of the space our agents populate. Set up Width 650 and Height' 300. [[File:Step 10. Adding agent animations7.png]]

We have finished creating the animation. Run the model and watch the dynamics on the network.