Nick's Auto-Evo Algorithm (Episode 1)

FOREWORD
After some thought and discussions on Discord, I’ve realized that this next part is actually mostly unnecessary. However, it’s worth discussing the parts of it that matter, so get ready for probably the shortest part of this series.

Part 4: Demography

As you can see, within just a few parts we’ve already quite rapidly created a rudimentary auto-evo algorithm, with traits like swimming speed, base metabolism, and mating frequency factoring into the survivability of species. I really like the approach we are taking because it feels like we are building the framework of the algorithm, and then filling in the details later. We will soon be ready to start introducing other species into the mix, but before we can do that there are two quick topics we must cover in their own parts.

The first is this part, on habitats and demography. How does where the species live affect its likelihood of interactions with other species? We have already factored in density, but there’s also other factors of the distribution of species in nature such as preferred habitats, habitat overlap, clustering, etc.

We will revisit other aspects of habitats again in the future, such as migrations, environmental conditions, territoriality, etc. For now though, we must simply consider where in the patch Modelus Specius is likely to live and how that affects its interactions with other actors in the patch.

We will be breaking down the following 2 assumptions from our list:
  • Modelus Specius is a flat, tiny, simple, jelly-like organism that lives at the bottom of the ocean.
  • Members of the species can instantly perceive food regardless of distance (Perception)
  • Members of the species can completely consume the food and gain 100% of the energy. (Hunting/Metabolism)
  • The species is equally distributed/dispersed across the world (Demographics)
  • The planet is one giant ocean of equal pressure water that is equally accessible to the player (Geography/Terrain)
  • Modelus Specius is the only species on the planet (Ecology)
  • Members can reproduce as many times as they want, instantly, with no pregnancy/gestation period. (Reproduction)
  • The species reproduces via asexual reproduction, spawning fully developed offspring that can themselves immediately begin reproducing. (Mating)
  • The species does not change in physiology as they age (Aging/Ontogeny)
  • The species is fully aquatic (Terrestriality)
  • Members of the species are solitary and do not cooperate with other species members in any way. (Cooperation/Sociality)
  • The species has no parental instincts, and will immediately abandon offspring (Parenting)
  • The species is perfectly adapted to its environment and suffers no death or disease from environmental conditions (Environment)

Questions to Consider

When addressing these two assumptions, there are a few questions that are raised:

  • What would a species’ habitat look like? Can it be assumed that a species occupies the whole patch? Or only parts of the patch?
  • If they only occupy parts of the patch, how do we calculate overlap?
  • Is the species evenly distributed across the entire habitat they occupy? Or are they clustered?
  • Are there inaccessible zones of the patch? (Physical barriers, isolated bodies of water, pressure differences, other physiochemical differences)

Habitats

What would a species’ habitat look like? Can it be assumed that a species occupies the whole patch? Or only parts of the patch?

From the definition of a patch, we are going to assume that all species in a patch occupy all parts of that patch. Habitats thus will not be defined by what parts inside of a patch are occupied by the species, but rather which specific patches are occupied in the first place. For example, consider the following diagram:

A species of camels would have their habitat defined by the 8 Desert patches that they occupy. However, within those patches the camels would be assumed to live in the entire area/space. This concept will be explored more in Episode 2.

Patches will tend to be smaller and represent a piece of land or ocean or sky that has very similar living conditions all across, so this is a fair assumption to make.

Overlap

If they only occupy parts of the patch, how do we calculate overlap?

This question is irrelevant because of the answer to the first question. Since we are not assigning specific habitats inside of a patch, overlap is unnecessary because all species in a patch will ALWAYS overlap. Therefore overlap will be more in regards to whether 2 species live in the same patch, and how many patches they live together in. This is something to revisit in Episode 2.

Clustering

Is the species evenly distributed across the entire habitat they occupy? Or are they clustered?

Here is an interesting point to consider. It might be difficult to imagine how clustering would affect demographics, so here’s a diagram to help illustrate the point.

image

Imagine a scenario with multiple species that fill up the entire patch, aka a case of high spatial density (remember that population density was renamed to spatial density). With even distribution, as seen on the left side, the average distance between any one species and the nearest member of another species is quite short, something we explored in part 3. When distribution is even, this is equivalent to minimal clustering (or a clustering value of 0).

When clustering is maximized (a clustering value of 1.0), all species are lumped into big groups. Notice how suddenly the average distance between any species member and a member from another species becomes much longer. For example the orange species members are now much further from the red species members.

So imagine you are a predator. Increased spatial density of your species and the prey species is a BENEFIT because it makes it more likely for a prey to be very nearby to you. Therefore, increased clustering diminishes the benefit of spatial density by grouping members of a species together, instead of allowing them to be mixed in. Another way of thinking about it: Increased density decreases the average distance to a prey, and increased clustering decreases the effect of density, therefore increased clustering increases the average distance to a prey.

On the flip side, when spatial density is low, clustering doesn’t really matter because there are fewer individuals (think of just 1 predator and 1 prey, clustering is irrelevant in such a case because there is no one to cluster with).

So this is the current equation for calculating the average distance between a predator and its prey, factoring in the spatial density of both species:

Distance per Hunt = (0.66 * Patch Length) * (1 - (4 * Predator Population Density * Prey Population Density)) - Predator Body Radius - Prey Body Radius

Now we’ll add in a term that diminishes the density term. First we calculating the Average Clustering between the two species, and then factor that into the overall equation:

Average Clustering = (Predator Clustering + Prey Clustering) / 2
Distance per Hunt = (0.66 * Patch Length) * (1 - (4 * Predator Population Density * Prey Population Density * (1 - Average Clustering))) - Predator Body Radius - Prey Body Radius

With the above equation, when density is high then high clustering can reduce its effect, but when density is low the level of clustering is irrelevant. Clustering can never actually make the average distance to a prey increase more than it normally would be, it can only reduce density’s effect of making it shorter.

NOTE: Clustering will be defined as a species trait. Why would a species ever evolve clustering? If you are a prey to many species, it will make it less likely for you to be found by predators since you can hide all your species members in a corner. Also, clustering will be necessary for cooperative social behaviours that we’ll introduce in a future part.

Inaccessible Zones

Are there inaccessible zones of the patch? (Physical barriers, isolated bodies of water, pressure differences, other physiochemical differences)

To this I would again say no due to the definition of a patch. A patch is defined as a contiguous space with common physicochemical features, so if there was a barrier that would define a separate patch. Thus we don’t need to consider this.

Filling up the Oceans

Finally, before we can close, there’s one more point to consider. The algorithm actually currently has no limit on the number of organisms that can exist in the patch. Modelus Specius could theoretically have millions of offspring and fill the oceans of the world multiple times over (if there was enough food). We should introduce a limitation in terms of physical space to prevent this from ever occurring.

We will do this by limiting births. If the number of births is ever going to produce more offspring than can physically fit in the patch, we will just limit it to what can physically fit. I’ll skip showing the math behind this because I think it makes sense already, but if someone wants to see the equations for it let me know.

Demos

There will be no demos this part, since the changes were so minor and barely visible in the results. I did notice though that increasing clustering did lead to either more time spent hunting, or lower overall populations for Modelus Specius because of less free time to reproduce.

As compensation for this less eventful part, the next part will be coming out pretty soon!


Summary

New Performance Stats
None

New Traits
Clustering

Topics for Discussion
All comments and feedback are welcome!

I realized I made a mistake with the corrected diagram at the top of this post. It should actually look like this:

In the updated algorithm, the first thing that happens is that the script determines what fraction of the population dies from starvation and kills them off first. Then of the remaining population, it determines how many offspring were birthed. Before it adds the births, it also kills off any of the population members who die from old age. Therefore births and old age deaths occur sort of in parallel.

Anyways, just wanted to make that clear and I’ll go back and fix the original post later. The next part will be coming up soon! Feel free to leave any suggestions or feedback you have on the series so far.

1 Like

Part 5: Hydrodynamics and Swimming

Yes we have a stat for movement speed now, but it’s a generic stat that is not tied to the organism’s body or the environment in any way. In this part we will look at the hydrodynamics of swimming and how to make movement speed realistically determined. There are no specific assumptions from our list that we are breaking down, instead we are just adding detail to the movement calculations from Part 3. Let’s find out how to make a creature’s swimming speed depend on its size, shape, and surroundings.

Undulation

Modelus Specius is a simple, spherical creature comprised of simple tissue. We’ll assume that this simple tissue has basic abilities to perform various tasks, such as in this case contracting to act like a muscle. We’ll classify Modelus Specius as using the type of swimming referred to as undulation, meaning it flexes the sides of its spherical body back and forth to propel itself forward. Thus we’ll say only the tissue on the sides of its body are contributing their force towards the swimming motion.

It’s hard to imagine how a solid sphere would use undulation, so imagine it as similar to the motion used by jellyfish (except that there is no hollow cavity or tentacles in the bottom).

Online, it says that the fastest recorded speed of a jellyfish is 8 kph. Dividing by ten I think gives us a more realistic top speed for small and simple jellies that are similar to Modelus Specius, so a top speed of 0.8 kph or 0.2 m/s. Now, for the next step, let’s take a look at Forces.

Force

Force is a simple concept in physics. It’s basically an interaction or energy that changes the motion of an object. When an object experiences a net force in a direction, it accelerates in that direction. When an object experiences no net forces in a direction, it maintains its motion in that direction (which could be maintaining its current speed without decelerating, or it could be being completely motionless). Keep in mind that accelerating in one direction (such as backwards) is the same as decelerating in the opposite direction (forwards). Why “net” force by the way? Because you can have multiple forces that act in opposing directions, but the ones that are greater will determine how the object’s motion changes.

For Modelus Specius’ swimming, we will consider its motion as an interplay of two forces: The “thrust” or “swim” force that the organism produces to propel itself forwards, and the drag force of water pushing back against it as it swims. We can visually display these using a diagram common in physics, a free-body diagram

image

Drag Force

At top speed, the swim force and the drag force will perfectly balance each other out, resulting in top speed being achieved and no more forward acceleration. Why is this the case? Because when you first start swimming, your Swim Force greatly outweighs your Drag Force. However, Drag Force increases with your speed, so as you speed up your Drag Force increased but your Swim Force stays the same. Eventually your Drag Forces reaches the value of your Swim Force, and that’s when you hit top speed and stop accelerating.

We already know the top speed of the Modelus Specius, which we’ve estimated at 0.2 m/s. But what if the ocean’s temperature changed and made water more resistant to swimming (higher drag)? What if Modelus Specius’ size got larger and less hydrodynamically shaped? Since drag force can vary so much, we should use our estimate of 0.2 m/s top speed to find the actual Swim Force produced by the jellyfish.

