Student work
Artificial life
Fish school and obstacles

Please note

The simulation needs a Java-Plugin (1.3.x) installed for your internet browser. If you do not already have one installed, the browser will prompt you to download the Plugin from “Sun”, who is the inventor of Java. Please download the JRE (=Java runtime environment) into a directory on your computer (e.g. “c:\temp”), execute the downloaded file for installation on your system (double-click on the file). Afterwards you will be able to reload the simulation page. Maybe you will have to restart your browser to succeed.

Run the simulation

Please click here.

Description of the simulation

In this simulation, you can see fish, that form swarms and avoid obstacles and predators. Basically, prey and predators perform an random walk. But there are several special individual events and behaviors, that lead to the observed group behavior:

Prey behavior

Every x steps, each prey fish updates a list of visible neighbors, which are all fish within a range given by the slider sensory-range. How often this update is performed is given by the slider called update-neighborhood-every. It is only for speeding up the simulation, that the neighborhood gets sensed by each fish every time step.

After that, several random fishes are picked out from this sensed neighbored fishes. How much are picked is given by the slider accounted-fish.

Each of these picked fishes has some influence upon the focal fishes further moving direction. If the picked fish is too near, the fish works like a repellent and the focal fish turns away. If the picked fish further away, the focal fish chooses a traveling direction parallel to those of the picked fish. If the picked fish is too far away, the focal fish turn toward the picked fish, in order to decrease the distance.

The two sliders dist-repulsive and dist-parallel set the two borders between the three ranges of distances.

  • If the distance < dist-repulsive, than the focal fish turns away
  • if the distance is between dist-repulsive and dist-parallel, then the focal fish aligns to the picked fish
  • if the distance > dist-parallel, then the focal fish turns towards the picked fish.

But the focal fish does not just pick one single fish from his neighborhood. How to deal with the information gathered from several picked (accounted) fishes ?

The solution is just building mean values. Each accounted fish results into a vector. The focal fish just averages all those vectors. When turning on the slider latency, the vectors are not affecting the focal fish immediately. Again, we calculate weighted means with the current moving vector and the vectors suggested by the accounted neighboring fishes. The higher the latency, the more weight is accounted to the current moving vector.

But the moving vector of all prey fish is not only influenced by other prey fish. Predator fishes work as extreme repellants, obstacles also work as repellants.

The slider randomness provides additional random input to this decision.

Predators behavior

The predator fishes perform basically a random walk, but when prey fish come into their view, they turn towards them.


  • Check how the number of actors (prey, predators, obstacles) changes the collective behavior.
  • Check whether the number of fishes taken into account for the flocking decisions plays an important role or not.
  • Check how the latency influences the movements of the swarm
  • Test several combinations of dist-repulsive, dist-parallel and sensory-range and see, how different kinds of flocks are created (dense flocks, loose-flocks,...)



The presented NetLogo simulation was written by:
Thomas Schmickl (2002), Department for Zoology, Karl-Franzens-University Graz, Austria, Europe,,

Further readings

  • Camazine S., Deneubourg J.-L., Franks N.R., Sneyd J., Theraulaz G. and Bonabeau E. (2001) Self-Organization in biological systems. Princeton University Press.

[Home] [Self-organization] [Ecology] [Populations] [Artificial life] [Student work] [Software] [Links] [Contact]