Group behaviors: flocks of birds

Click to choose your language:



General simulation description

The main feature of program is to demonstrate group behavior of the individuals. Each individual follows simple, local range rules without knowing anything about behavior of the group as a whole. It effects on behavior of whole group.


Figure 1. The group

Each individual tries to:

  • keep similar speed as its neighbors
  • not to collide with its neighbors
  • not to stand off its neighbors.

Simulation rules

Each individual modifies its behavior due to three neighbors observation:

  • left neighbor,
  • leader – closest individual in front of it,
  • right neighbor.


Figure 2. Neighbors.
(flight direction is shown)

If an individual doesn't have a leader it becomes group leader and keeps given flight direction. This way group as a whole has always some direction and we can observe individuals behavior inside the group. This establishment results straight from nature observation – leading individuals follow some additional stimuli which give them information what flight direction should they keep. Information about these is not necessary for group behavior simulation.

  • individual tries to keep weighted mean of three its neighbor speeds (standard weights 1/2/1),
  • individual modifies its speed in a way which won't let it to get too close to neighbors (each individual have different preferences to distance they keep),
  • individual modifies its speed in a way which won't let it to stand off neighbors,
  • group leaders have limited possibilities (they get tired), when maximum limit is exceeded they withdraw and others take their place,
  • each individual have maximum speed it can reach
  • to each individual's movement some random distortion is added.

Implementation

Simulation run. For each individual X do:

  1. Find nearest neighbors of individual X. Save their indexes (S1, L, S2) and square distances from individual X (S1D, LD, S2D)


    Figure 3. Nearest neighbors.

  2. Randomly choose one of side neighbors (S1 or S2) for use in given iteration.
  3. If individual X hasn't got a leader (is a leader itself) increase tiredness parameter T. In other case decrease T. If critical level of tiredness is exceeded decrease speeds VX and VY by 5%.
  4. If individual X is too close to its neighbors (measurement is independent on X and Y axis) decrease VX and VY properly.
  5. If individual X is too far from neighbors (measurement is independent on X and Y axis) increase VX and VY properly.
  6. Compute weighted means of neighbor speeds and save them in MVX and MVY. Modify VX by 10% of the difference between MVX and VX. Modify VY by 10% of the difference between MVY and VY.
  7. If individual X has exceeded maximum square speed decrease VX and VY by 25%.
  8. If individual X is too close to an obstacle (mouse cursor) modify its speeds VX and VY by 10%. Decrease VX and increase VY or decrease VY and increase VX (depending on obstacle position).


    Figure 4. Bypassing an obstacle.

  9. Add random distortion to speeds VX and VY.
  10. Move individual X due to VX and VY speeds.

Program options

randomize on/off Toggles random distortion to movement of an individual on/off
rescale Changes arrangement of individuals so the whole group could be visible on the screen.
center on/off Toggles view centering in the middle of the group on/off
step on/off Toggles step view refreshment on/off (redrawing by 100 simulation steps).Turning step view refreshment speeds up the program.
update Redraws the screen.
left-/left+ Increases/decreases left neighbor's speed weight
leader-/leader+ Increases/decreases leader's speed wight
right-/right+ Increases/decreases right neighbor's speed weight
lead time-/lead time+ Increases/decreases time of group leading
mouse on/off Turns mouse cursor influence on birds behavior on/off. If this option is active individuals try not to get to close to the point indicated by cursor.
mark leaders Allows marking leaders in red.
pause Pauses simulation.
restart Restarts simulation.
quit Ends program.
Program and text: Piotr Dachtera
Mentor: Maciej Komosinski
Translation: Piotr Ceglowski