Representing Natural Systems In Code

This project explored object oriented programming by means of creating a simulation inspired by natural systems.

Time: FALL 2021 // Creative Technology

Role: Creative Coder

Tools: P5.JS

Final Project:  HERE


Create a sketch that would simulate an existing natural system - look at physics, biology, and other natural sciences for good examples. Start with the environment - where is the system situated? What are the forces the environment might exert on the system? Examine the agents in the system, their relationships to each other and the environment they are in. The look at how this system would develop over time. What are the rules that you are going to come up with, what are the parameters you are going to feed into them and what effect will the changes have on the development of the system.


My initial idea was a bit ambitious for the timeframe. I wanted to have a system of hedgehogs and badgers. The badgers would hunt the hedghogs and the hedghogs would hunt plants that would grow at random intervals. I started by diagramming my thought process:

I decided that my main variable to track would be hunger. Hedgehogs would start with an initial "stamina" and as time goes on and they move around, their stamina will go down. if they come across a plant, it will increase their stamina. If their stamina reaches 0, then they will die and be popped out of the array.

For my initial tests, I worked to get a handful of objects that would be attracted to pixels on the screen. I explored distance functions and simulating steering behaviors based off of Craig Reynold's paper on steering behaviors. After setting this up, I decided that if their stamina reached a certain point, they would reproduce by adding a new "hedgehog" to the array and this will also reset their stamina to an initial position. I was satisfied with this result:

Along the way, I also stumbled upon some other happy accidents that can be explored HERE


This project was successful in that I managed to create a working natural system using p5.js, however, I spent a bit too much time styling at the cost of not having time to integrate my original badger feature.

Instructor: Maxim Safioulline