connor-brooks / ecosim

An interactive ecosystem and evolution simulator written in C and OpenGL, for GNU/Linux.
GNU General Public License v2.0
389 stars 12 forks source link
boids ecosystem evolution game genetic-algorithm life linux simulation

Ecosim Logo

Screenshot of ecosim

Requirements

$ sudo apt-get install libglfw3 libglew2.0 libglfw3-dev libglew-dev ffmpeg

Grab the code:

$ git clone https://github.com/connor-brooks/ecosim.git

Enter source directory:

$ cd ecosim/src

Build:

$ make

Run the simulation:

$ ./ecosim

Controls

Behaviour of agents

Agents within the simulation constantly loose energy over time, as moving around in the environment causes energy to be burned. The only way energy levels can be increased is via consumption.

Dietary preferences of agents vary, but fall into two main categories:

If an agents energy drops below a threshold, death occurs. In contrast, passing above a another threshold causes the agent to split into two copies of itself (asexual reproduction).

When an agent splits, it doesn't always make an exact copy of itself. Sometimes mutation occurs. This means that the genetic code (DNA) that dictates the agents behaviours is slightly modified.

These genetic traits are as follows:

Over time, only the most successful agents are able to pass on their DNA, causing the population of agents to slowly evolve.

However, it is important to note that there is no one-size-fits-all perfect agent. For a well functioning ecosystem to exist, balance is essential. For example: the existence of carnivores is essential to the existence of the herbivores in order to prevent overpopulation, which would result in mass-starvation and extinction of the herbivores.

Traits in detail

Metabolic rate

The metabolic rate is the rate which an agent transforms stored energy into kinetic energy. This has both pros and cons. Being able to move around the environment faster allows agents to consume food faster, but also causes the agent to eat more frequently.

Vision range

This trait dictates how far an agent can sense other entities. A larger vision range is generally beneficial. However, this trait has some minor downfalls, especially for herbivorous agents. For example: hypersensitivity to other agents causes fleeing from non-dangerous situations, which in turn results in reduced ability to consume.

Rebirth rate

Rebirth rate controls how much energy is stored within an agent before splitting (asexual reproduction) occurs. This is especially useful for agents with low metabolism, as it allows them to navigate the environment for a longer time without depleting their energy.

Dietary preference

Agent's dietary preference influences what food source an agent will pursue and consume: living or non-living. For an ecosystem to be stable, the need for agents of both these groups is required.

Flocking strength

Flocking is a behaviour in which agents form groups, or clusters, whilst navigating the map, forming "multicellular life". Paradoxically this offers both safety and vulnerability. By sharing information whilst flocking, a group increases it's members knowledge of other potential dangers or food. In contrast, if the group fails to avoid a potential danger the whole group suffers.

Wobble frequency

Whilst moving around the screen, agents speed up and down in a sinusoidal pattern, creating a "crawling" effect. The frequency of this movement is dictated by the wobble trait. Wobbling has both advantages and disadvantages, with a lower frequency resulting in longer periods of increased speed but also longer resting periods.

Tweaking the simulation

Ecosim provides a way to configure the mechanics of the simulation via editing the config.h file. The process of doing so is as follows:

What to change

This is entirely down to personal preference, however, most people will only be concerned with two sections of the configuration: The general agent settings, and the agent DNA settings.

Enable logging

In order to use the population/trait logger, change the LOGGER_ENABLE setting to 1, recompile, and run:

./ecosim_with_log.sh

Note, python3 and matplotlib is required in order to plot logged data.

Screenshot of ecosim in logger mode

List of config settings

Main world settings

Notes