Today I implemented predation into the simulation based on a foodweb.
The simulation now keeps track of who eats who, and then transfers compounds between species each timestep in accordance with that.
Every species now has two new behaviour parameters: Aggression tells them what percentage of the timestep they should spend hunting microbes, instead of gathering clouds. PreyPriorities tell them who to hunt.
During the time spent on hunting, a microbe looks for its prey using the same algorithm for gathering clouds. However, when a microbe finds its prey, instead of ‘gathering’ it, this merely creates an encounter.
During the encounter the faster microbe can choose whether to break off the encounter alltogether, to fight in melee (where both toxins and pilus/engulfment can be used), or to fight at range (where only toxins are used).
Why always the faster one? What about endurance predators? Or ambush predators?
In Nick’s simulation predators can still hunt prey that is faster than them, by running them to exhaustion or accelerating faster than them. I could also imagine a predator that hunts by catching its prey before they can even react properly, sort of like crocodiles. However, in the current game none of these predators exist. Acceleration, endurance and speed all rise in lockstep based on your microbe’s mass and its flagella. Thus the faster microbe will always be able to escape (to safety or to ranged combat) regardless of the scenario.
The fastest microbe will always make the decision that results in it getting the most compounds in the long run. If it chooses to fight, we calculate who wins in combat what fraction of the time.
How do we calculate who wins in combat what fraction of the time?
We give both microbes a survival score. A microbe’s chance of winning = score / (score + opponent’s score).
A microbe can increase his own score with defensive organelles like a better membrane, or lower his opponent’s score with offensive organelles like toxins and pili. Note that with this formula it is better to raise your own score if your chance of winning is under 50%, and better to lower the opponent’s score if your chance of winning is over 50%. In other words: if you’re a helpless prey who gets eaten to much, get defenses. If you’re a deadly predator who wants to kill prey even more efficiently, get weapons.
The exact formula for the score’s I determined mostly by my own experience as a long-time player of the game:
- Toxins: -5 to opponent per prokaryotic toxin, -7 to opponent per eukaryotic toxin.
- Pili: -10 to opponent for the first one, -5 for the second and third. -2 per pilus for any futher. They can also block toxins: +4 for the first pilus, +2 per pilus for any further, only to counteract subtractions from toxins.
- Health: + Health / 10
- Physical Resist: +(Health / 1000) per point of physical resist, only to counteract pili.
- Toxin Resist: +(Health / 1000) per point of toxin resist, only to counteract toxins.
- Engulfment: Counteracts your opponent’s entire health if you’re bigger than him.
When a microbe wins in combat, the compounds of the enemy (both the ammonia and phosphate they contain, and the average amount of compounds they would have gathered by now) are transferred into the winning microbe.
Naturally, we work with averages, so a species gets exactly: fights * (PWin * enemies compounds) - (PLose * Your Compounds). This results in predators stealing the compounds of their prey.
With this set up, I tested whether predation is worth it. In a new patch the answer is a resounding NO. There is so much ammonia, phosphate, and glucose available in clouds. Why would you ever want to fight for it if you could get it for free?
But in a more developed patch it becomes more interesting. For example, let’s say that cyanobacteria have taken over the pangonian coast. All the glucose is long gone and there are so many of them (say, 10,000) that trying to compete for ammonia and phosphate is pointless. What happens if we introduce P. Abyssus (two hexes of cytoplasm) into the patch with…
- Agression = 0. They won’t be predators and try to subsist on clouds. There are no glucose clouds. They starve in the first timestep. Even if there were glucose clouds they only survive for about 5 timesteps and then die due to being unable to compete for ammonia and phosphate.
- Agression = 1. They will spend the entire timestep slaughtering cyanobacteria until their entire glucose need is satisfied. By the around the 6th timestep every cyanobacterium has been killed. P. Abyssus realises it’s made a terrible mistake and starves to death.
- Agression = 0.1. Now we’re talking. I actually bothered to make a graph of this:
As you can see the population reaches an equilibrium with predatory P. Abyssus surviving because they don’t overhunt their prey.
This is great new but also kind of weird. In real life predators hunt until they’re satisfied, not until some evolutionarily acquired instinct tells them to starve themselves for the sake of the ecosystem. What we really need is some way to reduce the amount of prey a predator can hunt that doesn’t depend on the predator behaving nicely.
That’s why I’ll see you in the next update where I’ll be making a very crude version of Nick’s camouflage and detection system.