I created a basic “eat/mate/die” simulation in Processing. Creatures wander around the screen looking for food. When they are no longer hungry they begin a mating dance by slowly circling the center of the screen. If they are able to crash into each with sufficient velocity they will mate and reproduce. Eventually the creatures die of old age, or starvation, and become food for the surviving creatures to eat.
[vimeo https://vimeo.com/77563252 w=640]
The movement of the creatures is governed by steering behaviors that I picked up while reading The Nature of Code. Each creatures is pushed and pulled by four internal forces:
- Hunger pushes creatures toward food.
- Mating pushes creatures into a circular pattern and is inversely proportional to the hunger force.
- Separation pushes creature away from each other to prevent overlapping. Separation can be overcome by a strong mating force.
- Wander pushes creatures to explore the world.
Each creature has a unique name, selected randomly from the Social Security Administration’s list of top 1000 baby names from 1880.
The user is able to zoom in on and follow individual creatures with the space bar. While following a critter you can zoom further in or out using the mouse wheel, select other creatures to follow with j or k, and gently steer using the arrow keys. i reveals all the creature names and statuses, and p pauses or resumes the animation.
You can play with it here: http://openprocessing.org/sketch/116939
And download the code here: https://github.com/antiboredom/creatures