2.4. Discrete Event Simulation

A Swarm simulation proceeds in discrete time steps. Objects are created and then interact according to a scheduling mechanism. As the simulation proceeds, the agents update their instance variables and they may be asked to report their state to the observer swarm layer of the simulation.

The modeling process in Swarm, then, is quite different from simulation modeling in a non-object oriented language, such as Fortran or Pascal. These so-called "procedural languages" do not allow the modeler to take advantage of reusable classes through inheritance or the preservation of data allowed by encapsulation. Here's an example of a simulation in a procedural language:

Procedural language pseudo-code

  1. get parameters

  2. initialize[1]

  3. for 1 to timesteps do:

    1. for 1 to num_agents do:

      1. agent-i-do-something [2]

    2. show state [3]

  4. quit



Generally sets up data structures and support for output.


Here must provide data structure to save agent's state and implement behavior


Implementation of output often left to the programmer