Flocking Vee Formations

Flocking Vee Formations preview image

3 collaborators

Tags

biology 

Tagged by Reuven M. Lerner over 11 years ago

ccl 

Tagged by Modeling Commons System almost 13 years ago

flocking 

Tagged by Reuven M. Lerner over 11 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 945 times • Downloaded 74 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.)


WHAT IS IT?

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.

HOW IT WORKS

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.

HOW TO USE IT

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.

THINGS TO NOTICE

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.

THINGS TO TRY

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?

EXTENDING THE MODEL

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?

NETLOGO FEATURES

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.

RELATED MODELS

Flocking

CREDITS AND REFERENCES

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)

HOW TO CITE

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 AND LICENSE

Copyright 2009 Uri Wilensky.

CC BY-NC-SA 3.0

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
  clear-all
  create-turtles number-of-birds [
    setxy random-xcor random-ycor
    set speed base-speed
    set size 1.5 ; easier to see
    set happy? false
    recolor
  ]
  reset-ticks
end 

;;
;; 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 ]
    recolor
    fd speed  ; fly forward!
  ]
  tick
end 

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
    stop
  ]

  ;; 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
    stop
  ]

  ;; 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)
    stop
  ]

  ;; 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
end 

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)
  ]
end 

;;
;; 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)
end 

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


; 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 over 11 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky about 12 years ago Updated version tag Download this version
Uri Wilensky about 12 years ago Updated to version from NetLogo 5.0.3 distribution Download this version
Uri Wilensky almost 13 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 11 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.