To find the Swim Force, we will find the Drag Force and know that by definition the Swim Force has to be the same value. Drag Force can be calculated using the following equation:

image
Let’s break this equation down variable by variable to see how drag will be calculated in Thrive.

Relative Flow Velocity

This refers to the difference of velocity (remember that velocity is just a physics term for speed with a direction) between the fluid and the object.

If the fluid flows in the opposite direction to the organism’s motion, then you add the velocities to find the relative velocity. If flowing in the same direction like the 2nd panel, you subtract them (if you and the water are both moving the same way, it feels like you’re not moving). If the water is motionless, you only consider the velocity of the organism. Okay, simple enough, but this brings us to a dilemma.


The Dilemma

Now obviously ocean currents are a very real phenomenon that play a big role in life, but I simply cannot imagine how to make an algorithm that takes into account the role of water currents, especially when most of the values being used are averages. Water currents flow in different directions at different speeds all over the ocean. Do we just take an average direction and average speed for the entire patch’s water current?

Okay, say we do that, how do we factor that into the algorithm? Do we apply that to the speed of the organism when he is hunting? How do we know when the water current is flowing in the same direction as the movement? In the opposite direction? How do we know when it’s flowing at a 30 degree angle from the organism’s motion. We could theoretically get an “average direction” for all hunts, but how would that be calculated? We’d have to get an average position for the predator population, and an average position for the prey population. And keeping track of the positions of objects in the patch opens a WHOLE new can of worms…


There are two possible solutions I see to this problem:

  1. Completely ignore ocean currents and always assume the fluid’s velocity is 0.
  2. Completely ignore ocean currents within a patch, but consider ocean currents between patches.

Ignoring Ocean Currents

This is a simple solution that makes it so that we always only consider the velocity of the organism.

Ocean Currents Between Patches

In this scenario, you do the same as in the first solution, but instead you track ocean currents between patches. This means that ocean currents can affect things like migrations between patches, or even moving to another patch to hunt (if that is intended to be possible), but not any interactions within a patch. I feel like this solution doesn’t sacrifice too much realism since ocean currents play a more important role on the larger scale (between patches) than the smaller scale (within patches).

For our purposes, we will proceed using the 2nd solution, which means the relative fluid velocity is equal to the velocity of the organism, which is 0.2 m/s. This gives us so far:

Drag Force = 0.2^2

Density of the Fluid

Next we must consider the density of the ocean. The density of ocean water on the surface is 1027 kg/m^3. As you go deeper, the density of seawater increases. However, it increases at different rates depending on what latitude you are at. Seawater at latitudes of around 30-40 degrees south (a region called the Pycnocline) follow this pattern:

Modelus Specius lives at the bottom of the ocean, so let’s say the depth of the patch is 4000m. Assuming similar conditions to Earth at 30-40 degrees south, this gives us a density of 1028 kg/m^3. This means drag force is now:

Drag Force = 1028 * 0.2^2

We can simplify this and divide it by 2 (to get rid of the fraction in the formula) to get:

Drag Force = 20.56

Reference Area

When you swim into a certain direction, even though you are a 3D shape you are presenting a 2D profile or “silhouette” to the water. This “side” or “face” depends on which side you swim with, aka where is your front. Since Modelus Specius is a sphere, the frontal surface area is just a circle. In fact for a sphere any direction you look at it its 2D profile is just an equally shaped circle. Using the radius of Modelus Specius which we earlier defined as 0.5 cm, that gives us a circle area of 0.000079‬ m^2. This gives us:

Drag Force = 20.56 * 0.000079<U+202C> = 0.0016

Drag Coefficient

The drag coefficient is a value that takes into account the shape and texture of the object for how much drag it experiences. Many tests have already been done to find the Drag Coefficients for many reference shapes:

The Organism Editor will look at any species and assign the nearest approximation of drag coefficient based on what shape the front-side is closest to. Evolutions to skin (like hydrodynamically shaped scales) can increase or reduce the drag coefficient. Since Modelus Specius is a solid sphere, we’ll use the drag coefficient of 0.47.

Drag Force = 0.0016 * 0.47 = 0.00076

And that’s it! Our Drag Force is 0.00076 Newtons (the unit for force, also shortened to N). This means Modelus Specius must generate 0.00076 N of Swim Force.

Swim Force

When a muscle flexes, it produces a certain amount of force based off of the cross-sectional area of the muscle. Therefore if you know the area of the muscle, and since we know the force produced per area, you know the force the whole area can produce. Well for Modelus Specius it’s backwards, since we know the total force it can produce, and the total area involved in undulation, we can work backwards to find the force produced per area.

An example of cross-sectional area of human muscles.

A total of 0.00076N of force is being produced to swim when at top speed. The cross-sectional area of Modelus Specius is 0.000079‬ m^2. However, for realism’s purposes I would say that perhaps only 50% of the cells in the sphere are flexing and unflexing to produce the swimming motion, so that means half of that area so 0.000039 m^2. This gives a force per area of 19.5 N/m^2. Human muscle has a force per area of 350000 N/m^2. Yes, a lot more, but humans have also had millions of years to evolve their muscles to become incredibly efficient, whereas Modelus Specius is a very primitive species with very simple muscle fiber cells.

Updating the Algorithm

So now we have some values that we can put into the algorithm. Muscle Area (the area of cells involved in undulation), and Muscle Strength (the Newtons produced per area of the muscle). An organism uses these to produce Swim Force. Swim Force is then compared to the Drag Force caused by the environment, and the result determines the top speed of the organism.

One assumption this is making is that the organism will accelerate so quickly to its top speed that we can just use the top speed for its hunting speed, and ignore the time spent accelerating. For now we will have to make this assumption for simplicity’s sake, but in the future we can revisit this to try to flesh it out.

Demo

Running the updated algorithm gives us results very similar to Parts 4 and 3:

Starting Conditions
  • Simulation Time = 24 months
  • Modelus Specius
    • Starting Population = 100
    • Available Reproducers = 1.0
    • Mating Frequency = 1/month
    • Litter Size = 1
    • Lifespan = 3 months
    • Base Metabolism = 300 calories/month
    • Clustering = 0
    • Locomotion = Undulation
      • Muscle Area = 0.000039 m^2
      • Muscle Strength = 19.5 N/m^2
      • Drag Coefficient = 0.47
      • Frontal Surface Area = 0.000079 m^2
      • Swim Speed = 20cm/s (Derived from above above traits)
    • Body Radius = 0.5cm
    • Body Volume = 0.52cm^3
  • Food
    Starting Amount = 50000
    Energy Yield = 1 calories
    Regeneration Rate = 50000/month
    Body Radius = 5cm
    Body Volume = 523.6cm^3

The population stabilizes around 277. The reason not much changed is that many of the changes we’ve made were under the hood, supporting more advanced interactions with other species and the environment in future parts. For example, we can now make environmental changes to the density of the oceans, or evolutionary changes to Modelus Specius’ body, and it will change the speed of its swimming. Something that did change though is that the speed of Modelus Specius is now around 20cm/s instead of 1cm/s, which has reduced the time they spend hunting every month to even less (0.22%).

Glad to be done with this pretty technical and not very rewarding part. Next time, we will finally, finally add in the main ingredient of evolution that we all love… Other species!


Summary

New Performance Stats
None

New Traits
Locomotion Type
Muscle Area (Swimming)
Muscle Strength (Swimming)
Coefficient of Drag
Frontal Surface Area

Topics for Discussion

  • How do we model ocean currents?
4 Likes

FOREWORD:

The addition of new species warranted some big changes to the algorithm’s code. Not only does Auto-Evo now have to loop through several species to run calculations every month, it also introduces new “race” mechanics to see who gets food first. These new features were much more complicated than I originally anticipated, and I basically learned the hard way why it’s so important to organize your code. I had to do an overhaul of the code to make it cleaner and more organized to add in the new features. I also had to greatly increase how much data was being displayed in the final reports to make them show a lot more information and use them for bugfixing. This way we can see much more detail into what is happening month by month and use it to debug the algorithm whenever I make a mistake (which I made a lot of when implementing these new features). There may have to be a part or two after this for bugfixing of the script if I catch any more. Anyways, all the major bugs have hopefully been ironed out, so time to showcase the next part!

Part 6: Competition

So far in the series, we’ve created a single species that eats, swims, reproduces, and inhabits certain parts of the patch based off density and clustering. But that’s not how evolution works, with just a single species. Evolution pits multiple species against each other! I think it’s time to start adding in some competition!

In this part we will be removing the following assumption from our list of assumptions:
  • Modelus Specius is a flat, tiny, simple, jelly-like organism that lives at the bottom of the ocean.
  • Members of the species can instantly perceive food regardless of distance (Perception)
  • Members of the species can completely consume the food and gain 100% of the energy. (Hunting/Metabolism)
  • Modelus Specius is the only species on the planet (Ecology)
  • Members can reproduce as many times as they want, instantly, with no pregnancy/gestation period. (Reproduction)
  • The species reproduces via asexual reproduction, spawning fully developed offspring that can themselves immediately begin reproducing. (Mating)
  • The species does not change in physiology as they age (Aging/Ontogeny)
  • The species is fully aquatic (Terrestriality)
  • Members of the species are solitary and do not cooperate with other species members in any way. (Cooperation/Sociality)
  • The species has no parental instincts, and will immediately abandon offspring (Parenting)
  • The species is perfectly adapted to its environment and suffers no death or disease from environmental conditions (Environment)

We will start by adding one additional species to the environment. This species will have the exact same stats as Modelus Specius and feed on the same floating clouds of glucose. At the moment this is effectively equivalent to doubling the starting population of Modelus Specius, since they are both evenly matched. However instead of reaching an equilibrium with all of the population being in Modelus Specius, it will evenly split between the two species. After updating the algorithm, we’ll differ the stats of Species B to see if the environment reaches an equilibrium between the two species.

Then, once we have ironed out all the features of having two unique species in the environment, we will add two more species, and they will be given unique stats as well. Our goal is to create a simple environment of different species, that will serve as the foundation for the work we do in the future parts.

Also before we start, I tweaked some of the numbers of Modelus Specius to produce some more realistic outcomes for some of the statistics. Now the fraction spent hunting every month usually comes out closer to 30% of the month rather than 0.7%.

Summary of the changes
  • Mating frequency was reduced by 50%
  • Lifespan was increased to 12 months
  • Base Metabolism was increased to 100 calories a day
  • Muscle Strength reduced to 2.5N/m^2 (making the typical speed 7cm/s)

