This page was automatically generated by NetLogo 3.1.4. Questions, problems? Contact firstname.lastname@example.org.
The applet requires Java 1.4.1 or higher. It will not run on
Windows 95 or Mac OS 8 or 9. Mac users must have OS X 10.2.6 or higher and use
a browser that supports Java 1.4. (Safari works, IE does not.
Mac OS X comes with Safari. Open Safari and set it as your default
web browser under Safari/Preferences/General.)
On other operating systems, you may obtain the latest Java plugin from
Sun’s Java site. General information on the models, including instructions for running them on your own computer, is available from the NetLogo Simulation Information Page. To download this page, do not use "Save As," but right-click (or on Macs control-click) on this link. You also need to download the NetLogo program, which you can do by right-clicking or control-clicking this link.
created with NetLogo
view/download model file: Flock.nlogo
This project is an attempt to simulate the coordinated motion of a group of individuals such as fish in a school, or birds in a flock. Each bird follows a simple rule, and the flock as a whole moves without any leader. A bird adjusts its flight based on the position and/or heading of its three nearest neighbors; this adjustment is partitioned into three zones:
1) Repel range. A bird moves away from neighbors that are too close.
2) Direction range. A bird aligns with neighbors that are a comfortable distance away (i.e., it attempts to match the neighbor's heading.)
3) Position range. A bird moves towards neighbors that are far away.
A bird adjusts its heading towards a vector sum of the "target" headings that these would imply for each neighbor; the influences of birds are weighted by the inverse of distance, such that close birds are more influential than distant ones.
In addition, a bird will accelerate slightly for each neighbor in front of it and in the position range; it will decelerate slightly for each neighbor that is behind it and in the position range. This allows trailing birds to catch up with the flock and leading birds to slow down without turning around. All birds also have a blind spot (the default is 30 degrees) directly behind them, in which they cannot sense the presence of other birds.
For the sake of simplicity, birds reflect off of obstacles as light would reflect off of a mirror. Though this is not necessarily realistic, it adds variety to the simulation by forcing the birds to continually adapt the flocking structure to outside influences.
The RESET_BOARD button erases all obstacles that have been drawn and restores the edge boundary.
The RESET_TURTLES button creates the specified number of birds and places them in black cells on the board.
The GO button executes the flocking rules described above; one button executes a step at a time and the other runs continuously.
The MAKE_OBSTACLES and REMOVE_OBSTACLES buttons allow you to make obstacles that the birds must avoid, and to remove them.
The OBSTACLES_TRANSPARENT and OBSTACLES_OPAQUE buttons toggle the way birds perceive obstacles in the middle of the screen. After selecting obstacles_transparent, birds can still see neighbors that are on the opposite side of an obstruction. Selecting obstacles_opaque (which is done by default in the reset_birds procedure) causes obstacles to block the birds' line of sight and hide neighbors that are behind obstacles. The step by step go button should be used when obstacles are opaque, because no attempt is made to synchronize the turtles' execution of commands when they are looking for obstacles.
The NUMBER slider sets the number of birds in the simulation.
The REPEL_RANGE, DIR_RANGE, and POS_RANGE sliders control the outer limits of each of these zones. The relative sizes must be maintained for the program to function properly (i.e. repel_range < dir_range < pos_range.)
The NOISE slider determines the maximum random adjustment that a bird could make to its heading in a single time step.
The FLEXIBILITY slider controls how completely a bird adjusts its heading to the calculated target. A flexibility of zero would cause a bird to maintain straight-line motion (excluding walls and random turns), while a flexibility of 100 represents instantaneous adjustment to the influences of the three closest neighbors.
Obstacles can easily be created in the center of the screen by using the MAKE_OBSTACLE button; the flock remains quite cohesive when confronted with various shapes and sizes of obstacles. Cohesiveness is affected by the parameters, in particular flexibility and noise.
Modified for NetLogo by B.J. MacLennan, October 2007, from original version by William Thies on Scott Camazine's website.
Based on the Huth and Wissel (1992) model of fish schooling.