swarm-modeling
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

New code for boids, fish schooling


From: M Lang / S Railsback
Subject: New code for boids, fish schooling
Date: Tue, 31 Oct 2000 08:24:02 -0800

Some of the fruits of our recent collaboration with Geir Huse (a
fisheries researcher with an interest in Complex Adaptive Systems,
University of Bergen, Norway) are now available at:
ftp://ftp.swarm.org/pub/swarm/src/users-contrib/anarchy/

We were looking at the question: If fish schooling is modeled using the
Boids algorithm (fish try to match each other's speed and swim towards
each other), how many of the fish have to move in the same direction to
re-direct the entire school?

These models are good for Boids-like demos and for wasting incredible
amounts of time watching (and experimenting with) little things bouncing
around the screen. It is especially fascinating to vary the movement
parameters during a run and watch how behavior changes.

Here are the three models we posted. Each (except ClupeoidsV1) has a
ReadMe file and all seem to work in Swarm 1.4.1, 2.0.1, and 2.1.1.
Thanks to Steve Jackson for deciphering the original Boids and doing the
coding.

I. NewBoids:

This is a minimal modification and cleanup of Eric Werk's Swarm version
of Boids. We fixed the memory leaks, so it is safe to run as a demo on
your laptop. The original display object is a Canvas that looks nicer
but (a) leaks and (b) does not run in Windows without special effort
(see the ReadMe). We added a second zoom raster display that can be used
instead of the canvas. We also fixed an error in how the boids determine
which other boids they interact with, so it will not produce the exact
same results as Werk's original.

This version of Boids uses a movement formulation that is fairly
elaborate and difficult to explain. There are actually up to six
criteria for determining movement. The order in which the different
movement criteria are applied (collision avoidance, maintaining speed,
flock centering, velocity matching, etc.) is important, and the methods
for calculating and applying the acceleration vector are
counterintuitive. Expect to spend several hours in the code before
attempting to understand exactly what it is doing. In this version, we
made no attempt to improve or document the formulation. 

The code does include a very complete and useful vector math object. 

II. ClupeoidsV1:

This was our first modification of Boids into a fish schooling model.
The movement algorithm is nearly the same as in Werk's Boids, which
means that it is not as simple and understandable as ClupeoidsV2 but
(therefore?) produces more interesting behavior. There are a number of
other important changes.

1. When clupeoids reach the edge of the space, they bounce off. (Boids
had an error in its toroidal space implementation that was not easily
fixable.)

2. During a simulation, the user can send a selected number of clupeoids
to a chosen location (e.g., to see how many other clupeoids follow
along). When these "directed" clupeoids arrive at the chosen location
they turn into circles on the display and no longer move. This is done
via the BoidSpace probe display, which provides access to the method
[send: fishToX: Y: ]

3. The canvas space object was replaced with a zoom raster. The
clupeoids appear as a line segment pointed in the direction of their
velocity, with length proportional to velocity magnitude.

4. The movement parameters can be changed during a simulation using the
probe display (this is good for hours of fun!). The default values of
the movement parameters are in an object loader file "Boid.Params".

III. ClupeoidsV2:

This model is similar to ClupeoidsV1 except that we completely replaced
how the fish decide where to move to. The clupeoids follow only two
rules in moving: match the velocity of the neighboring clupeoids that
they detect, and move toward the centroid of the location of the other
clupeoids that they detect.

Detected neighbors are the other clupeoids that are (1) within the
distance defined by the parameter interactionDist, and (2) within the
field of view (defined by the parameter fieldOfView- a parameter that is
especially fun to play with). The field of view is defined as the
fraction of a full circle that a clupeoid can see- for example, if
fieldOfView is 0.6, then each clupeoid can detect others that are within
130 degrees either side of straight ahead. (The field of view method and
code was in Eric Werk's original boids.)

There are no methods active to maintain a minimum distance between
clupeoids or to maintain any desired speed. There are no obstacles or
predators in clupeoids.

Steve Railsback
-- 
address@hidden
Lang, Railsback & Assoc.
250 California Ave., Arcata CA 95521
707-822-0453; Fax 822-1868


                  ==================================
   Swarm-Modelling is for discussion of Simulation and Modelling techniques
   esp. using Swarm.  For list administration needs (esp. [un]subscribing),
   please send a message to <address@hidden> with "help" in the
   body of the message.
                  ==================================



reply via email to

[Prev in Thread] Current Thread [Next in Thread]