New Definitions

One more thing before we start the algorithm, it’s important to clarify the meaning of some terms I’ve been throwing around lately. I’ll add all of these entries to the glossary:

  1. Generation: A generation refers to a “turn” in the game. For example, when you start the game you are playing on the first generation of your species. After reproducing, entering the editor, and a timestep passing, you resume play in the 2nd generation. Technically, yes, you could say that there’s thousands of generations that would’ve occurred in the thousands of years that passed during the timestep, but for the game’s purposes we call the time after each editor session a new “generation”.
  2. Timestep: The time between generations is called the timestep. When a player enters the editor, does his stuff, and then returns to the game, the game fast forwards thousands or millions of years to represent the evolution that took place. That’s called a timestep. Every time the player reproduces and enters the editor, another timestep passes. Timestep just refers to the time that passed.
  3. Simulation Step: This simply refers to the unit of time for simulation for the population algorithm. At the moment, this is one month. This means that all the calculations are run over the course of a month, and then repeated for however many months that we want the simulation to go for.

If there are any questions or suggestions about these definitions let me know. Anyways, on to the calculations!

Order of Calculations

One point I’ve been bringing up a lot is that the order of calculations is very important… Well it’s time to bring it up again! We are now going to have several species running inside the simulation at once, so the order of calculation is critical for decisions such as who gets first access to food.

Turn Order

My original idea was to use a “Turn Order” to handle the multiple species. This is because of the way the algorithm is designed, where we calculate the population change of one species at a time over one month, and then repeat that however many months. At the end of a generation, the game would randomly pick a turn order for all the available species, and then every month it would run once through that list in the order they were assigned, running the population algorithm on each species. This meant that if a species was lucky enough to be at the top of the list, he’d feed first every month of a simulation before anyone else. This also meant that in times of shortage the bottom species on the list could get no food and immediately go extinct. I originally thought this was fair since it was random every time, so everyone had a chance of going extinct and on a future generation a different order of species could be picked, where perhaps you’re at the top. However, I realized that this was not allowing for the species to actually compete with each other in times of shortages.

Simultaneous Simulation

So instead, I decided to implement a simultaneous “race” whenever there is a shortage of food. In any month that there is more food than food that is hunted, the race mechanic is irrelevant and everyone gets the food they want. However, whenever there’s a shortage, the Success Rate of each species hunting the food determines what fraction of the food they get. For example, if Modelus Specius and the other specius combined want to hunt 10,000 food, but there’s only 1,000 food remaining, then if Modelus Specius has a success rate of 75% he gets 75% of the 1,000 and the other species gets the remaining 25%.

How do you calculate Success Rate you ask? Let me explain.

Race for the Food

Let’s first define the two species we have. We have Modelus Specius, the species one we know and love, and now we’ll introduce a second species called Propagatus Maxima. For now they will have the exact same stats. We’ll define a new statistic called Competitiveness, which will be used to calculate the success rate of each species in hunting the food.

Speed

We have no combat in our simulation at the moment, so competing for food is purely determined by who’s the fastest to get it first. We’ll represent this by having the species’ speed compared to the combined speed of all the other species. If Modelus and Propagatus have the exact same speed, say 1m/s, then each wins 50% of the contests. Here’s the mathematical form:

Success Rate = Speed of Modelus / ( Speed of Modelus + Speed of Propagatus)
Success Rate = 1 / (1+1) = 1 / 2 = 0.5 = 50%

However, if Modelus had twice the speed of Propagatus, he would win a larger share of the contests (in this case 2/3).

Success Rate = Speed of Modelus / ( Speed of Modelus + Speed of Propagatus)
Success Rate = 2 / (2+1) = 2 / 3 = 0.67 = 67%

So the greater your speed compared to the competition, the larger share of contests/races you win. Interestingly, with this equation no matter how fast your competitors are you’ll always get at least some of the food (representing hunts where you get lucky).

Population

Okay, but what if the slower species outnumbers the faster one 10:1? Shouldn’t that give a competitive advantage to the larger population since there’s more of them? Yes, so let’s introduce that into the mix.

Say cheetahs and hyenas both hunt antelopes. The cheetah can easily catch an antelope before a hyena 90% of the time because of his speed advantage. But, there’s only 1 cheetah whereas there are 100 hyenas. After that cheetah catches his first antelope, he doesn’t compete with the hyenas anymore and they’re free to now chase antelopes completely uncontested.

We’ll model this by having the Required Hunts of the species multiplied by its speed in the equation. If a species requires a lot of hunts, they’ll be competing for the prey a lot more and thus increasing their competitiveness. A species that is faster but requires less hunts will be like the cheetah and leave the competition early once they get their fill.

This does make a big assumption, and that is that there is no intraspecific competition (competition between members of the same species). I have avoided that so far since I cannot think of a good way to implement it, so please pitch in if you have any ideas on how to model it mathematically.

Say Modelus has twice the speed but Propagatus requires twice the hunts, this will look like:

Success Rate = (Speed of Modelus * Required Hunts for Modelus) / (Speed of Modelus * Required Hunts for Modelus + Speed of Propagatus * Required Hunts for Propagatus)
Success Rate = 2*100 / (2*100 + 1*200) = 200 / (200+200) = 200/400 = 0.50 = 50%

Their two advantages balance out and they both win half the contests. If one species had double the speed and double the required hunts, they’d win 80% of the contests (4x the success rate of their competitor).

Priority

One final component we are missing though. Two species could both have the same speed and same required hunts, but different Priorities for their prey. The cheetahs do all their hunting on antelopes, while the hyenas spend half their time hunting antelopes and the other half hunting zebras. Priority is a proportion simply representing what fraction of their energy they try to get from a given prey. This gives us the final form of the equation:

Success Rate = (Speed of Modelus * Required Hunts for Modelus * Modelus Priority for Food) / (Speed of Modelus * Required Hunts for Modelus * Modelus Priority for Food + Speed of Propagatus * Required Hunts for Propagatus * Propagatus Priority for Food)

Note that at the moment, there are only two species and they both chase after the same food, so they both have a priority of 1.00 for the food. In the future, we’ll create more complex food webs with predators having multiple different preys, so Modelus Specius could have for example a priority of 0.5 for Prey 1, 0.3 for Prey 2, and 0.2 for Prey 3 (all of a predator’s priorities must add up to 1.00).

To recap, we calculate the Competitiveness of a species for a given prey, and compare that to the Pooled Competitiveness of all predators hunting that prey. Using this equation, we can determine the success rate of two or more predators that hunt for the same prey based off their speed, required hunts, and prey priorities. In times of shortage, the success rate determines what fraction of the food they receive.

Competition is a Lose-Lose

If you have studied some biology you might know, competition is a lose-lose for both parties involved. Not only does competition harm you during times of shortage, but it also interferes in times of plenty as well.

We will get to the other interactions listed on that chart in future parts. For now we’ll discuss competition.

Assume that you are Modelus, and there is an equal population of Propagatus in your patch that is perfectly even in all stats. You both hunt for the same clouds of glucose. Statistically speaking, half the time you are likely to have a member of Propagatus beat you to the food you are chasing, and have to start a new chase. So even when food is in abundance the competition increases the time you need to spend on every hunt. We will also model this using Success Rate. If the two species are perfectly evenly matched in speed, required hunts, and prey priority, you will only have a Success Rate of 50%. If you are only winning 50% of the hunting contests, your average hunting time increases by 50%. This is because you need to hunt twice as much, since half your hunts are failing, to get the amount of food you need. If you are winning 90% of the hunts, then your average hunting time only increases by 10%. Recall the equation for Time per Hunt:

Time per Hunt = Distance per Hunt / Species Swim Speed

We’ll now update this to:

Time per Hunt = (Distance per Hunt / Species Swim Speed) * (1 / Hunting Success Rate)

NOTE: Hunting Success Rate is an average of the hunting success rates for all the preys that a species hunts. It is weighted by how many hunts are performed on that prey.

So we can see that even with ZERO shortage, competition increases the time spent hunting for all predators, even if any of the predators have an advantage. This should lead to a phenomenon observed in biology called the Competitive Exclusion Principle, which says that competition between multiple species for a single role will ALWAYS lead to one species winning and the others going extinct or evolving for different roles/niches. We will discuss this more when we run the demos.

The diagram above gives a simple illustration of the Principle.

And that’s all for the mathematical explanations of this part. Even though these explanations were shorter than previous parts, I probably spent 10x longer actually coding the prototype for this part, because of the complexity of the newly introduced interactions.

Demo with 2 Equal Species

Without further ado, let’s see how the introduction of new species changes the simulation! We currently have two species, Modelus Specius and Propagatus Maxima, and they have the exact same stats in all respects. Let’s see the starting conditions:

Simulation Conditions

image

Patch

image

Food

Modelus Specius

Propagatus Maxima

Running a demo of the two species produces the exact outcome we would expect, they perfectly match each other in population size the entire simulation, stabilizing at 446 members each. It’s not even necessary to show the graph for this demo, but at least we know the code is working as intended so far.

Demo with 2 Unique Species

Now for the one we were waiting for, where we assign different stats to each species. We’ll start by doing a very, very small change. We’ll simply increase the strength of Modelus Specius’ muscles from 2.5 N/m^2 to 3.5 N/m^2. A harmless evolution, right?

Propagatus Maxima went extinct in 21 months, while Modelus Specius survived and thrived and stabilized at 923 members.

So what’s the story. We can see the exponential growth at the beginning as there is an abundance of food. Notice that Modelus always seems to grow a little faster than Propagatus. Then the food shortage kicks in on the 8th month, and both populations lose a lot of members. However, Propagatus never recovers! Why is this? It’s because when there is an abundance of food competition increases the time spent to hunt but everyone gets all the food they need eventually (unless it takes them sooo long that they run out of time in the month). However, after the shortage starts, there is only so much food to go around every month. Modelus’ slight speed advantage lets them win more of the scarce food on month 9, which leads to a bigger gap between the two species’ populations by month 10. This bigger gap allows Modelus to win even more of the food, and the cycle continues until Propagatus goes extinct. What does this remind you of? That’s right, the Competitive Exclusion Principle. This is a perfect example of the principle in action, since both species are hunting the same “Food” which makes them competitors for the same niche.

A niche is akin to a “role” of a species in an ecosystem, defined by where it lives, what it hunts, and other such factors.

