A header-only c++ library for creating 2D flocking animations. http://www.cs.toronto.edu/~dt/siggraph97-course/cwr87/
The algorithm uses kD-Trees to calculate the neighbors of a boid, making it possible to simulate more than a thousand boids (depending on framerate, compiler optimization level, and processor speed).
Please use the highest optimization level if you compile the library yourself. 500 boids is already difficult with the default optimization, whereas with -O3
you can easiliy run a 1000 boid simulation.
(I don't have a windows PC, so just for mac)
brew install cmake
brew install llvm
brew install clang-format # for working on the project/formatting
For the demo animation:
brew install cairo
brew install gtk+3
NOTE: i had to
export LDFLAGS="-L/usr/local/Cellar/cairo/1.16.0_5/lib $LDFLAGS"
cd build
cmake ..
make && make install
./test.sh
./build/flockingbird_demo
make sure that compile_commands is linked to the root
ln build/compile_commands.json .
Resources used for development
- http://www.vergenet.net/~conrad/boids/pseudocode.html
- https://p5js.org/examples/simulate-flocking.html
- Swift (Work in progress)