DylanCope / Evolving-Protozoa

An interactive environment where protozoa-like entities live, die, and have offspring whose behaviours and morphologies can change.
MIT License
231 stars 24 forks source link
evolutionary-algorithms simulation

Evolving-Protozoa

Check the simulation out on YouTube:

IMAGE ALT TEXT HERE

Come discuss the project on discord!

Overview

The aim of this project is to create an environment where protozoa-like entities can evolve their behaviours and morphologies in order to survive and reproduce. The simulation takes place in a 2D environment with Newtonian physics implemented with Verlet integration. The following screenshot shows a zoomed-out view of the entire environment. In the screenshot below, can see procedurally generated rocks shown as brown-grey triangles that form rigid boundaries for cells moving around the tank fluids. The bright green cells are plants that serve as a sources of energy and mass for protozoa. These plants emit chemical pheromones that spread through the environment, and gradients of which can be detected by the protozoa. These pheromones are visualised in the screenshot and can be seen as the glowing green trails dispersed around and behind plant cells.

Running the Simulation

Prerequisites: Make sure you have Java version 9 or greater installed. If you don't know how to install it, then hopefully this tutorial will help you out!

Start by downloading the latest version from the Releases page on GitHub. The program will be downloaded as a ZIP file, so unzip it and locate the Evolving-Protozoa.jar file. You should also see a run.bat, a saves folder, and a config folder. If you are on Windows, you can launch the simulation by double-clicking the run.bat, otherwise, you can manually run the jar file from the terminal using the command in the run.bat. You should be met with a launch screen where you can reload a previous save or start a new one.

Accessing Simulation Data: The simulation records a lot of data as it runs, and makes back-ups of the tank at various stages. In the save's folder you can find CSV files containing the genomes of each protozoan, and overall statistics from the simulation polled at different moments in time.

Configuring the Simulation: There are various parameters that can be changed by editing the config/default_settings.yaml file before creating a new simulation. For an existing save, you can change the parameters by editing the settings.yaml file in the folder corresponding to the save. These changes will not take effect until you close and reload the simulation.

Linux: The project is developed and tested on Windows, but a user has created a build of the software on the Arch Linux Repository. Note: This is not maintained by the original developer. It may be out-of-date or untested.

Controls

Once you have the simulation running, there are a few controls that you might want to utilise.

Using the REPL.

Another useful feature is the ability to interact with the simulation through the commandline REPL. You can access it through the terminal that launched the program, in IntelliJ this will be in the run tab. The REPL is a simple commandline interface, you can start by typing help to see the available commands.

png

The most useful command is the toggleui command, which completely closes the program window and runs the simulation headless at maximum speed. The settime and gettime commands will allow you to control the simulation time, i.e. the amount of time that the simulation is stepped with each update. For instance, settime 2 will run the simulation twice as fast. However, this can change the behaviour of the simulation and lead to glitchy physics or cells that die fast, so be careful. Ancedotally, people have managed to increase it to x10 or x20, and still get interesting results.

Tips for Increasing Performance

The simulation requires a relatively powerful machine to run with acceptable framerates, but there are still several options available to increasing the performance.

Features

The primary objective of this project is to investigate the emergence of multicellular structures, i.e. the development of coordinated groups of attached cells that incur a survival benefit by being attached. So far, by implementing cell-adhesion and allowing protozoa to share resources I have seen the emergence of some quite cool multi-cell behaviour. However, the next step is to achieve cell differentiation via the evolution of gene-regulatory networks.

png

In the next screenshot we see a close-up of tracking a protozoa in the environment. The tracked cell is fixed at the centre of the screen as it moves around, and the neural network that controls its actions is illustrated on the right-hand side of the screen. This network evolved using a variation of the NEAT algorithm. The protozoa have a variety of other evolvable traits, including (but not limited to) their size, growth rate, colour, speed, herbivore factor, and the growth of offensive spikes for harming and killing other protozoa.

png

Zooming in more on a protozoan, we can see one of their key evolvable traits: vision by light-sensitive "retinas". These retinas can have variable fields-of-view and acuity, mediated by a ray-casting procedure that feeds into their control circuits. However, developing such capabilities' comes with a cost. Retinas require a complex molecule call retinal that is sensitive to light, which itself requires mass and energy to produce from raw material extracted from feeding on plants. The introduction a prerequisite material for developing such a useful trait that has a cost to produce opens up the interesting possibility for predation as an alternative strategy for meeting the requirement.

png

This final screenshot shots an example of the kinds of multi-cell structures that can evolve in this simulator. This is facilitated as the cells have the ability to evolve Cell-adhesion molecules (CAMs) that allow them to bind to other cells and transmit mass, energy, signals, and complex molecules.

png

Next Steps

Developer Set-up

The simulation is written in Java and uses the built-in Java Swing library for the UI. I developed this project using the IntelliJ IDEA IDE, so I recommend doing the same. To get set-up, first clone the repository, open the project in IntelliJ, and run the protoevo.core.Application class build adding an "Application" build configuration. Be sure to include -Xmx16G -Dsun.java2d.opengl=true as program arguments.

png

The dependencies should be handled by Maven. You can check that they are properly configured by looking at the Modules tab in Project Structure window in IntelliJ.

png