Interesting to note that even such a small competitive advantage of Modelus Specius over Propagatus Maxima builds up to a huge difference in population, and will eventually lead to Propagatus going extinct. This is exactly what is described by the Competitive Exclusion Principle, and it’s fascinating that this pattern emerged without us even specifically trying to put it into the algorithm. We simply modelled realistic interactions and have started to produce a realistic system! I have high hopes for where this algorithm can go!

Just a quick aside, now that we’ve got multiple species I’ll probably skip showing the tables with the monthly statistics since it would just be way too much information (since it’s one table for every species). I can keep posting them though if you guys really want them. For now though, I’ll show you Modelus’ report just so that we can understand what is happening:

What are some of the interesting patterns you see? Well for one thing you can see that the time per hunt goes down every month, and this is because Modelus is facing less and less competition as Propagatus dies off. This gradually leads to them having more free time to reproduce, which increases their birth rate and helps them reach a higher population.

One thing this demo has taught me though is that I feel that the starvation penalties may be a bit too harsh.

Less Severe Starvation Rules

At the moment, 100% of the starving population of a species will die next month. This leads to very sudden extinctions when food runs out. I know that making this value any less than 100% seems very unrealistic since it seems like you’re saying species members can survive over a month without eating. To counter that, I’d say that this percentage can also represent how much energy ALL species members are receiving. 75% Proportion Fed could also mean that ALL species members only receive 75% of the energy they need. So to create a bit of a “softer landing” for species that run low on food, and not letting them go extinct extremely quickly, let’s try making it so that only 50% of starving species members will die. This means starvation is of course still bad but not the game-ending event it was before. This means that your species could technically eat 0 food for an entire month, and only 50% of them would die. Is that entirely realistic? I’m not sure, but we cannot make any more granular changes unless we make the timesteps smaller, and perhaps this is better for balance. Let’s see how this affects the simulation with the same conditions as before.

There we go, a much less severe drop for Propagatus. Even though he looks like he is still destined to go extinct under the current conditions, he at least won’t do so in under 2 years. We can play with the severity of starvation to get the results we like, so I’ll leave that open as a discussion question.

How severe should starvation be?

One more demo with 2 species. This time let’s make Propagatus Maxima into the species he was intended to be. Modelus Specius’ strength will be set back down to 2.5, but instead Propagatus will have 20% higher mating frequency than Modelus.

Holy cow. Clearly increasing mating frequency appears to still be very overpowered. We can revisit potentially balancing that in a future part.

This has been a lengthy post, but luckily with lots of cool new content! We are finally starting to see a lot more of the typical patterns we associate with evolution emerge in the system. I will do a sub-part soon where I’ll crank up the number of species in the simulation to 4, giving each of them unique advantages, and we’ll see who wins the game of evolution! Then after that, we’ll proceed with the next part of the series. Until then, please leave your feedback below!


Summary

New Performance Stats
Competitiveness
Pooled Competitiveness

New Traits
None

Topics for Discussion

  • How do I model intra-specific competition (competition within a species)?
  • Is it possible to make the time-steps smaller? This would allow for more realistic hunger/starvation modelling. Except this could also make the algorithm very computationally intensive.
  • How severe should the consequences of starvation be? 100% death rate of all starving members?
2 Likes

I think there’s a typo here.

Very interesting to see multiple species added. I’m currently working on the basic framework for auto-evo (scheduling background calculations, waiting for them to end). It’ll soon be time to add some kind of fitness calculation.

1 Like

Interesting stuff.

So say you had only one limited food source in a patch, like iron maybe. Are you saying (assuming no predation) that even if you started with 100 species all but one would go extinct? And even if that one splits one half will just die off? I’m not sure that’s particularly ideal.

On the wikipedia page you linked to it says:

Competitive exclusion is predicted by mathematical and theoretical models such as the Lotka-Volterra models of competition. However, for poorly understood reasons, competitive exclusion is rarely observed in natural ecosystems, and many biological communities appear to violate Gause’s law. The best-known example is the so-called “paradox of the plankton”.[7] All plankton species live on a very limited number of resources, primarily solar energy and minerals dissolved in the water. According to the competitive exclusion principle, only a small number of plankton species should be able to coexist on these resources. Nevertheless, large numbers of plankton species coexist within small regions of open sea.

I imagine that we would want a bunch of different plankton-like species right all coexisting?

1 Like

Ah thanks I fixed the post.

Also very interesting, what are you planning to include in the fitness calculations? Let me know if I can offer any of the equations or functions I’ve created so far.

Yeah that’s a good question. At the moment, since the model is so simple the Competitive Exclusion Principle has a very exaggerated effect. However, there are several reasons that I can think of that ideally should limit the Competitive Exclusion Principle acting strongly and quickly to wipe out competing species. As we build the algorithm these should start to be introduced. Technically, if there was a species predating on Modelus or Propagatus, that would be a additional factor that would limit the Competitive Exclusion, but we’ll assume that does not apply:

  • The model currently lacks intraspecific competition, which means that an increasing number of Modelus Specius will always perfectly cooperate with each other and each will decide to target separate foods from the other members of Modelus Specius. Even in times of shortage members of Modelus willingly choose to take, for example, 75% of the energy they need so that all other members also can get 75% of the energy they need. We know that realistically this doesn’t happen, so I’ve been thinking about how to model intraspecific competition and I might have a solution for the upcoming sub-part.
  • The model only has one niche which both species are trying to fill. In more complex ecosystems, Predator 1 might hunt Prey A and Prey B, and Predator 2 might hunt Prey B and Prey C, and Predator 3 might hunt Prey C and Prey A. Predator 1 is the dominant competitor for hunting Prey A, as is 2 with B, and 3 with C. However, since they all have different overlaps for their niches and the prey they are most successful at hunting, competitive exclusion will have less of an effect to reduce their numbers.
  • The predators are highly efficient. At the moment there are very few things obstructing the predators from catching their prey. For example the predators do not have to deal with the constraints of perception and simply always know where the prey are. They also always catch the prey and do not have to fight in combat with the prey. I’m predicting that once we add in new features like perception and prey that run or fight back, predators will become much less efficient and Competitive Exclusion will develop a weaker effect. I might be wrong on this one though.
  • The exclusion of weaker species only actually kicks in in times of shortage. Notice how before the food shortage both populations were growing, even the weaker predator. The shortage is also pretty unrealistic, since during the shortage months all the food is being eaten, and then 2,000,000 units of food are appearing out of thin air to replenish the food stocks in the next month. Once we implement predation on proper species that have realistic population growth, I’m predicting it will change the amount of Competitive Exclusion we see.
  • The Competitive Exclusion Principle as it’s currently implemented only applies to consumers (aka heterotrophs). The equation so far is specifically for chases when one predator catches the prey before you do, and there’s only a limited number to catch. For something like plankton, if one plankton consumes solar energy it doesn’t take any solar energy away from another plankton. Instead here the competition becomes more about location, and being the plankton that is at the top of the ocean to receive the sunlight and physically block plankton below you who will receive less of the light. Also, I’m not sure if the plankton all feed on the same minerals or on different minerals, because if it’s the latter there might also be some differences in the niches they are trying to occupy, again leading to less Competitive Exclusion.

It’s not super high priority. Initially I’m just going to duplicate the random population changes.
But it would definitely be helpful to think about how this simulation could be fed with the data that is in Thrive.
Once the initial work is done it will be easier to see what kind of information is easily available and what’s difficult to get.

1 Like

Yeah that’s true. I’m excited to cover that topic when it comes up. Episode 2 and especially Episode 3 will be about how to take the information provided by Thrive and feed it into the simulation. Episode 1 is mostly about how to process that information into an outcome once you already have it.

It’s one of the most interesting things I have ever read about evolution!
I really like what are you doing.
I have only one question, do you think could be interesting to introduce parameter about growing up, when member of that species become 100% effectively? How this affect competition with food?

I would be very interesting in see a species with low time to become full grown in the same patch with one stronger in hunting but not in growing.

Do you think could be interesting parameter?
@NickTheNick

Of course cells do not do that if they split by mitosis so they could have that parameter set o 0

This value could affect speed of hunt or effectiveness maybe, because all species would be generally more ineffective ( if both species has same lifespan and 1 need more time to o become fully effective)

I’m also thinking about age that could affect same value but I think I’m putting too many things on the same time :slight_smile:

We’ll absolutely get to the effects of aging! One of the current assumptions is:

The species does not change in physiology as they age.

However, in a future part, we’ll remove that assumption and create a process to track different age classes and how each one is able to survive in the environment.

1 Like

So I played around a little bit with a basic Lotka Volterra model. It’s less chaotic than I thought it would be which is good, but it is quite delicate, if you change the parameter values even a little it can break. However I’m a it more open to being convinced this might work.

One thing I’d suggest is it might be good to play around with it. The code is here. Try changing the predation relations or the birth and death rates and see what happens to it. You might need to pip install pygame to get it to work. I marked 3 places in the code where things can be changed relatively easily. Feel free to ask if you have any questions.

Well, finally got around to reading through all of this. There’s so much here that it’s quite difficult to respond to individual points so I’ll have to accept this post being quiet vague.

First off, thanks so much for doing this. We’ve been in need of a concrete approach to the CPA system for some time and even if this is eventually rejected, it’s good to be at the point where we can decide on something properly one way or the other. It’s also reminded me why I fell in love with Thrive in the first place. So again, thanks, and thanks for not giving up when you lost the first copy of all this.

One question I think we all need to answer as individuals before we define a system like this is: what is Thrive about?

For me, personally, I want a product where the central premise is, ‘Can you beat an evolution simulation at its own game?’ There’s no point having some crazy simulation in the background if it doesn’t affect the player’s experience, and there’s no point having the player do anything if it can’t affect the simulation. That’s a point I’ll return to later.

I really like your chess analogy, and I think we can extend it further. I’m good enough at chess to know how proper chess players play without actually being able to follow that myself, so let’s use some of that.

For the most part, it’s all about patterns. Sometimes there will be standard procedures and definite best strategies, such as the progression of an opening once it’s been chosen, but on the grander scale there’s less determinism about it. A grandmaster can look at the board and approximately match the situation to a pattern they’ve learnt, then use a heuristic approach to choose what’s likely the best response. That’s also how computers play chess as it drastically reduces computation requirements. Or at least, they did until the advent of, ironically, genetic learning algorithms.

Comparing this to Thrive, I would like to see a non-deterministic pattern-based approach to strategic gameplay too. If an ecosystem appears to be almost all herbivores, you can recognise that pattern and know that becoming a carnivore will in most cases be an advantage. But not always. Maybe you didn’t factor in the unique situation of this play through, such as established carnivores migrating in from surrounding patches that you now have to catch up with.

