Flocking Vee Formations

Flocking Vee Formations preview image

3 collaborators



Tagged by Reuven M. Lerner about 5 years ago


Tagged by Modeling Commons System over 6 years ago


Tagged by Reuven M. Lerner over 5 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 362 times • Downloaded 25 times • Run 0 times
Download the 'Flocking Vee Formations' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


This is an adaptation of the Flocking model to produce V-like formations in artificial flocks. Not all birds produce V-like formations when they flock, but they are often observed in large birds traveling together distances (e.g. migrating Canada geese). This model demonstrates simple rules that cause V-formations to occur.


Each bird starts out with a random position and heading in the world. If the bird cannot see any other birds in its limited vision range, it will continue to fly straight at its normal base speed. If it can see another bird, it follows four basic rules, given by this order of precedence.

  1. If it is too far away (that is, further than the distance for getting an updraft benefit) from the nearest visible bird, it will turn toward that bird and speed up to get near it.
  2. Once it is near enough to another bird, it will move randomly to one side or another until its view is no longer obstructed.
  3. If it gets too close to another bird, it will slow down.
  4. Once the three conditions above are met (the bird has an unobstructed view and is sufficiently close but not too close to another bird), the bird will set both its speed and its heading that of its closest visible neighbor.


NUMBER-OF-BIRDS sets the number of birds in the world.
Use SETUP to populate the world with birds, and GO to run the model.

Vision Parameters:
VISION-DISTANCE and VISION-CONE defines the radius and angle span, respectively, of the area within which a bird can see another bird. A VISION-CONE of 120 means that the bird can see up to 60 degrees to its right and 60 degrees to its left. OBSTRUCTION-CONE defines the angle span for which a bird considers its vision to be obstructed by another bird.

Motion Parameters:
BASE-SPEED defines the speed that birds will fly if they are not speeding up to catch another bird that they see, or slowing down to avoid colliding with a bird.
SPEED-CHANGE-FACTOR is the factor by which birds increase or decrease their speed, given as a fraction of their base speed. A BASE-SPEED of 1 with a SPEED-CHANGE-FACTOR of 0.25 means that birds will travel at speeds of 0.75 (slow speed), 1.0 (normal speed), or 1.25 (fast speed).
UPDRAFT-DISTANCE defines how near to another bird one must be to take advantage of its upwash.
TOO-CLOSE defines how close one bird can be to another bird before slowing down to avoid collision.
MAX-TURN sets the maximum number of degrees that a bird can turn during a single tick.

Visualization Parameters:
If SHOW-UNHAPPY? is switched ON, birds that have not satisfied the conditions outlined in the HOW IT WORKS section are colored red, and all the birds that have are colored white. If SHOW-UNHAPPY? is OFF, birds are colored varying shades of yellow.


After forming a vee-flock for a while, birds tend to drift apart from one another.

Birds following these rules may form flock formations other than a balanced V. These include asymmetrical (unbalanced) V shapes, echelons (diagonal lines), or inverted V shapes. In fact, imperfect formations such as these are more commonly observed than balanced vees in nature too.


Play with the sliders to see if you can get tighter flocks, looser flocks, fewer flocks, more flocks, more or less splitting and joining of flocks, more or less rearranging of birds within flocks, etc.

Does having lots of birds make it more or less likely to form good V shapes?

Can you set parameters such that running the model for a long time produces a single static flock? Or will the birds never settle down to a fixed formation?


What would happen if you put walls around the edges of the world that the birds can't fly through?

What would happen if you gave birds limited energy levels, so that flying fast would make them expend more energy and eventually become exhausted. Flying slowly, or within another bird's updraft, could allow them to recoup some energy.

Try making a 3D version of this model. What additional considerations have to be taken into account in three dimensions?


Birds use in-cone to find neighbors and determine whether their view is obstructed.

The subtract-headings primitive is also useful, for turning gradually (only partway) toward some new heading.




This model is loosely based on rules introduced in the paper:
Nathan, A. & Barbosa, V. C. (2008). V-like formations in flocks of artificial birds. Artificial Life, 14(2), pp. 179-188. (available at http://arxiv.org/pdf/cs/0611032)


If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:

  • Wilkerson-Jerde, M., Stonedahl, F. and Wilensky, U. (2009). NetLogo Flocking Vee Formations model. http://ccl.northwestern.edu/netlogo/models/FlockingVeeFormations. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.
  • Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.


Copyright 2009 Uri Wilensky.


This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

Comments and Questions

Click to Run Model

turtles-own [
  visible-neighbors      ;; what birds can I see nearby?
  closest-neighbor       ;; who's the closest bird I can see?
  speed                  ;; what speed am I flying at?
  happy?                 ;; am I content with my current place?

;; Setup Procedures

to setup
  create-turtles number-of-birds [
    setxy random-xcor random-ycor
    set speed base-speed
    set size 1.5 ; easier to see
    set happy? false

;; Runtime Procedures

to go
  ask turtles [
    set speed base-speed
    set visible-neighbors (other turtles in-cone vision-distance vision-cone)
    ifelse any? visible-neighbors
      [ adjust ]
      [ set happy? true ]
    fd speed  ; fly forward!

to adjust ;; turtle procedure
  set closest-neighbor min-one-of visible-neighbors [distance myself]
  let closest-distance distance closest-neighbor
  ;; if I am too far away from the nearest bird I can see, then try to get near them
  if closest-distance > updraft-distance [
    turn-towards (towards closest-neighbor)
    ;; speed up to catch up
    set speed base-speed * (1 + speed-change-factor)
    set happy? false

  ;; if my view is obstructed, move sideways randomly
  if any? visible-neighbors in-cone vision-distance obstruction-cone [
    turn-at-most (random-float (max-turn * 2) - max-turn)
    ;; speed up to get out of the way
    set speed base-speed * (1 + speed-change-factor)
    set happy? false

  ;; if i am too close to the nearest bird slow down
  if closest-distance < too-close [
    set happy? false
    ;; speed down to let the bird in front of me move away
    set speed base-speed * (1 - speed-change-factor)

  ;; if all three conditions are filled, adjust
  ;; to the speed and heading of my neighbor and take it easy
  set speed [speed] of closest-neighbor
  turn-towards [heading] of closest-neighbor
  set happy? true

to recolor ;; turtle procedure
  ifelse show-unhappy? [
    ifelse happy?
      [ set color white ]
      [ set color red ]
    ;; This changes the bird's color some shade of yellow --
    ;; note that the color is based on WHO number, not RANDOM, so birds
    ;; won't change color if the SHOW-UNHAPPY? switch is flicked on and off
    set color yellow - 2 + (who mod 7)

;; TURTLE UTILITY PROCEDURES, for turning gradually towards a new heading

to turn-towards [new-heading]  ;; turtle procedure
  turn-at-most (subtract-headings new-heading heading)

to turn-at-most [turn]  ;; turtle procedure
  ifelse abs turn > max-turn [
    ifelse turn >= 0
      [ rt max-turn ]
      [ lt max-turn ]
  ] [
    rt turn

; Copyright 2009 Uri Wilensky.
; See Info tab for full copyright and license.

There are 4 versions of this model.

Uploaded by When Description Download
Uri Wilensky about 5 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky over 5 years ago Updated version tag Download this version
Uri Wilensky over 5 years ago Updated to version from NetLogo 5.0.3 distribution Download this version
Uri Wilensky over 6 years ago Updated from NetLogo 5.0 Download this version

Attached files

File Type Description Last updated
Flocking Vee Formations.png preview Preview for 'Flocking Vee Formations' over 5 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.