C/C++‎ > ‎

Boids


Boids is a swarm simulation, the birds follow these rules:

 - Separation: steer to avoid crowding local flockmates
 - Alignment: steer towards the average heading of local flockmates
 - Cohesion: steer to move toward the average position of local flockmates
 - Escape: steer away from the "eagle"
 - Border constraints, here the position is just turned down

The calculation of the flock's position is done in two threads, the GUI is done via FLTK.
The birds move in 3D space, their depth is indicated via their brightness.
Compile it with (needs libfltk-dev):
  $ g++ -O3 -Wall -funroll-loops -o boids boids.cpp -lfltk -lpthread
  $ g++ -O3 -Wall -funroll-loops -o boids_3D boids_3D.cpp -lfltk -lpthread

qt-boids-2.tar.gz needs Qt, unzip the folder and run qmake, then make.


The dots are the birds, the big one is the eagle.

Č
ċ
ď
boids.cpp
(17k)
El Samuko,
Sep 23, 2010, 1:21 PM
ċ
ď
boids_3D.cpp
(19k)
El Samuko,
Sep 23, 2010, 1:26 PM
ċ
ď
qt-boids-2.tar.gz
(4k)
El Samuko,
Sep 24, 2010, 3:05 AM
Comments