This project aims to be a simulation of a basic ecosystem. This is inspired from Daniel Schiffman's simulation which can be found here.
Current version: 1.1.0
This project uses a CMakeLists.txt
file to build the project. The parameters for the cmake command are listed below.
Option name | Description |
---|---|
OUTPUT_DIRECTORY | The output directory where the binary is gonna be located. |
SFML_ROOT | The path to the SFML root location (in case Cmake can't find it properly with FindSFML.cmake). |
- Visual Studio 15 / 17
- CMake > 2.5
- C++14
Clone the repository, open a command prompt in it and type:
Example 1 (32 bits environnement):
mkdir build
cd build
cmake ..
cmake --build .
Example 2 (64 bits environnement):
mkdir build
cd build
cmake -G "Visual Studio 15 Win64" ..
cmake --build .
Example 3 (using CMake options):
mkdir build
cd build
cmake -DOUTPUT_DIRECTORY=..\bin -DSFML_ROOT=C:\path\to\your\SFML\location -G "Visual Studio 15 Win64" ..
cmake --build .
- g++
- CMake > 2.5
- C++ 14
Clone the repository, open a terminal in it, and type:
Example 1 (without CMake options):
mkdir build
cd build
cmake ..
make
Example 2 (with CMake options):
mkdir build
cd build
cmake -DOUTPUT_DIRECTORY=../bin -DSFML_ROOT=/path/to/your/SFML/location ..
make
Make sure the different .dll
files are in the folder where the executable is. Those .dll
files are needed:
- freetype.dll
- jpeg62.dll
- libbz2.dll
- libpng16.dll
- sfml-graphics-2.dll
- sfml-system-2.dll
- sfml-window-2.dll
- zlib1.dll
Then, you should be able to run the executable Ecosystem_simulation.exe
.
You should be able to run the simulation by opening a terminal in the output directory and type:
./Ecosystem_simulation
-
Enter
: Starts the simulation -
Escape
: Ends the simulation -
Space
: Pauses/Resumes the simulation -
Left arrow
: Slows down the simulation by 2 -
Right arrow
: Speeds up the simulation by 2
-
There are
30
cells, spawning randomly on the window at the beginning of the simulation. -
A cell has a random radius value, from
5
pixels to50
. The biggest the cell is, the slowest it is (from10
pixels/second to50
). At the beginning of the simulation, each cell has100
HP. Each second, the cell loses3
HP. When a cell has no longer HP, it disappears: the cell is dead. A full HP cell isgreen
, while a almost-dead cell isred
. -
Each
0.7
seconds, a food appears on the window. A food is represented by ablue
octagon. When a cell comes into contact with a food, the cell eats it and regain20
HP.
Here's a short video how this simulation looks like:
This simulation uses SimplexNoise to simulate a natural movement for the cells and SFML to render the graphics.
You can customize pretty much all the settings of the simulation, such as:
-
The maximum HP of the cells
-
The number of HP lost per second
-
The minimum / maximum radius of the cells / food
-
Cells / Food color
-
The minimal / maximal speed of the cells
-
The number of seconds between the spawn of two two piles of food
-
The number of HP the cells regain by eating food
-
The color / size / font of the text
... and more.
You just need to change the constants values in the file src/constants.hpp
.
-
A more random natural movement for the cell. Currently, the movement is a bit predictable (the cells are more likely to move at the center of the window). Brownian movement?
-
Gather the info about the results of the simulation and write it down in a file. So, we could make statistics about the simulation.
-
Speeding up / down the simulation. (Version 1.1.0)
-
Save the animation in a
.mp4
file. -
Timer for the duration of the simulation. (Version 1.1.0)
-
Generations system (with genetic inheritance).
If you want to improve this project, feel free to create a pull request. Make sure your code respects the settings of the .clang-format
file.