Perhaps there are a few situations when certain adaptations are absolutely optimal. If your prey develops poison, you develop poison resistance. But I really don’t want that to happen with everything.

Coming back to your algorithm, I’m worried it’ll be hard to strike that balance. While admittedly the situation is relatively simple so far, there’s little scope for variety. Increased speed is always better. Increased mating frequency is always better. At the moment the difference in improving any of these stats is purely cosmetic, they all lead to a general survivability advantage.

But, as TJWhale said, with more complexity you could see the opposite problem. Suddenly things become chaotic, and you have zero idea what the best strategy is.

I think once you introduce more than two species you’ll see the impact of this issue reduce, but I’m still hesitant. In the real world, there is always a cost for any benefit. Being faster means needing more food. Being bigger means less manoeuvrability. I assume this will be addressed later on but I think special care needs to be taken to make sure there aren’t too many outright wins, but instead advantages for certain situations or habitats that may have drawbacks.

I was also slightly disappointed to read you’d opted not to go the continuous route. Although you can get equations you can’t solve analytically and would have to discretise for computation anyway, I do think there are more tools available, especially calculus. For example, Holling functional responses can model the effects of hunting and nutrition in a simple way (or so I’ve learnt from one semester of modelling and dynamical systems). Still, discrete models have their uses and if we build a decent algorithm with one then that’s no issue.

Having said all that, I really like where this is all going. The potential for becoming over complicated for little gain is high but still I believe it’s worth pursuing.

I would like to take a look at your Python script, and maybe even try my hand at developing a dynamic version where the user can adjust values for species attributes on the fly and see how that affects population distribution. I need an excuse to practice Java outside of work.

Also, at every stage it should be important to keep gameplay in mind. One of my general worries about Thrive is that we’ll end up designing a system that’s entirely independent of the player’s actions outside the editor. If they design the perfect organism but play the actual game terribly, how do we take that into account? Or if their species is sub-par but they’re really good at hunting and surviving as an individual? I’m struggling to think of a way to do this that doesn’t cheat the evolution system.

Anyway, really great read and thanks again. Together with our recent uptick in concept art and considerable programming effort, Thrive is once again looking very viable.

4 Likes

Thanks yeah I’ll definitely check that out! My prediction is that even though Lotka-Volterra models do create pretty chaotic relationships, there are enough “soft boundaries” in the other features that we have introduced into the system that can sort of “box” the outputs of predator-prey interactions into a relatively understandable pattern. But we’ll see how well that prediction can hold up after I test with that and ultimately add more species and deeper interactions to the algorithm.

Thank you I appreciate it! For me as well it has helped tap into some of that original passion that drew me into the project, which is I think the only reason I was able to tackle it a second time after losing my progress. I think even if this approach doesn’t work, it gets the conversation going on how to concretely simulate Auto-Evo. Perhaps this algorithm can inspire a similar algorithm, or perhaps certain equations used in this algorithm can be used in the final algorithm, or perhaps even this algorithm will simply show us what route NOT to take.

Yes, I completely agree! In fact I am glad to see that so far every trait that has been introduced does affect the outcome in a believable way, and I’m going to try to keep it that way so there’s no useless complexity being added. Actually one trait I’ve noticed has been having a very small effect on things is the Clustering trait, so in a future part I might revisit why it’s not producing the results we intended.

That’s a good point! I was actually planning to address that 2 parts ago, but I decided to leave it for later. The thing is we are currently assuming that the traits are being fed to us from the Organism Editor. Since it’s only Episode 1, I’m only covering how these different traits will be used to calculate the final population numbers. However, Episode 3 will actually cover how this algorithm as a whole will integrate into the game. In other words, where the values for these traits are coming from. Part of that will be covering how the player’s performance in-game affects Auto-Evo, and another will be how the Organism Editor ties into the traits used in Auto-Evo. Realistically, many of these traits would actually be tied together. For example:

  • Increasing body size/volume will:
    • Increase base metabolism (you’ll need more energy)
    • Increase body radius (you can catch prey slightly faster)
    • Likely increase frontal surface area (Which will increase the drag you face from water and reduce your speed)
    • Reduce mating frequency (since it takes longer for your body to replicate all its cells)
    • Increase your energy yield when fed upon (Perhaps making you a more tempting prey)

Another two reasons why I think all mutations currently seem like brainless winning moves:

  • There’s almost no competition. With many other species also evolving around you, it’s no longer a matter of choosing a “good” mutation or a mutation that simply increases your population, it has to be a mutation that increases your population more than the mutations chosen by your competition that is increasing their populations. Think of it like the difference between being the only Toy Store in a town versus a Toy Store with 5 other competitors within several blocks. Of course being the only Toy Store will be pretty easy and it doesn’t really matter what business decisions you make, but Thrive is a game about being one of many Toy Stores and surviving the fight to become the best.
  • The environment is extremely forgiving and mild. We’re basically assuming that there is no change in climate over time, and there are no deaths from environmental conditions that the species is unadapted to (like temperature, pressure, acidity, salinity, radiation, etc.). Increased mating frequency is probably a pretty stupid choice of mutation if you are a hairless animal at the onset of an Ice-Age.

I’ll really dive into the details on all the interrelationships between traits on Episode 3, since I think it’ll be really cool since it’ll be a discussion both on Auto-Evo and the Organism Editor and how they tie together.

I would have if I could have, but I felt that my skills in continuous mathematics and modelling are nowhere near my ability to model discretely. Since I felt that this entire venture was already going to be difficult enough for me on its own, I decided to at least make the process around it easier for myself and use what I was best at (discrete modelling) and the language I’m most familiar with (Python), even if continuous modelling and learning a better programming language would have produced a better outcome. I mean worst case scenario, if this algorithm is chosen and we want to make it continuous, we’ll have an entire pre-built model to base it off of.

I’ll send it your way. In the script has a section that lets you do exactly that, tweak the numbers for each species, or the patch, and watch the outcome.

A very good question that we always need to keep in the back of our minds. In Episode 3, we’ll tackle this problem full on.

1 Like

Part 6.1: Intraspecific Competition

So we just implemented interspecific competition, which is competition between species, but what about competition within a species?

image
Two Terror Birds compete for the same prey

Intraspecific competition can very well affect the survival of a species. Say a T-Rex is roaming around looking for food. It’s possible that he spots a prey about the same time that another T-Rex spots a prey. They both chase for the prey, but only one gets to it first, making the other one have to hunt again. They could have agreed to chase different prey, but most species are not cooperative or altruistic, and many don’t even have the intelligence to be able to even discuss things in any way. As a result, the intraspecific competition actually increased the average hunting time of the species, even when there was no shortage of food.

What’s interesting to note is that Intraspecific Competition only affects the increase to hunting time, but has no effect on the fraction of food caught during shortages. This is because during a shortage, if one T-Rex catches a prey in a race with another T-Rex, that other T-Rex automatically loses that prey, so the differences cancel out. However, with the example I gave above, you can see why it still affects the time spent hunting (which applies with or without a shortage).

The only problem was that actually implementing intraspecific competition mathematically has been something I was wondering about for a while now, but I finally came up with an idea.

Intraspecific Competition

We can simulate intraspecific competition using a simple proportional model. And we’ll use the strategies you know and love, Proportional Estimations and Edge Cases!

Assume a Modelus Specius population has a very very small population in a patch, basically 1. He will face a very very small rate of intraspecific competition, basically 0%. This is because it’s almost impossible for another Modelus to beat him to a prey, since they’re just not there. As a result, he suffers essentially no increases to his hunting time.

But this will never happen, the populations of species will almost always be more than this in a patch. As you increase the population of Modelus, you increase the percentage of hunts he will fail due to intraspecific competition, AKA the average time he’ll have to spend hunting. We can model this using a simple relationship:

For every +1 organism/m^3 increase in the population density of Modelus Specius, there is a +0.1% increase in intraspecific competition, meaning there is a +0.1% increase in average hunting time.

Note that we’ve now added Population Density to the algorithm. This is represented as individuals per m^2 (or per m^3 if underwater).

Clustering will increase this number. At 0% clustering, there will be no effect on intraspecific competition. However, the more clustered a species is the more they will get in each others’ way, thus it will increase intraspecific competition. This gives us:

For every 1% increase in the clustering of Modelus Specius, there is a +0.1% increase in intraspecific competition, meaning there is a +0.1% increase in average hunting time.

Hopefully this also makes the Clustering trait a little more impactful on the simulation than it’s been so far.

Mathematically this looks like:

Intraspecific Competition = Intraspecific Competition Rate * Population Density * (1 + Clustering)

Note that the Intraspecific Competition Rate describes how fast the Intraspecific Competition of the species grows as a result of increases to population density or clustering. Intraspecific Competition Rate is a trait, it’s an innate behaviour of the species. Meanwhile, Intraspecific Competition is a Performance Stat, since it fluctuates with the changing levels of population density.

To summarize: Intraspecific competition simply describes what percentage of hunts are lost due to a member of the same species beating you to the prey. It technically can never reach 100%, because some members of the species have to be the ones winning, so it caps at around 99.99%.

Altruism & Cooperation

However, some species have evolved the ability to recognize their kin and even work with them and avoid conflicts with them. We still have a while to go before we get to intelligence and sociality, but for now we’ll create the potential for this feature when it is introduced in the future.

Increasing the altruism of your species will reduce how fast intraspecific competition increases with population density and clustering. Say the standard Intraspecific Competition Rate is +1.0%, an altruistic species might evolve to lower this to 0.5% or 0.1%. This represents social species that live in large groups and who have learned to avoid competing with each other.

2-Species Demo

So what should these changes do? The introduction of intraspecific competition should actually add as an additional limiter on the size of a species in a patch, on top of food. As a species grows larger and larger, there is more and more intraspecific competition which makes their hunting less and less efficient. This should actually help mitigate the effects of the Competitive Exclusion Principle that we observed last in Part 6, since the dominant species in a competitive relationship might not be able to fully take over the patch since they’ll face too much intraspecific competition. Let’s run the numbers and see the results:

The parameters of the demo are the same as in Part 6. Remember, Propagatus Maxima is the same as Modelus Specius in every trait except that it’s mating frequency is 0.6 times per month instead of 0.5. We’ll now add the following two trait changes/additions to Propagatus:

  • Clustering increased from 0% to 50%
  • Intraspecific Competition Rate set to +0.7% per 1 individual / m^3

