Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/erthium/boids
Simulation of Boid artificial life program
https://github.com/erthium/boids
agent-based-simulation boids boids-behaviour boids-simulation cpp cpp11 flocking flocking-agents flocking-simulation functional-programming makefile sdl sdl2 sdl2-image simulation
Last synced: 5 days ago
JSON representation
Simulation of Boid artificial life program
- Host: GitHub
- URL: https://github.com/erthium/boids
- Owner: erthium
- License: gpl-3.0
- Created: 2024-04-05T22:22:06.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-04-24T00:54:53.000Z (8 months ago)
- Last Synced: 2024-10-30T18:04:30.671Z (about 2 months ago)
- Topics: agent-based-simulation, boids, boids-behaviour, boids-simulation, cpp, cpp11, flocking, flocking-agents, flocking-simulation, functional-programming, makefile, sdl, sdl2, sdl2-image, simulation
- Language: C++
- Homepage:
- Size: 5.47 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Boids
Simple simulation of **Boid** artificial life program initially developed by Craig Reynolds in 1986.
---
---
The main source that I followed while developing the simulation is [Boids - Cornell ECE](https://people.ece.cornell.edu/land/courses/ece4760/labs/s2021/Boids/Boids.html), I appreciate the detailed explanation and the code provided.
## License
This project is licensed under the [GNU GPL-3.0](https://github.com/ErtyumPX/boids/blob/main/LICENSE) license.
Feel free to use the source code. Referring to the repository would be very much appreciated.
## Setup
Project is currently compiled with `GNU G++ 13.2.1`.
The only third-party dependency is `SDL2`. Used version of SDL2 in project is `2.28.5`, should work as long as it is **SDL2** and not **SDL**.
For compiling and linking rules `GNU Make 4.4.1` was used. After downloading dependencies, make sure to change the include paths inside the Makefile.
```
# change the paths for '-I'
CC := g++
CFLAGS := -Wall -std=c++11 -I/usr/include/SDL2 # here
TEST_CFLAGS := -Wall -std=c++11 -Iinclude/SDL2 -Isrc/ # and here
LDFLAGS := -lSDL2 -lSDL2_image
...
```After fulfilling dependencies, download or clone the project and use Makefile to easily compile:
```
> make all
> make run
```Since SDL2 is a cross-platform media library, output should work on Windows, MacOS and Linux.
## Rules
As with most artificial life simulations, Boids is an example of emergent behavior; that is, the complexity of Boids arises from the interaction of individual agents (the boids, in this case) adhering to a set of simple rules. The rules applied in the simplest Boids world are as follows:
- **Separation**: steer to avoid crowding local flockmates
- **Alignment**: steer towards the average heading of local flockmates
- **Cohesion**: steer to move towards the average position (center of mass) of local flockmatesSource: [Wikipedia Boids](https://en.wikipedia.org/wiki/Boids)
## Simulation
The simulation allows you to:
- Speed up/down the simulation using `q` and `e` keys
- Toggle the debug mode for seeing each agents' visual and protected range using `d` key
- Restart the simulation using `r` key**Speeding Up/Down**
**Debug Mode**
## General Structure
### Directory Structure and Files
- `src/` directory contains the source code
- `src/main.cpp` is the entry point of the program
- `src/game.hpp` contains the declarations of the core functions
- `src/game.cpp` contains the implementation of core functions
- `src/agent.hpp` has the struct of the boid agents
- `src/master.cpp` has the struct of all the configurations for the simulation
- `stable/` directory contains the stable output
- `stable/boids.follow` is the executable### How It Goes
Will be updated soon.