Ocean Ecosystem Simulator

Context and inspiration

In the last year of my preparatory school, we all had to make a scientific project that we would present during the exams. The theme was “Ocean” and after having considered some maths and physics subject ideas, I realized I would prefer to make something more visual, like the simulation of an ecosystem under the sea inspired by this video from Sebastian Lague: https://www.youtube.com/watch?v=r_It_X7v-1E. This lead me to learn Unity, because even though I had already learned C++ and SFML during high-school, I felt that I need a more powerful renderer and this was the opportunity to learn to use a game engine. Although it was an original project, I got my teacher approbation and I loved building it. Actually, this experience had an great impact in my choice of pursuing an engineer school that allow me to specialize in video games!

The first iteration of a very realistic modelization of the deep seas!

The main quest: Lotka-Voltera equations

During my school classes, we often heard about the Lotka-Voltera equations that reflect how prey and predator populations evolve over time. Therefore, my first goal with this project was to see those equations emerge by themselves from my simulation. Indeed, when such an equilibrium could be made, I could’ve been confident that I had tweaked my system right enough. With that in mind, I was able to adjust the reproduction rate, the growth of algae, which was the base resource for the fauna, and how  threatening the sharks would be to the fishes. I was so happy the first time I recognized the pattern of the predators and preys’ equations!

A graph of the fish (orange) and shark (blue) population from the simulation that mimics two iterations of the theory

The Lotka-Voltera equations, which reflect the variations of predator and prey populations over time

The twist: genetics and mutations

My teachers insisted that my project should have more than fishes eating each others. I then decided to had some statistics and genes to the animals and allow them to mutate. I made traits for basic characteristics such as health, hunger and reproduction rate, but I realized that I was starting to lack time so I scaled down my expectations focused on only one trait: speed. Soon enough, I could show off that as the simulation would advance, fishes would to evolve to become faster in order to eat the algaes before their peers!

The evolution over time of fish speed (green) and population (orange). There is a first phase which speed stays consistent because there are not enough fish to need any competition and evolution, but after some time, there are so many fishes that natural selection occurs to choose the ones able to eat before the others.