/ PROGRAMMING

Life 2.0 (Simulation)

Since learning how to program, I’ve always thought that it would be fun to make a nature simulation.

While making another ‘Game of Life’ was possible, I wanted to make something a little more interesting, with predators and prey. I was reminded of this idea after finding this blog post from Ben Katz, one of the MIT students who worked on MIT mini cheetah, which was basically exactly what I wanted to make!

The game is really simple. There are prey cells, that try to survive by evading the predators cells, and there are predators cells, that try to eat the prey. If a predator cell is unable to eat a prey cell within a certain amount of time, it starves. Thus, predator cells are always patrolling the area looking for prey In contrast, if they don’t see a predator, the prey will stay put.

Both predators and prey have a sight radius and movement speed, configurable before the start of the game. To make this more interesting, however, both predators and prey can reproduce asexually after some time, with offspring whose characteristics are slightly better or worse than their parent’s. Thus, if the simulation is able to run for long enough, there should be evidence of natural selection.

I also added (and want to add more) analytics tools. Currently, the simulation outputs data to data_output.py for post-analysis. When you are running the simulation, you can also run plotter.py to for a graph of prey and predator populations vs time. Later, I want to add another graph to see average predator and prey characteristics to get a sense of the level of natural selection ongoing.

You can find all the code here!

Upgrades and Improvements

  • The simulation seriously slows down when there are too many characters to draw. This is slightly annoying and I don’t know if it can be fixed (intensive graphics will always take long)
  • I think that there is an error in my simulation currently… graphs of the population don’t follow the Lotka-Volterra Predator-Prey model, which describes a very characteristic set of graphs… which my simulation doesn’t produce. I’ll keep working on this project to see if I can fix this
  • I really want to add more analytics tools to see the natural selection! In Ben Katz’s version, he included different types of prey, with different starting characteristics. I think that this would be a good idea to add.

So far, I’m having lots of fun working on this project! It’s allowing me to regain some python skills (everything is in python) and is less stressful than working on my big quadruped project… AKA: this is the project I work on at school when I’m free. Hopefully you’ll enjoy it too!


I’m not sure whether I’m actually going to pursue this project since I have some ideas for other small projects that may be more fun. If I get around to it, I’ll definitely work on this more… and if you’d like the work on it, please contribute!