Flocking Simulator

Brent Dimapilis
CSC471 Final Project
Fall 2010

Background

In nature, birds can be seen flying within flocks. There are similar behavior patterns found across all flocks. The flocking simulator tries to imitate the behavior of birds in flight as they would appear in nature. In this paper, birds will be referred to as "boids", taken from Craig Reynolds' paper on distributed behavior models. This project uses the boids algorithm discussed in his paper. The name "boid" refers to a bird model, but the pronunciation is that of "bird" in a stereotypical New York accent.

Characteristics

There are similar flying patterns found in all flocks in nature. In this program, boids tend to follow these five main rules to direct their flight:

Boids are translated across the world using an average of these default characteristics. Extra characteristics have been implemented into this program to illustrate other types of behaviors. These extra characteristics affect the behavior of a boid when enabled:

An example of birds flying towards a specific target can be found in Figure 1. An alternate view (right) also shows the direction vectors (green) of the boids.

Figure 1: Boids flying towards a target (orange boid).

Modeling

The modeling in this program was created using a few primitive objects. The final bird model in this program is animated. Initially, the model of the bird was a spherical object with wings, found in Figure 2.

Figure 2: Spherical figure.

Later, the model was redone to replicate a more bird-like figure, using more primitive objects. This is shown in Figure 3.

Figure 3: The sphere is now a bird.

Running Simulator

To compile this program on a unix machine, the user enters the following into the command line:

   g++ -lglut -lGL boidssim.cpp

To run the program, the user runs the executable followed by the number of boids to use within a flock. For example, running the program with 300 boids would look like:

   ./a.out 300

To run this program at the right speed, you will need to choose the right amount of boids to run the program with. The system that I have been using outputs the best performance when ran with 300 boids.

Controls

The following controls are implemented into the flocking simulator:

   w - move controllable boid in positive y-direction
   a - move controllable boid in negative x-direction
   s - move controllable boid in negative y-direction
   d - move controllable boid in positive x-direction
   z - move controllable boid in positive z-direction
   x - move controllable boid in negative z-direction
   p - pause animation
   o - resume animation
   i - scatters the flock (press i again for default behavior)
   u - changes flock behavior towards controllale boid (ignore, fly towards, fly from)
   l - turn lighting on or off
   m - rotate controllable boid
   q - quits program

Conclusion

There are various programs that try to imitate the behavior of flocks and different programs use different methods to characterize the behavior. For this program, all of the rules were used to calculate an average translation in the world. Other programs use a priority structure, where only certain rules are met based on the boids situation. Other programs go for more of a realistic approach where others tend to be more exaggerated, such as for cartoon animation. There is no right or wrong way to model the behavior of a flock as it is up to the implementer.

Resources

Flocks, Herds, and Schools: A Distributed Behavior Model Paper on the boids algorithm written by Craig W. Reynolds, submitted to SIGGRAPH.
Boids Pseudocode A very helpful website that explains the boids algorithm in pseudocode.
Boids Background A more detailed discussion on steering behaviors behind the boids algorithm.