Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/falcowinkler/flockingbird

Flocking algorithm implementation in c++
https://github.com/falcowinkler/flockingbird

boids boids-algorithm boids-behaviour boids-simulation cpp cpp11 emergence flocking header-only modelling-biological-systems simulation

Last synced: 2 months ago
JSON representation

Flocking algorithm implementation in c++

Awesome Lists containing this project

README

        

### flockingbird
A header-only c++ library for creating 2D flocking animations.
http://www.cs.toronto.edu/~dt/siggraph97-course/cwr87/

![demo500](https://user-images.githubusercontent.com/8613031/119993840-52e67280-bfcc-11eb-8697-ae98e67c4900.gif)

The algorithm uses [kD-Trees](https://github.com/jlblancoc/nanoflann) 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.

### setup
(I don't have a windows PC, so just for mac)
```bash
brew install cmake
brew install llvm
brew install clang-format # for working on the project/formatting
```

### Dependencies
For the demo animation:
```bash
brew install cairo
brew install gtk+3
```

NOTE: i had to
```bash
export LDFLAGS="-L/usr/local/Cellar/cairo/1.16.0_5/lib $LDFLAGS"
```

### build

```bash
cd build
cmake ..
make && make install
```
### build and test
```bash
./test.sh
```

### run demo
```bash
./build/flockingbird_demo
```

### emacs integration

make sure that compile_commands is linked to the root

```bash
ln build/compile_commands.json .
```

### Credits/Disclaimer
Resources used for development
- http://www.vergenet.net/~conrad/boids/pseudocode.html
- https://p5js.org/examples/simulate-flocking.html

### Bindings
- [Swift](https://github.com/falcowinkler/flockingbird-swift) (Work in progress)