Here is the link http://www.beyazcuce.com/hunt
I have always wondered if evolution can be simulated or not and decided to try by myself. Even though I truly believe that the evolution does exist and work in the everyday life, seeing soemthing with your own eyes makes you feel it to your bones, just like seeing a planet by a telescope for the first time. You know that it is there, but when you see it with your own eyes, you experience a special moment.
Genetic algorithm is nothing new and it does work. I have used this technique a number of times and each time it was successful. So to simulate life, I knew that I had to use it.
How to simplify
Life is complicated and to truly simulate it would require to simulate all the sub atomic particles. Obviously I had to simplify it. But how simplified it should be? Well what I am looking for is a result which would surprise me as the programmer. I should only set the rules at the beginning and let the nature do the work. To achieve this, I decided to keep it very simple, because if it was suppose to surprise me, a simple environment and a couple of creatures would still be able to provide that. Therefore I chose to add only 3 types of living beings:
- carnivorous (hunters: they will hunt the herbivores)
- Herbivores (preys: they will be the hunt and eat plants)
- Plants (well, just plants)
I knew that every entity should have had their DNA in order to use Genetic Algorithm. I didn’t make a list at the beginning and went with the flow. While programming, all the attributes appeared by themselves anyways. Obviously, hunters will be hunting preys and preys will be eating plants. So the plants should not be mobile but the others should. That self-defined the first DNA attribute, lets call it a
Gene. So if they are mobile, they should have a speed. So the first gene is their speed and it should be between 1-99 (cause why not). And then I have decided on the other attributes that most living beings do share such as when to start running away from a hunter, what is the hunger threshold, sex desire, food storage capacity, when to start searching for food and so on. Every single attribute will define these simple creatures.
- Every creature is created randomly at the beginning, with randomly generated genes. There is a limit for the number of preys and hunters which can exist at the same time for CPU process limitations.
- The plant’s will be created at certain times, but this time range will be random as well to simulate “climate”. So sometimes they will regenerate in 2 seconds but sometimes it will take 100. If it’s 100 seconds, it will be a famine.
- Every creature will want to breed and it needs two individuals to breed. When they breed, they will cross their DNA’s from 2 knobs. The selection of each part will be completely random.
- There are states for each creature
- Gray: Sleep
- Pink: Mating
- Orange: search for food
- Red: run away from a hunter
- Blue: hunting
- Every once in a while there is a mutation in a creature’s DNA completely randomly.
- When a hunter attacks a prey, a turn based fight start in between. Although the power of the attack and the defense are random, they still stay in the range of their gene which defines their strength and defense power. Think this like a mouse attacking a bizon. Even though they are the hunters, mice will have no chance against bizons.
- When they breed, they lose a certain amount of energy
- Each second they age 1 point, I like to think a second in the game as a year.
- When they sleep, they lose half a point of energy, when they are stressed and running away from a hunter, they lose 2 points, when they are roaming to find food, they lose 3.
- When they reach a threshold like hunger or sex desire, they have to act that way. But maslow’s pyramid is applied to the simulation, a hungry hunter will not look for a mate.
- If they store too much food, they get fat and it slows them down
- Linger rate for hunters only, defines the success of choosing a single prey and stick with it in the herd.
- Their color is a representation of their families, therefore you can identify the members of a single “species” easily.
- System regenerates new creatures randomly in order to keep up the population. Think this as new species are coming to the land and get a chance to evolve.
What to expect
I was expecting some behaviour after I set the rules and defined the environmental variables
- At the beginning of the simulation, all creatures will be acting silly and their behaviour will change in time and make more sense for the watcher
- The strong animals will survive better
- The more eye-sight, the better
- The more powerful, the better
After watching it hours, it started to surprise me a lot and to be honest, I learned a lot from this simulation. I know it sounds crazy for the programmer to be surprised by it’s own creation, but I didn’t really invent this nature, I simply created a laboratory to observe the existing nature.
First of all, I realised there are no perfect species. They come and go. Even though there is a perfect hunter, a perfect prey, they all disappear in the end and always new species appear. Lets dig into this a bit. A perfect hunter kills everything around it and eventually starves because there is nothing left to eat. So it is not always a good thing to be a perfect hunter. This made me think about human race, we are very good at many things and no other species can compete with us. But if we are not careful about the resources, we will end ourselves just like the perfect hunters.
On the other hand the perfect prey disappears after a while as well because no hunter is capable of killing them, as long as they are around, the hunters don’t get the chance to evolve enough to get strong and the new randomly created hunters are inepts. That leads them to get better and better at standing by and not wasting any energy, wait for the food to appear and as soon as they appear, they attack and get everything. Also they tend to store as much as possible. But once there is famine, they all die at once and disappear from the face of the earth. This also tells a lot about nature, whatever we do, we are depending on the nature and it is unreliable. If a single variable changes like the global warming, no matter how skillful we are, there is nothing to save us.
While preys are feeding, if there is a hunter nearby, they don’t get close to there (you can see a red stroke around the prey when this mod is on). Some of them has lower “fear” thresholds so they don’t really care, you can think this as badgers walking around lions. Being too shy is not always a good thing because they can starve because of the hunters near to the plants. This reminds me the antelopes going near to the water knowing there is a corcodile in it.
It is possible to get surprised by the nature even with a simple simulation. I enjoyed watching it for hours and witnessed many interesting unexpected behaviour. I hope you enjoy it as well.