Meanwhile, Modelus Specius has an Intraspecific Competition Rate of 0%, meaning it faces no within-species competition. Let’s see the results!

Interesting! Remember that the last time we ran the demo Modelus Specius was on its way to extinction, ending the 2 years at around 160 members. This time around Modelus is at over 400 members by the second year, and still at above 300 by the third! Clearly the intraspecific competition of Propagatus is holding it back from dominating the environment, even though it has the reproductive advantage.

It’s also interesting to note that Clustering actually has a significant impact now. Before, Clustering barely (and I mean barely) affected the average hunt distances even at the most extreme values, but now it plays a major role in intraspecific competition. Species that are clustered together will face a lot more competition between species members, and are better off evolving to live more solitary lives (think boars) OR to evolve cooperative tendencies so they can work together (think zebras).

3-Species Demo

Alright, time to crank up the simulation by a notch. We added a 2nd species last time, so now let’s add a 3rd! This species will be the exact same as Modelus Specius, but it will have slightly stronger muscles (3.0N/m^2 instead of 2.5N/m^2). To recap, the three species look like:

Modelus Specius: The typical species.
Propagatus Maxima: Same stats as Modelus Specius but Mating Frequency is 0.6 / month instead of 0.5, Clustering is 50% instead of 0%, and Intraspecific Competition Rate is 0.7% instead of 0%.
Minimus Rex: Same stats as Modelus but Muscle Strength is 3.0 N/m^2 instead of 2.5.

Let’s see the results:

Damn, even though Modelus Specius was able to hang in against the competition last time around, the double competition of Minimus Rex and Propagatus Maxima was just too much and they went extinct. It’s also interesting to see that Minimus and Propagatus do not seem to be pushing the other into extinction. Perhaps they will survive in an equilibrium? It could be that Minimus has the competitive edge because of the speed advantage, but Propagatus is able to “eat into” those losses with his increased mating frequency that covers for his starvation deaths. Or perhaps their declines are slower and we would need to run the simulation for longer.

Regardless, amazing to see the simulation still holding together with 3 species in the mix now! It’s really starting to feel a lot more like a living ecosystem compared to the first few parts of the series. It’s also really cool to see the results and predict what causes are leading to what outcomes. These interactions will only get more deep and exciting as we go!

Q&A

Before we close, we’ll take this moment to open the series up to for a Questions and Answers period for all readers. We’ve covered a LOT of content so far, and I want to make sure none of the readers are falling behind on their understanding. If you have any questions, comments, concerns, suggestions, or what have you on the series so far, submit it on our Discord, Subreddit, Facebook, or Twitter and I’ll answer as many as I can in the next post! You can also respond to the subreddit post that I’ll be making for this part shortly, or to the Devblog that will be coming out within a few days (that will be all about this series). Hopefully this Q&A can help bring us all up to speed on the series so far and address any ongoing confusions people may have.

Anyways, thanks for reading and see you guys next time!


Summary

New Performance Stats
Intraspecific Competition

New Traits
Intraspecific Competition Rate

Topics for Discussion

  • All feedback is welcome!
2 Likes

One question I have is what happens if you run the 2 species model for longer? Does it settle into an equilibrium or does one species die out? Same question for the 3 species model, what happens over a longer timespan.

For the 2 species model, Modelus died out after 1-2 more years. However, if I increased Propagatus’ Intraspecific Competition Rate to 0.8%, then they stabilize. Here’s a graph of their populations in the latter scenario over 10 years:

If I do the 3 species model over 10 years Minimus Rex wins and the other 2 species go extinct. However if I give Minimus Rex some intraspecific competition as well (an Intraspecific Competition Rate of 0.8%) we get a 2 species equilibrium. Modelus still goes extinct though. Here are the results.

I guess Modelus is just not competitive enough to survive against 2 competitors. Also there is probably not enough food being generated every turn in the ecosystem to support three species of around 500 individuals. I’m guessing if the food replenishment rate was increased, or if the intraspecific competition rates of Minimus or Propagatus were increased which would lower their equilibrium populations, Modelus could survive.

2 Likes

Part 6.2: Q&A

And we’re back with the questions that people had for the Q&A! Let’s see what feedback people had.

@DmitrisTerlegkas from Twitter asks:

Who the hell has time to write 10k words??? Give the man who wrote all that a metal and a raise

Me, and technically I shouldn’t have the time but I’m carving out what free time I can. A medal would be cool though!

LibertyBellSeven from Reddit asks:

Good stuff! My main concern about auto-evo is that it will produce similar and unnatural looking creatures. How can the algorithm generate lifeforms that can compete aesthetically with the player-species?

To which I answered on reddit. Here's the response I gave:

That’s a good question, and part of the answer is that it’s hard to give a straight answer since both Auto-Evo and the Organism Editor are still works in progress and haven’t been finalized yet. It’ll become more apparent how to address issues like these once we actually finish designing those.

However to answer your question as best I can right now, there’s a lot of physical, chemical, and biological reasons that creatures on earth look the way that they do. Hopefully, if we implement realistic enough rules and boundaries in the game, it will drive the creatures generated by Auto-Evo to approximately fall into believable looking aesthetics.

One example I can think of is that we’ll calculate the frontal surface area of any organism, and that will reduce their speed if they live underwater. This will tend to cause underwater species to go for more streamlined shapes to have higher speeds underwater, and have a more fish-like appearance as seen on earth.

Another example could be putting hard limits on where certain mutations can occur, since evolution always works with what DNA is currently available. For example a species might start evolving legs on the sides of its torso with the new leg bones evolving out of the existing spine bones, whereas we wouldn’t allow a leg to start evolving out of an earlobe. However, maybe that creature has very unique ears that have bones in them that could evolve to split off and develop a leg! The point is though that plausible biological and physical limits will exist to make things look more natural.

Solitarian from the Community Forum asks:

Actually the plan is to make the algorithm specifically note what kinds of movement organisms use and have that affect their survival. Some differences will be clear, such as underwater patches being specifically different patches than terrestrial patches and containing different species. However, there will of course be grey areas. There are birds that dive into water to catch fish, there are amphibians who live on both water and land, etc. I’ll address that all in future parts once we get major obstacles like predation, combat, and metabolism out of the way.

MisterMustachio from the Community Forum says:

I have to wonder how you’ll calculate the overlap of species in separate environments. A species may encounter a number of other species, but isn’t likely to encounter every member of those species, nor is every species likely to encounter every other species.

Species within a patch are assumed to pretty much interact with all of the other species in the patch. The differences will be between patches. Species A might overlap with Species B in some patches because they both exist in it, and not in other patches since only one of them exists there.


Those were all the questions from this Q&A. Unfortunately my free-time has been limited so the next part likely won’t be ready for another week. However, if it makes you feel better it’s because the next part includes some major changes.

2 Likes

Part 7: Predation

At the moment, all of the species hunt for the same free-floating clouds of glucose that we’ve been calling “Food”.

Boring!

Now that we have multiple species let’s add the first step to realistic feeding, carnivores!

Now that we’ve added other species to the mix, and gotten the nitty gritty of competition out of the way, we can start to make this model a lot more interesting. These next few parts will have a lot of juicy content, but will also involve some difficult conceptual hurdles, so it’ll be interesting to see how we make it past them. In fact, my notes for the parts after these next few posts are sparse, because it will depend so much on what we come up with for these next few parts.

Predation is a VERY complex topic, so we will be breaking it down into several parts. Today we will tackle the basic concept of catching and feeding on other species, and how that changes the population dynamics of the ecosystem (as well as how their speeds, accelerations, and endurances are pitted against each other). In future parts, we’ll address Combat, Parasitism, Scavenging, Prey Selection, Heterotrophy vs Autotrophy, and Cannibalism. By the end of implementing all the features related to predation, we’ll have a MUCH more robust algorithm on our hands. We’ll also see that the Starvation Deaths performance statistic is actually a very complex stat derived from many, many, many interplaying factors. It will be the stat that likely fluctuates the most between months, and it makes sense because success in hunting is a large part of survival. Many evolutions of species will simply be to improve success in hunting and reduce Starvation Deaths.

Let’s break down the following assumption from our list of assumptions:
  • Modelus Specius is a flat, tiny, simple, jelly-like organism that lives at the bottom of the ocean.
  • Members of the species can completely consume the food and gain 100% of the energy. (Hunting/Metabolism)
  • Members of the species can instantly perceive food regardless of distance (Perception)
  • Members can reproduce as many times as they want, instantly, with no pregnancy/gestation period. (Reproduction)
  • The species reproduces via asexual reproduction, spawning fully developed offspring that can themselves immediately begin reproducing. (Mating)
  • The species does not change in physiology as they age (Aging/Ontogeny)
  • The species is fully aquatic (Terrestriality)
  • Members of the species are solitary and do not cooperate with other species members in any way. (Cooperation/Sociality)
  • The species has no parental instincts, and will immediately abandon offspring (Parenting)
  • The species is perfectly adapted to its environment and suffers no death or disease from environmental conditions (Environment)
We will instead replace it with:
  • Modelus Specius is a flat, tiny, simple, jelly-like organism that lives at the bottom of the ocean.
  • Members of the species will always win combats against smaller individuals, and lose to larger ones (Combat)
  • Members of the species always consume 100% of the energy of defeated prey (Metabolism)
  • Members of the species can instantly perceive food regardless of distance (Perception)
  • Members can reproduce as many times as they want, instantly, with no pregnancy/gestation period. (Reproduction)
  • The species reproduces via asexual reproduction, spawning fully developed offspring that can themselves immediately begin reproducing. (Mating)
  • The species does not change in physiology as they age (Aging/Ontogeny)
  • The species is fully aquatic (Terrestriality)
  • Members of the species are solitary and do not cooperate with other species members in any way. (Cooperation/Sociality)
  • The species has no parental instincts, and will immediately abandon offspring (Parenting)
  • The species is perfectly adapted to its environment and suffers no death or disease from environmental conditions (Environment)

Changes to the Algorithm

This part again included some major changes to the code, so I had to do another major overhaul to make things cleaner and more organized. I also had to reorder how some things were calculated to make it easier to implement predation and the upcoming features. Here is a summary of the changes:

  • Prey lists and predator lists. Every species now has a list of species it preys on and a list of species that are predators to it. Instead of just calculating hunting statistics once for every species, we now calculate different statistics for each prey that they hunt. These include Required Hunts, Available Hunts, Time per Hunts, etc. The differences between how the predator favours the prey is based off of the priority that predator has for hunting each prey. If a species has a total energy requirement of 1000 joules for their entire species, and they have a prey priority of 50% for Species X, then they will try to get 500 joules of energy through hunting Species X (however many hunts that would be). At the moment, all species have only 1 prey, the food clouds, with a priority of 100%, so this makes no change to the simulation’s outcome. However things will change over the course of this part as we make species prey on each other.
  • Body mass, acceleration, and endurance added as traits. I will explain why below.

