Download
Ecology is a simulation of Genetic Programming applied to free-wheelin' agents, called critters. Click here to download the latest version.
Note: Several of the descriptions here are obsolete and incomplete. I haven't developed the code for several years and this document is even older, so things have changed.
![]()
Here's an example of critters moving around in their world. The green blobs are food, the red circle and the green triangle are both critters, male and female, respectively. The lines that shoot out of their "fronts" are the visualisation of their sensors.
Evolution
The critters goal in life are to pro-create. Well, actually, it's not a goal at all. It's just that the ones that aren't any good at pro-creating, they tend to die. The one's that are good at it, they flourish and get more numerous. Until someone who's better comes along.
Evolution starts out with a simple program that I've designed (a lá Tom Ray's Tierra) , a program that survives but does hardly anything fancy. Now, technically, this is cheating. But waiting a week for a random creature to finally appear, a critter that actually survives to mate... that is an experiement that will have to wait.
The program of the orignial individual looks like this;
(prog5
(initialize
(prog2
(use-attack-sensor
(set-sensor-base-dir 0))
(use-sensor-1
(set-sensor-base-dir -0,1))
)
)
(prog2
(set-want-to-mate (> my-health 0,9))
(set-frequency-of-thought 0,2))
(use-attack-sensor
(if-close-to sensor-color food-color
(prog2
(set-speed 0,3)
(set-delta-direction sensor-off-center))
(set-speed 0,5)
)
)
(if-positive can-eat
(set-speed 0,001)
(set-delta-direction sine-wave-3)
)
(use-sensor-1
(if-close-to sensor-color wall-color
(prog2
(set-delta-direction 1)
(set-speed 0,1)
)
0)
)
)
![]()
This picture shows two critters feeding, they both have their shields up while eating. Perhaps a way of staying safe when your standing still?
Mating
The system don't explicitly reward good critters. Critters that are successfull at eating can store energy. Critters with the required amount of energy can choose to mate with another critter. They do have tools so that they can choose partners, but initially, they just... go for it. Their offspring, especially in the early generations, often tend to fail miserably. Wander into walls, go in infinite loops. Or just hang out. These die off. But after a few generations, the evolution of evolvability provide critters that crossbreed better. That are less prone to braking. This is when evolution really kicks in.
Sensors
Critters have very limited sensors. I've tried to leave the world that the critters live in as simple and open-ended as I possibly could. Open-ended means that evolution could, theoretically, take off in unimagined directions. Their sensors, for instance, are a extremely simple form of retina (inspired by Craig Reynolds work). They all have three sensors, or slits, that they can see through. Through the sensor they can percieve distance, color and the center of the object they have in view. The object, currently, can be any of four things
- Other critters
- A wall
- A food-pellet
- Nothing (there's nothing within range for the sensor)
Critters make most of their descitions based upon these simple pieces of information. There are other pieces of information that they can use, for instance, whether the critter they're currently aiming their weapon at (they have a simple form of attack/defence system) is a close relative (parent/child/sibling) or not, as killing siblings for food is genetically speaking a terrible idea.
![]()
Here's a critter that has split it's two eyes so that it can survey a larger area looking for food and avoiding collissions. The rays pointing out of the eyes indicate that the eyes are seeing something, in this case, a couple of walls.
The relatively dark red color indicates that the energy level is low. A strong green color indicates that the individual has lots of energy.
Day to day business
Critters tend to move, eat, attack and mate most of the time throughout their lives. Eating is an automatic process, if a critter finds itself on top of a food pellet, it will automaticall eat. This is the one automatic actions critters take. When a critter wants to mate, for instance, it must express a wish to do so. If there's another eligable critter within range, of the opposite sex, then mating will ensure and offspring will appear. It's not uncommon for critters to kill their partner, right after having mated with it. This would, generally speaking, be considered bad manners, but technically, the mother/father just wants more offspring. The life of the partner is not interesting at all once the children are born.
![]()
The big green circle is a food pellet, that's being surrounded and consumed by a number of critters. One has spawned a child, that's visible as a small brown circle.
War of the sexes
I've had to resort to forcing males to pay for half of the child, because before I did this, males kept taking advantage of females. Evil bastards, heh? This may change back to the way it used to be - since critters can tell the difference between a male and a female, males that don't pay for mating would perceivably spend all their energy trying to wipe out the competition. Killing females for food could turn out to be suboptimal. As it stands, they all try to kill one another for food. The goal is to forever tweak the settings so that setting is right for complex strategies to evolve.
Energy
The world that the critters live in has a set energy level. As critters eat, energy shifts from food-pellets to the bellies of critters. When a critter dies, some of that energy is returned to the world in the form of a new food pellet. Energy is also lost when critters move, think and act. Yes, thinking incurs an energy cost on critters. This limits them to few thoughts, infrequently. A critter can set the frequency it would like to think at, and alter this frequency throughout it's life. Setting it's frequency to 20% (20%? what kind of frequency is that!?) means that it's a 20% chance that it will think the next frame to come up. Of course, when a creature doesn't think the system does't have to update it's sensors or execute it's code, which saves precious clock-cycles, enabling us to have even more critters to the world.
Also, we only charge for the number of instructions a critter executes, a large program doesn't necessarily mean that the critter thinks a lot. Most of that code might be in optional branches, that never get executed. For instance, half of the program may be in a brach that only gets executed when there's a wall in view.
Networking evolution
NOTE - the networking code isn't currently working properly, as I'd have to rewrite large portions of it to get it to work. I currently have no plans on doing that, but if you think I really ought to, let me know.
Evolution is notoriously slow, so slow in fact that hardly anything happens. Therefore, I decided to harness the power of the internet to ship critters around, so they can evolve on several computers simultaneously! That means, that the critters that appear on your screen can have evolved on someoneelses computer. Or more likely, they have been evolved on many many different computers before they arrive in your computer. Every once in a while, one of your critters will leave your computer and arrive at our server, waiting for a new computer to move to.This is called "the island model". Populations are conceptually isolated on islands, and boats infrequently ferry individuals across from one island to another.
