I’ve always been interested in mimicing organic systems in Flash, and tolerance based behaviours in particular. When I built out my ProximityManager class, the first thing I thought of building with it was a simple aquatic ecosystem, here’s my first attempt….
This eco-system is only 6kb in size (well, 27kb with the sprites and background image) but manages to acheive some fairly complex, organic behaviours as a result of using a tolerance methodology. It contains 3 different organisms, each with their own set of tolerances and behaviours:
Food:
These little white sprites don’t really do much except drift in the tide. They only exists in the upper region of the ecosystem, and are the energy source all other organisms rely on (directly or indirectly). Over time, they lose energy and shrink until they die and are removed from the system. Larger, more energy rich Food drifts at higher depths, which rewards more aggressive Prey organisms.
Prey:
These orange sprites are the most complex organism in the system. They survive by eating the Food near the surface, but predatorial pressure forces them to return to the depths when they aren’t hungry. As their energy levels drop, they shrink in size until they die and are removed from the system. When hungry, they will move to the surface and pursue any Food within their range.
They have a number of tolerances that govern their behaviour, including a depth preference, a tolerance for hunger and a tolerance for “fear”. Their speed also varies – higher speed improves their ability to chase food and escape enemies, but also increases the rate at which they burn energy.
When their energy needs are satisfied, they may move to the surface to try to reproduce asexually – if successful, they will create a single child which shares most of their traits, mutated slightly. In this manner, a form of evolution occurs in the system over time (you may notice that the Prey get faster and more skittish if you let it run for awhile).
When scared by being chased, or merely by the presence of a Predator (larger predators are more frightening), they will beat a hasty retreat to the depths. They are less aware of Predators while chasing a Food sprite, and are oblivious to threats while reproducing.
Predator:
The large “jelly fish” sprites are Predators. They drift into the system randomly, and there can be up to 3 predators in the system at a time. Predators swim slowly and aimlessly, until they become hungry or a Prey organism catches their attention. Like Prey, different Predators have different tolerances for hunger, and different speeds. As their energy decreases, they will shrink until they die and are removed from the system.
When hungry, Predators will search for Prey, and then rush at them quickly in an attempt to eat them. While attacking, Predators will constantly look for a bigger, closer meal to chase. Predators are sensitive to pressure however, and cannot follow Prey below their individual depth tolerance. When a Predator catches a Prey organism, its energy is added to the Predators and the Prey is removed from the system.
The ecosystem does a pretty good job of maintaining balance. Prey population is controlled by predation and Food availability. Predators are limited by Prey population. I have seen the system die when 2 or 3 fast predators over-hunt the Prey, but hey, that happens in real life too.
I’ll probably tweak the numbers further, and add some more behaviours in the future, but I thought this was a decent first try.
Cheers.
Vrr nice; I wish I could put this as the background of my 2nd monitor; for now, it’s a nice browser window shrunk to fit on my desktop. Nice job, mangxt!
It looks so pretty!
Nice work Grant, wish I had more time to do stuff like that 😉 Reminds me of that shark simulation thing Sam Wan did a couple of years back, very cool simulation stuff.
Very cool … It might be nice to be able to toggle the background on and off so you can see the interaction a bit better.
once again.. you’re a madman..
Nice work Grant!
(you should add a pollution “layer”.. a kind of a predator that effects both the prey and their food source..)
Cool work, I like the jelly fish most… I´m looking forward for mutants ;-)… I had a project a few terms ago at university … not in flash, but evolution rocks anyway =)http://bitlife.pl-visions.com
Awesome! I always wished and still hope i would do something like this..
It makes me crazy, great stuff Grant
If you leave it up long enough, they all die.. but really really cool!
Your are a master Grant! Congrats, it’s really beauty to hang watching : )
Simply amazing.
All very interesting stuff.. Looking forward to the talk on the 19th.
I love this, Its very nice
Terrific !
Why not adding others elements such as Human, Sharks…? 😉
One of the coolest things I have seen in Flash, I often look up the Proximity Management post just to find this page 😉
Really inspiring to see simple code turn into evolution.