How Do we Implement Predation?

As a result of implementing predation, Modelus Specius will now be a carnivore. Carnivores will instead consume members of other species instead of the clouds of glucose. In this case, Modelus Specius will feed on Propagatus Maxima, and nothing else. Propagatus Maxima and Minimus Rex will continue to feed on glucose only. We’ll cover herbivores and omnivores in a future part. This gives us the chance to create our first food web!

We can see that it’s pretty simple so far, with Modelus Specius at the top of the food chain and only two species below him.

The major changes to the simulation by adding predation will be:

  1. Hunting prey that can move and escape you. So we need to come up with an equation that determines how successfully predators can catch prey.
  2. Hunting prey whose population can grow or shrink dynamically. This will not need to be specifically coded because it will naturally result from the changes we make. However, it will be interesting to observe how it changes the results of the simulation.

Planning how to start tackling this issue can be a pretty tricky concept, so let’s break it down into its constituent elements and think about it logically.

A predator can either be in two situations with the prey.

  1. The predator is faster than the prey.
  2. The predator is slower than the prey.

New Traits

Before we consider these two scenarios, I added 3 new traits to the mix to help in the calculations that you will see soon.

Acceleration is a trait representing a species’ initial acceleration going from not moving to his max speed. It is calculated by the simple physical equation of Acceleration = Force / Mass. Remember that force in this case is the force of the muscles, which we already have traits for. The units of acceleration are in meters per second squared.
Body Mass is a trait representing the mass of the species. So far, it is only used in calculating the acceleration of the species. The units of body mass are in kilograms.
Endurance is a trait representing how long the species can go at its max speed before it tires and has to stop. The units of endurance are in seconds.

Faster Predator

If the predator is faster, then it’s quite simple. The predator can overtake the prey in speed and catch him. In this case, we can refer to the predator as a “Speed Hunter”, since he’s using his greater speed to catch the prey in their chases.

There’s only one caveat. What if the predator starts 100m away and gets tired after just a couple meters of running? Even if he’s faster than the prey, it’s irrelevant because he started so far away he couldn’t traverse the distance. Thus we can see that even if the predator is faster than the prey, he has to have the endurance to overcome the distance between them. So a more accurate statement would be:

“If the predator is faster than the prey, AND the time it takes to catch the prey is less than or equal to the predator’s endurance, the predator will always win the chase.”

Mathematically, we’ll represent this using a fraction. We’ll divide the endurance of the predator by the average time per hunt. We’ll cap the success rate of the predator at 100%. This gives us the following equations:

IF Predator Speed > Prey Speed
THEN Success Rate = Endurance / Time per Hunt 

NOTE: For or any astute readers, you may recall that Time per Hunt is a performance stat that is affected by inter and intra specific competition! More competition increases the time per hunt. This means that increased competition makes it less likely that a predator will have enough endurance for all their hunts, since sometimes they’ll spend time chasing a prey that gets caught by someone else and wastes some of their endurance.

Also, remember that we added in a new trait called acceleration! Actually calculating a detailed realistic way of implementing varying speeds and accelerations into the hunting equation would be a nightmare. So the simpler way that I will tie in acceleration is by comparing the acceleration of the predator to the acceleration of the prey. If the predator has a higher acceleration than the prey, this gives him a bonus to his speed. If he has lower acceleration, this gives him a malus. This is to represent organisms who are very quick at accelerating and reaching their top speed and catching their prey (or getting away from their predators). So we’ll update the equations to this:

IF Predator Speed * (Predator Acceleration / Prey Acceleration) > Prey Speed
THEN Success Rate = Endurance / Time per Hunt

However, what if the predator does NOT have the endurance to outweigh the average time per hunt? Notice that the relationship is a simple ratio, so if the endurance is half of the average time per hunt, then that means the predator will win half of the chases. This represents that half of the time, the predator is close enough to catch the prey. The other half of the time, he starts so far away that he gets tired before he catches up to the prey (even though he is faster).

This seems like a good equation for now. If we find that it favours the predators or the prey too much, we can come back and rebalance it. Let’s see a quick visual demo of what we discussed:

Let’s say that the prey starts 25m away, and both species have equal acceleration so there is no bonus/malus to the predator. We can see that the time it will take the predator to catch the prey is just the distance he starts away from the prey, divided by the difference in their speeds:

Time per Hunt = Average Distance of Predator from Prey / (Predator Speed - Prey Speed)
Time per Hunt = 25m / (10m/s - 5m/s)
Time per Hunt = 25m / 5m/s
Time per Hunt = 5s

Notice how the prey has a much higher endurance than the predator. But it doesn’t matter! Since the predator is faster, he catches up to the prey in 5 seconds, exactly his endurance limit. Using the equation we have above, that gives the predator a success rate of:

Success Rate = Endurance / Time per Hunt = 5s / 5s = 1.0 = 100%

The average hunt is exactly within the endurance limit of the predator, so he catches the prey essentially an average of 100% of the times that he chases him.

Slower Predator

Ok, but what if the predator is not faster than the prey? In that case, there’s only one possible scenario where the predator could still win. This is what we’ll call an “Endurance Hunter”.

Imagine a predator starts to chase a prey 10 meters away. The prey has a speed of 10 m/s, but only 1 second of endurance. Meanwhile, the predator has a speed of 1 m/s but has 100 seconds of endurance. The prey outruns the predator for the first second, but then tires. Meanwhile, the predator second by second gets closer, until eventually catching the prey on the 20th second.

So even if the predator has a lower speed than the prey, he can still win if the overall distance he traverses is greater than the distance the prey traverses PLUS the distance of the gap between them. How does this look mathematically?

First, let’s define the distance traversed during a hunt as the speed of the organism multiplied by the endurance of the organism:

Predator Distance Travelled = Predator Speed * Predator Endurance
Prey Distance Travelled = Prey Speed * Prey Endurance

Now, combining this with what we discussed above we get:

IF Predator Speed * (Predator Acceleration / Prey Acceleration) <= Prey Speed
AND Predator Distance Travelled >=  Prey Distance Travelled + Average Distance from Predator to Prey
THEN Success Rate = Predator Distance Travelled / (Prey Distance Travelled + Average Distance from Predator to Prey)

Notice that again we are using a fraction for determining the success rate. This time we compare the distance travelled by the predator to the distance travelled by the prey plus the gap between them. This means that the total distance travelled of the predator would equal the total distance travelled of the prey plus the average gap between them for the predator to have a 100% success rate.

Let’s use another diagram to visualize this scenario:

Again the prey starts 25m away from the predator. Although the prey has a higher speed than the predator, he tires quickly while the predator continues chasing due to his high endurance. Eventually the predator catches the prey, at the 55th meter. The time the hunt takes is the total distance the predator has to move to catch the prey, divided by the predator’s speed.

Time per Hunt = (Prey Distance Travelled + Average Distance from Predator to Prey) / Predator Speed

The predator’s average success rate is modelled by:

Success Rate = Predator Distance Travelled / (Prey Distance Travelled + Average Distance from Predator to Prey)
Success Rate = 75m / (30m + 25m) = 75 / 65 = 1.00 = 100% (Capped at 100%)

Notice that you could have an alternate scenario where the predator’s distance travelled is less than the prey distance travelled plus the average distance from predator to prey. In this case, the success rate would just be the ratio of the predator’s distance travelled to the denominator.

Assumptions

Now what are some of the assumptions that this model is making? Well it assumes that predators and prey always have their maximum endurance available when chasing. What if a predator starts a chase with only half endurance? Or a prey with only 20% endurance? In this case it might make it better to see endurance as the AVERAGE endurance of members of that species when a hunt is initiated. We could keep this in mind though and revisit it in a future part (yes I know I sound like a broken record when saying that).

Order of Calculations

A key question to ask ourselves here is, what order do we calculate predation changes? The problem is that predation calculations for one species will affect the overall calculations of other species. Do we calculate the predation of herbivores first, and then the carnivores? Do we randomly pick one species at a time and calculate predation on it and keep rotating until we’ve hit all species?

The solution I’ve gone for here is to calculate it simultaneously to starvation. Is this entirely realistic? Perhaps not, because it’s currently possible that a species is preyed on at the beginning of the month but still contributes towards the overall hunger and thus starvation of the species over the course of the entire month. However, it means we avoid having to worry about who to calculate predation for first which would be a HUGE hassle on its own, so for now I think it’s a worthy sacrifice.

We can visualize the current life cycle of organisms using the following Life Cycle Diagram:

So the way it works is we start with the initial population, and we calculate the food it hunts and the number of individuals that are hunted first. Then the members who die from starvation and predation are killed off. From the survivors, offspring are born, and then some of those survivors also die of old age. The final group of survivors plus the offspring form the population of the next simulation step.

Demo

Now that we’ve ironed out all the additions of predation, let’s run a demo to see how things have changed.

Here are our Starting Conditions

image



The final populations of the species were:
Modelus Specius - 2,045
Minimus Rex - 70,679
Propagatus Maxima - 38,211

It’s good to see that the simulations have not become chaotic as I was worrying! It seems that the many soft caps we’ve introduced, such as intraspecific competition, interspecific competition, spatial population density, movement speed, and others have helped “cushion” major upheavals from disrupting the population numbers.

From looking at the graph we can see the typical rise in population until we hit the famine on the 22nd month, and then a big hit to the “herbivores” (Minimus and Propagatus). We can also see that once the shortage hits Minimus begins to outperform Minimus at being the dominant glucose-eater.

Meanwhile, although Modelus looks like he’s off the charts, he’s actually maintaining quite a stable population at several thousand members. He was also largely unaffected by the famine, catching essentially just as many prey in the 22nd, 23rd, and following months as he did before.

One thing that I noticed when balancing the simulation was that the predators are very overpowered at the moment. If I make them just even slightly more powerful than the prey in terms of speed or endurance, they will completely eat all the prey and then make themselves starve to extinction. The reasons for this are because perception and combat haven’t been implemented yet. The predators currently know where all prey are at at all times, and always win combats against them. They also suffer no deaths from intra-specific competition, only delays to hunting times. So the predators are extremely and unrealistically efficient. Once we implement these features, predators won’t be as omnipowerful and we’ll start seeing more realistic balances of numbers. Still, it’s cool to see that the predators are naturally forming a smaller proportion of the ecosystem than the prey, and are also reaching stabilized population numbers within 4 years of the simulation.

This part included some major changes, so get ready for some “bugfixing” sub-parts to come up in the next week or so if I run into any bugs or flaws with the implementation from this part. Anyways, it’s really cool to see these features making it into the algorithm and to watch the evolution get slowly and slowly more realistic! Now that we’ve got the basics of predation in place, stay tuned for the content we’ll be able to add next!


Summary

New Performance Statistics
Caught Hunts
Predation Deaths

New Traits
Acceleration
Body Mass
Endurance

Topics for Discussion

  • Comments and feedback are welcome!
2 Likes

Part 7.1: Understanding Predation

We implemented a big feature in the previous part, but I’ll admit the write-up was a bit rushed. There was so much coding involved in updating the script that when it came to writing the post I was ready to just post it.

But I think it’s important that we fully understand this model as we progress through building it. So to better explain the additions we’ve made, let’s do a sub-part to illustrate how adding predation has changed the model.

Bugfixes

Before we begin, one bug I caught was that I realized I wasn’t using the predator’s adjusted speed in calculating the time per hunt or success rate for hunts. Recall that the predator’s adjusted speed is:

Predator Speed * (Predator Acceleration / Prey Acceleration)

Essentially giving them a bonus or malus to their speed based on how much acceleration they have relative to the predator. This bugfix has greatly improved the power of predators in the predator-prey relationships.

Overview

First thing’s first, let’s summarize what was done in the last part. Besides the under-the-hood changes I had to make to the code to support predation, all we did was make two changes.

  1. Species can now predate on other species. This means that the fate of predators and prey are now getting tied together. If a predator does very well in hunting a prey, that could drive the prey to extinction, which would then cause the predator to go extinct. A predator would never want to over-hunt his prey.

  2. When a species predates on another species, he compares his speed, endurance, and acceleration to those of the prey. The comparison determines the success rate of the predator in catching the prey.

It’s these two changes that lay the foundation for predation in the algorithm, and will be used as the basis for adding in future features like Prey Selection, Parasitism, Scavenging, and more.

Types of Hunters

In order to create the equations we wanted, we categorized hunters into two types: Predators they are faster than their prey (Speed Predators), and predators that are not faster than their prey (Endurance Predators).

One change I’ve made here is that I’ve divided the outcome of the Speed Hunter success rates by 2. This is to represent the variability in hunting outcomes. Having an endurance that meets the average time per hunt likely won’t mean a predator will win 100% of hunts. In fact there will be a lot of variability with some hunts being shorter, some being longer, and only the average hunt having a length that is the average time per hunt. Thus it makes more sense if the predator’s endurance would actually have to be considerably higher than the average time per hunt to win 100% of them. With this change, they’ll need to have twice as much endurance.

The logic of this change was also applied to the success rate of Endurance Hunters.

Here’s a visual to represent these changes:

Problems with the “2 Types of Hunters” System

There is one problem I’ve noticed that this system introduces however. Since Speed Hunters and Endurance Hunters have their outcomes calculated differently, just a slight change in a predator’s speed can make it suddenly shift categories and dramatically change its survival. Sometimes, if the conditions are in a certain way, a predator actually performs WORSE by increasing their speed, since they switch from being an endurance hunter to being a speed hunter and the calculations give them a lower success rate. There are two ways I can think of to solve this:

  1. Hunting Spectrum. Make the hunter type a spectrum. Instead of a species being 100% a Speed Hunter or 100% an Endurance Hunter, we can allow for a range of combinations in between. Since we’re dealing with average speeds, average success rates, etc., we can say that on AVERAGE the species uses Speed Hunting X% of the time and uses Endurance Hunting Y% of the time.
  2. Fall-Back Option. Make Speed Hunters able to fall back to using Endurance Hunting if it gives them better success rates.

I ended up implementing both of these. I liked the idea of a Hunting Spectrum, because I didn’t like the sudden jump species were making from one category to another the moment their speed went a little higher than the prey. At the moment, if the predator’s speed is equal to or lower than the speed of the prey, he will use Endurance Hunting 100% of the time. If his speed is 50% higher than that of the prey, he will use Speed Hunting 50% of the time. If his speed is double that of the prey or higher, he will use Speed Hunting 100% of the time.

I also liked the idea of a Fall-Back option because it doesn’t make sense why improving speed should decrease the success of a predator. This now means that endurance hunting is the “default” for species, and evolving a higher speed than your prey simply offers you the option of using speed hunting if its more effective. I will have to do further research into why speed hunting often gives worse performance though.

Tying into the Algorithm

How does the addition of predation affect the overall process of hunting, acquiring food, and starvation deaths?

Predation simply adds an extra limiting step in the process of hunting. Recall that when we added food to the system, it introduced the ability for species members to die of starvation if not enough energy was consumed. Well since then we’ve been gradually increasing the possible factors that can cause a species to not get all the energy it needs, ultimately increasing the importance of Starvation Deaths. Implementing movement in part 3 introduced the idea of having to spend time to reach food, competition led to increases to time based on how many people were chasing the same food, and now predation adds the ability for prey to escape you if you are not fast enough. Since we’ve now added so many factors, let’s summarize the full “Hunting Breakdown” of all the steps that limit the success of energy consumption:

First a species determines how much total energy it needs and it divides it up into quotas between each prey based on how much it prioritizes that prey. This is used to calculate the Required Hunts for each prey. However, a species might require more hunts than there are prey, so required hunts is limited to produce the Available Hunts. However, an organism has to compete with other species and even members of his own species who could steal a prey before him, so the available hunts is limited by competition to produce the Uninterrupted Hunts. However, an organism may not always catch all the prey he chases if they are able to evade him, so the uninterrupted hunts is limited to produce the Caught Hunts (this is the step added by predation). Finally, the organism might not even have enough time in the day to perform the number of hunts he needs to feed himself, so the caught hunts is limited by the organism’s free time to produce the Completed Hunts. This final completed hunts value is what determines how much energy the species gets from that prey, and is used to calculate Starvation Deaths.

That was a big wall of text, so here is a visual:

In this diagram I focused on energy instead of hunts but it’s the same idea.

Think of the width of the bars representing the amount of energy at each step. The main pattern you can see is that each step reduces the final success rate of the species in getting the energy they need. The boxes to the right explain the limiting factors involved in that step. We can see that the amount of energy a species actually receives will almost always, without exception, be less than the ideal amount of energy they would need in a perfect world. That might not be entirely the case right now, but it will become more and more true as we continue to flesh out the algorithm.

This means species have many opportunities in evolution to better adapt to any one of the numerous limiting factors that are listed on the right-hand side. A good player will be one who can easily identify the factors that are limiting his hunting the most and plan what mutations would best respond to that for the short and long term.

For those who are interested, here is a sneak peek at a more expanded version of the “Hunting Breakdown” list. This is what it will look like once we’ve added more features to the algorithm (like perception and combat).

Order of Calculations

Before we move on to the final topic, I’d like to reiterate one more time how the order of calculations has been changed with the addition of predation. Here is a visual:

image

Predation and Starvation are calculated simultaneously. This means if a species has 100 members who require 100J of energy, but they only receive 50J, then 50 members die of starvation (assuming a starvation penalty of 100%). If 25 members are eaten by predators, this is further subtraced out of the remaining 50 members to leave 25 surviving members as the Intermediary Population 1.

This means that those 25 members who were eaten by predators still contributed towards starvation. What if all 25 of those members died at the beginning of the month? Shouldn’t the species have only suffered half as much starvation because it really only had to feed 75 mouths? Or what if the 50 members had died of starvation first? Then wouldn’t the predators have had a harder time finding the remaining 50 members and perhaps only eaten 15 of them instead of 25? This approach ignores all those possibilities and just has both starvation and predation occur at the same time.

I’m describing this again in case someone can find a flaw with this approach. I am worried that it is sacrificing some realism, but the alternatives were just far too complex and seemed to sacrifice even more realism. If you try to calculate predation first sometimes, you need to calculate starvation first other times to be realistic. You also then need to decide which species to calculate predation on first sometimes and which species to calculate predation on first other times. It becomes a whole Belgiuming mess, so “Simultaneous Calculation” was the best compromise I could think of.

Performance Stats and Traits

Now finally, we’ve explained what the changes were by adding predation into the model, and we’ve explained how these additions affected the rest of the model. But let’s take a look at a very significant but underappreciated feature that was added way back in Part 1, statistics!

We’ve been gradually piling up the number of Performance Stats and Traits in the game. It might get kind of easy to lose track of all of them. The “Starting Conditions” boxes have become pretty sizable with multiple images, and the Charts are so big now with so many Performance Stats I won’t always be posting them.

So in the interest of seeing how all the statistics tie together, and also cause it’s pretty cool, let’s make a tree of all the relationships between all of the traits and performance stats!

image


Legend:

  • Yellow boxes are Traits of the current species.
  • Blue boxes are Performance Stats of the current species.
  • Pink boxes are Traits or Performance Stats of any prey of the current species.
  • Purple boxes are Traits or Performance Stats of any predator of the current species.
  • Orange boxes are Traits of the environment.
  • Green arrows show proportional relationships (where an increase in the source leads to an increase in the target)
  • Red arrows show inversely proportional relationships (where an increase in the source leads to a decrease in the target)

Although the diagram can seem overwhelming at first, it actually contains a lot of cool information. For one thing, it contains all the current traits and performance stats in the model. Also, since it tells you what is calculated from what, it also essentially shows you the order of calculations!

The presence of pink and purple boxes on the chart representing stats from prey and predators show how the addition of predation has made species success a lot more dependent on the success of its prey and predators.

Orange boxes represent the features of the environment. Those boxes are the potential targets for change during climactic events like ice ages or global warming, and those variables will change when a species moves to a new biome. At the moment, the number of orange boxes is pretty limited. This will change as we introduce more features of the environment in future parts.

Another cool thing is that the yellow boxes represent all the potential targets for evolution for your species. These variables are the ones that will only change as a result of changes you make in the Organism Editor. They essentially represent the player’s input into the system. It’s through the manipulation of the yellow variables that the player tries to increase the survival and success of his species on his planet. In Episode 3 we will talk about how these Traits are derived from the designs of organisms the player makes in the Organism Editor.

Conclusion

That’s it for this sub-part! Thanks for reading, and hopefully this helped shed light on the recent changes to the system from adding Predation. Stay tuned to see what will be the topic for the next part, but I sense that it will be something interesting.