Crash Course in Population Dynamics

This page is a copy of Seregon's original thread on the archive forum covering the necessary information for understanding the game's population dynamics system. Important posts are marked with a heading, but all others have been preserved too.

# Important Post 1

Seregon:

In this thread (depreciated link) I've been explaining how the compound system will work (summarized here (depreciated link)). I'm now going to take one step back and explain how the compound system fits into the simulation of a community of species which inhabit a biome.

## Population Dynamics crash course

First though, I need to explain what I mean by population dynamics, as it's not something I expect many people will be familiar with. I'll try and give a crash course, but this sort of thing is taught in the final year of an ecology degree, if at all, so it's fairly advanced. The maths I'll use isn't quite as advanced, and you should have encountered most of it by the end of high school if you didn't drop maths. Note that units are very important in population dynamics, so I'll be paying a lot of attention to them. I'll give more reasons why when it's appropriate, but for now it's enough to say that the overall value for the rate of change of a population must be measured in individuals per unit time. I'm going to use years as the unit of time for now, but these equations can ussually be scaled to any time-scale easily enough.

The population dynamics of a particular species summarises all the influences on that species population level into a single rate of change, and we use this rate to calculate how that population changes at each point in time.

## Exponential growth

At its most simple a population is influences by just two factors: birth and death. Birth (b) is measured in individuals per individual per year, that is, the number of babies each individual is expected to give birth to annually, its effective unit then is 'per year', or year^-1. Death (d) can also be measured in individuals per individual per year, which represents an individuals average yearly chance of dying (effective unit: year^-1).

Now we combine these rates. Our population at time t is x(t) (unit: individuals), and our rate of change is dx/dt (individuals per year). Our first equation is:

dx/dt = b x - d x
dx/dt = (b - d) x
rate of change = births per year - deaths per year

This is an ordinary differential equation (ODE), which describes the rate of change of a variable according to its current state. In effect, the rate of change of a population can be written as a function of the current popoulation and the current time, where birth and death are constant parameters. Note that in our equation we don't use the current time, this is something we'll introduce much later.

dx/dt = f(x,t)

We can integrate this function to find the population at any time t. Given a starting population of x(0)=1 at time t=0, we can calculate:

x(t) = t0 exp(t (b - d))

I'm not going to explain how you integrate an ODE, becuase doing so very quickly becomes impossible as the equation becomes more detailed, so that in reality you almost never actually do an integration (and we certainly won't be able to in Thrive).

Instead what we do is simulate the progress of the ODE, or system. This means that you iteratively calculate the population x(t+1) at a future time, based on the population at the current time x(t), until you get to the time your interested in. The most basic method of doing this is the Euler method:

x(t+1) = x(t) + f(x(t),t)
x(t+1) = x(t) + (b - d) x

What we can see from this last equation is that the population will increase or decrease depending on the ratio of births to deaths. If birth rate is higher than death rate, population will increase, if lower, population will decrease. What perhaps isn't so obvious is how the population will increase or decrease. Becuase the rate of change is multiplied by the current population, the rate of change will be higher if the population is higher, so that growth becomes exponential (as hinted by the equation for x(t)), growing ever faster all the way to infinity:

Similairly, if death rate is higher, the population will decrease, ever more slowly, until it goes extinct (x=0):

As can be seen in the above equations, birth rate and death rate combine to define the population growth rate (r, unit: individuals per individual per year, effectively: year^-1) in a very simple way:

r = b - d

We'll use this simplification below.

## Carrying capacity

In reality, populations don't grow to infinity. That's becuase theres never enough resources to support an infinite population, in effect every population is limited to a particular carrying capacity (K, unit: individuals) within its environment. That is, the maximum number of that individuals which can be sustained indefinately. If the population rises above this capacity (which is possible), it will eventually fall again as individuals starve due to a lack of food or other resources. The equation for this is:

dx/dt = r x (1 - (x / K))

The first part of this equation (r x) is equivelant to our previous system (r = b - d; r x = (b - d) x), the second part (1 - (x / K)) is new. To see how it behaves it's easiest to calculate the value of dx/dt (= f(x,t)) for a few values of x, we'll assume for now that K = 1:

x = 0:
dx/dt = r 0 (1 - (0/K)) = 0
Theres no population to grow, so the population stays steady at 0.

x = 0.1:
dx/dt = r 0.1 (1 - (0.1/K)) = 0.1 r - 0.1^2 r = 0.1r - 0.01r = 0.09r
So long as r > 1 (equivelant to: b > d) the population will grow, albeit fairly slowly.

x = 0.5:
dx/dt = r 0.5 (1 - (0.5/K)) = 0.5 r - 0.5^2 r = 0.5r - 0.25r = 0.25r
This is actually the fastest rate at which the population can grow or decline (except when the population is far above the carrying capacity, which rarely happens in reality).

x = 1:
dx/dt = r 1 (1 - (1/K)) = 1 r - 1^2 r = 1r - 1r = 0
The population is at the carrying capacity, and will not grow any further.

x = 1.5:
dx/dt = r 1.5 (1 - (1.5/K)) = 1.5 r - 1.5^2 r = 1.5r - 2.25r = -0.75r
The population is above the carrying capacity, and will fall until it reaches that carrying capacity.

Now, it's also possible to see a few flaws with this model. For example, at x = K, f(x,t) = 0, no matter the value of r. In effect a population at it's carrying capacity cannot change, even if its death rate is far higher than its birth rate. This is becuase the model represents an over-simplification of reality. However, the model is still useful, and provides a few good insights:

## r- vs. K- selection

r-selected species are those which have a very high reproductive rate, but relatively short lifespans. They are able to quickly increase their population, especially after a disaster or other event destroys part of it. Conversely, they tend to die off quickly as well, so that when resources are scarce, their population will quickly fall to a lower level. In a chaotic environment, their population levels tend to continually rise and fall, without ever really stabilising. They tend to produce huge numbers of offspring, but make little to no investment in their survival (e.g.: small eggs with very little energy reserves, no parenting), which therefore have a very low survival probability. Effective reproduction relies on the sheer number of offspring produced, not their quality.

K-selected species are those which have relatively long lifespans, generally with a relatively large body size, and a relatively lower reproductive rate. Their populations are very resilient to change, and tend to react very slowly. This means that when disaster wipes out part of the population, it can take a very long time to recover. However, it also means they can smooth over the oscillations of a chaotic environment, holding their population relatively steady, without booming or busting as much as an r-selected species. They tend to produce a relatively small number of offspring, but invest significant effort in their survival (e.g.: eggs with large energy supplies, or in the extreme case of mammals and sharks the offspring are actually carried within the parent until they 'hatch', extended parenting), so that each offspring has a much higher chance of survival. Effective reproduction relies on the quality of offspring, and each one is fairly precious.

## Equilibria and stability

This model has two equilibrium points, extinction (x* = 0), and population saturation (x* = K), x* represents an equilibrium value of x. This means that for most parameters values (exception: r = 0), the population will approach one or other of these equilibria depending on the parameters, and initial conditions (x(0)), as time increases to infinity. Equilibria can be described as either stable or unstable (or occasionally semi-stable, or even neutral, but that's for a later lesson).

Crudely, stability is defined as: if, when simulated in forward time, a point near x* remains near x*, or converges to x*, then x* is considered stable, (also called an attractor). If the point diverges from x*, x* is considered unstable (also called a reppeller). Note that in more complex systems the point can travel a very long way away from x* before returning and eventually converging, but for most of the examples we'll use it'll be fairly obvious whether an equilibrium is stable or not.

If r > 1, extinction (x*=0) is unstable, and population saturation (x*=K), is stable. If you start with 0 population (x = 0 = x*), then you will always have 0 population, however, if you have even the tiniest fraction more than 0 (e.g.: x = 0.000001 > x*), then x will diverge from x*, the population will grow up to the carrying capacity, and therefore extinction is unstable. Similairly for population saturation (x*=K), an initial condition of x(0) = K = x* will neither grow nor decline, but any other value of x (> 0) will eventually converge on x* = K, so that x* = K is a stable solution, which attracts nearby trajectories.

## Summary

That's enough math for one day, hopefully most of it made some sense. If not, let me know and I'll try and improve my explanations, also let me know if I'm going too slow. If anyone is especially interested let me know and I can tell you a lot more, as well as recommending a few good books. This (population dynamics), along with the math involved (nonlinear dynamics), is what I do for a living (for minimum wage, mind you :roll:), it can be absolutely fascinating, is an incredible tool for understanding nature and the world around you, and, sooner or later, will cause a complete brain-meltdown…

It can also be nicely summarised by one of my favourite quotes: "all models are wrong, but some are useful" (George E. P. Box)

Next lesson: I'll introduce a second species, and look at how predator and prey interact with eachother.

edit: replaced the figures with some of my own, for a more consistent style.

Mysterious_Calligrapher:

I have been meaning to get around to giving the forum a proper explanation of this for some time.

Seregon:

Ah, good to know someone else knows what I'm talking about. It's hard to know at what point what I've learnt stopped being common (atleast to scientists/biologists/ecologists) knowledge, so I may be starting too simple. There's a lot more to cover though, and things will get a lot more interesting, so I'll try and explain everything as best I can.

If you spot any errors, or think I've missed something, feel free to correct me.

Mysterious_Calligrapher:

Seregon wrote:

Ah, good to know someone else knows what I'm talking about. It's hard to know at what point what I've learnt stopped being common (atleast to scientists/biologists/ecologists) knowledge, so I may be starting too simple. There's a lot more to cover though, and things will get a lot more interesting, so I'll try and explain everything as best I can.

If you spot any errors, or think I've missed something, feel free to correct me.

I promise to go through the math very soon. I posted a simpler version some time ago, concentrating on trying to find an arbitrary limit of resources to determine the carrying capacities. Of course, that thread probably got eaten.

Speaking of which, what are your thoughts on determining the carrying capacity? I know how to do the math, but what size population do you think is feasible, programming-wise, considering that the majority of your species will exist only as a population count that occasionally has beneficial mutations?

Seregon:

I actually didn't plan on using a carrying capacity (not directly anyway). Rather than cap the population with an arbitrary capacity, I think we can limit it by using its dependance on the resources it needs. So, if we have a sunlight intensity (the original resource for most biomes, as discussed elsewhere we could equally use heat or certain chemicals) of x / m2 / year, and plants can only effectively capture and use that sunlight at a certain rate, then combined with a density dependant death rate there is a maximum number of plants that area can support… in turn, those plants can only support so many consumers, which can only support so many predators.

I suspect that wasn't a very good explanation, but I intend to develop pretty much exactly that system in the next post on predator-prey interactions (with a few modifications beyond the classical Lotka-Volterra model), so hopefully all will become clear.

As you say, considering that most of the population is just a number, there isn't really a limit (programming wise) to what we can do, except trying to be realistic. I tried to come up with some rough numbers just now as estimates, but it depends on too many factors (resource availability, biodiversity, competition, creature size, trophic level, succession stage, and more…). I hope that we'll be able to develop an equation, based on what I'll be posting next, which factors in all of these, without us having to come up with too many arbitrary parameters values.

~sciocont:

Excellent post. I've only just begun studying calculus, so I'm not yet able to fully look through the differentials, but I do have a general understanding of how differential equations work. The really important concepts there are the simplest ones: birth rate and death rate. Both of these are going to be partially set in the editor, then modified through the auto-evo process. The player/ computer will set in the behavior editor the general population survivorship curve curve for the species.

Remember that we measure time in generations: each generation, the computer takes each species and adds a constant number of offspring for each fertile female (or the offspring-bearing caste). This gives the actual number born that generation. Let's call it B for Births.
Then, at the end of generation 1, the computer cuts down that number of surviving members of that generation in accordance with the height of the survivorship curve at the end of the first generation. If the curve is at 90 percent of the original height, it multiplies B by .9. This would model regular exponential growth, by adding a number of births each generation, modeling birthrate.

To model deathrate, we simply track each generation until the survivorship curve reaches 0% and make sure that, by the end of each generation, the number of organisms from that species in that generation is in line with what the survivorship curve shows.

I'm making a few assumptions here:

1) The lifespan of any organism cannot be under two generations: this is to ensure that there is still a percentage left by the end of one generation, and that the organism reaches sexual maturity at least by mid-lifespan (because they only technically reproduce their population at the generation mark, regardless of when the player might see more being born). This minimum lifespan goes well with our minimum size of 10 cm.

2) Mutations (of the chosen organism or any in its biome that affect it) can only have two effects:
-To increase/decrease the birthrate (multiply B by a positive number)
-To increase/decrease the deathrate (multiply the percent remaining after each generation by a positive number)

3) A population consists of all of the organisms from all living generations in one species.

Hopefully that all makes sense. The only mutation that doesn't have either of the two described effects would be a modification of the survivorship curve itself.

# Important Post 2

Seregon:

Thanks. I basically agree that birth and death rates are the important part, and that they are whats evolved by auto-evo, but thats still a vast oversimplification of what we actually need to do (I'll be covering this in the next two lessons). As we've seen in the auto-evo discussion before, it's not enough to say 'species a reproduces faster', we need to know why (higher fertility, better survivability of offspring, more succesful feeding?).

Using the birth and death rate, and a survivorship curve, is a very good way of summarising a species population dynamics, it's just doesn't provide enough detail to get interesting auto-evo'd species. It's probably a good way to represent a players species fitness to them though.

I also largely agree with the use of generations, but more for use with auto-evo (for timing mutations) than reproduction. One of the nice things about ODE's is that we can simulate them over a period of time, and find out whats happening in that entire period, without too much calculation. i.e.: while we might only update population numbers every generation, the changes is the result of individuals born thoughout the whole generation. I'd also like to see different species able to reproduce at different times, but I suspect your definition of generation isn't as strict as mine, so that works anyway.

In effect what you say is correct, but I'm more interested in working out how particular mutations affect birth/death/survivorship, and how the traits which are mutated affect the population dynamics. More on that in a few lessons time.

Next lesson below, note that I wrote this last night, before reading scio's post above:

## Predator prey models

Right, now that we've covered some very basic examples, lets look at something more interesting. Rather than looking at one population, what happens when two interact?
The classic example is the Lotka Volterra Model, which deals with a predator (e.g.: fox) and a prey (e.g.: rabbit) species.

The equations are:
dx/dt = (a * x * y) - (b * x)
dy/dt = (-c * x * y) + (d * y)

Where a, b, c, d are parameters, x is the predator population, and y the prey population. I've chosen to name the variables x and y, but I could equally call them x(1) and x(2), which I will be using in future, but not for this example.

Theres actually a lot going on here, so I'll break it down into pieces:
(a * x * y)
This represents the increase in predator population as a result of it predating the prey. (x * y) is the encounter rate between the species, i.e.: how many times (per year) you can expect two individuals to meet. 'a' is the efficiency with which these predations are converted into more predator population (units: new individuals per encounter (individuals sqr) per year, effectively 1 per individual year).

- (b * x)
Loss of predator population via mortality, 'b' here is equivelant to 'd' in the exponential model in the last post (units: individual per individual per year)

(-c * x * y)
The loss of prey population due to predation, 'c' is the number of prey individuals lost per predation (units: 1 per individual per year). For readability, I would ussually define the ratio between c and a, rather than indivually defining them. So, rather than saying c = 0.8 prey individual dies per predation (not every hunt is succesful), and a = 0.1 predator individual is born (it takes a lot of food to feed a new infant), I would say c = 0.8, and A = a/c = 0.125 = 1/8 predator individuals are born per prey individual killed (A units: individual per individual). The above equations would then be:
dx/dt = (A * c * x * y) - (b * x)
dy/dt = (-c * x * y) + (d * y)

+ (d * y)
Gain of prey individuals from reproduction. In this model we assume that the preys reproduction is exponential, with no limitations.

The result looks something like this:

Whats immediately obvious is that the populations fluctuate. They don't increase to infinity, or decrease to extinction (though with different parameters, either of those are also possible - if the predators over-hunt the prey goes extinct, then the predators have nothing to eat and also go extinct. If the predators aren't able to eat enough they go extinct, and the prey is able to increase exponentially). Instead, the populations enter a stable cycle: when there are lots of prey, the predators have lots of food so their population increases; this increased predator population depletes the prey population, which crashes; the predators then don't have enough food, so their population also crashes, at which point the prey population can increase again. This cycle is stable, and will carry on for all time (given the assumptions we've made). Interestingly, the results of this very simple model can be observed in actual data for many predator-prey species interactions in reality.

I'd also like to introduce another way to look at this data, a phase plot, which plots the trajectory of a model against its variables, rather than time. This lets you see the population level of one species for a given population of another. It also shows you how the trajectory either approaches a stable equilibrium point, or as in this case, a stable cycle (other possibilities, such as chaos, also exist) depending on the the model, its parameters, and your starting variables (initial value).

Here we can see that, as expected, the phase plot is a cycle. Note that the trajectory here moves clockwise, which can be made clearer by adding flow arrows to show in which direction the phase trajectory will move at any point in phase space, and how fast:

From this we can also see that the trajectory flows much faster in the bottom and right of the plot, where the populations are decreasing, than in the top left, where they are increasing.

I've introduced these plots mainly out of interest, I'll be using them in future to illustrate more interesting points.

## Three species interaction

The main problem with this two species model is that we don't know where the prey gets its energy from, so to expand on it we'll add a third population, the resource (e.g.: grass), as a food source for the prey. The equations are very similair to those above:

dx/dt = (a * x * y) - (b * x)
dy/dt = (-c * x * y) + (d * y * z)
dz/dt = (-e * y * z) + f - (g * z)

As before, we have predators (x) reproducing by predating on prey (y), and losing individuals to mortality. We have prey reproducing by consuming the resource (z), and losing individuals to mortality from predation. An finally, resources reproducing at a constant rate 'f' (individuals per year) due to the constant energy input from the sun, and losing population to consumption by prey. We no longer have the potential for infinite growth, as each species now ultimately depends on the constant energy available from the sun for its population, and this energy is effectively shared between the species according to the parameters used (i.e.: how efficiently each species gets and holds onto that energy).

We can see here that there are no longer any stable oscillations, but rather that ther trajectories follow a damped oscillation before stabilising. Not quite so interesting as the previous model, but we'll fix that next time. Note that here the prey population is higher than the resource population, this isn't so realistic for rabbits and grass, but if we were intead looking at squirrels and oak trees it'd be far more reasonable. The phase plot shows the same information, but illustrates the lessening cycles:

I've only plotted the trajectory in the predator and prey axes above. It is possible to plot in 3D with the resource, but this actually makes the graph less clear.

## Summary

This three species model is a *very* simple version of what I'm trying to develop for Thrive, but it includes a lot of important elements. The population of each species is now capped naturally (by the suns input energy), not by an arbitrary carrying capacity. Each consumer species is dependant on a lower trophic species for its energy, and suffers predation from higher trophic species. And most importantly, the stable population of each species is dependant on the values of the parameters which define how efficient each predation process is, and these parameters are what could effectively be evolved by auto-evo.

Now, the parameters we have now (a-f) are far too simple to be of any real use, it doesn't really mean anything if a fox becomes more efficient at hunting a rabbit, we need to know how (is it faster, sneakier, stronger, better camouflaged, more toxic…?), so there's still a lot more to build on top of this… all in good time.

Next lesson time I'll be looking at seasonal forcing, and what happens when sunlight is no longer constant (i.e.: stronger during the summer, weaker in the winter). I'm also going to be working on a *very* simple example of auto-evoing the parameters above to give you a better idea what I mean… no promises it'll work though.

Please let me know what you think of these… are they too long, too complicated, too slow? If you think anything needs a better explanation or more detail, please let me know. You've probably also noticed I did a lot less analysis of the examples this time, this is partially becuase as the models become more complex, the analysis becomes much harder to do, but also becuase I'm actually far more interested in developing the models than analysing them. I also didn't want to go too overboard on the graphs, even if they are relatively small files. If you want more analysis though, I'll happily add more.

~sciocont:

You're doing brilliantly. These models are fascinating and you're explaining then extremely well.
as for our differences in generation:
The generation is simply a unit of time in which we allow evolution to occur. It doesn't mean that young are born only at the start of a generation, it just means that that's when we measure how many should have been born within that generation, whenever in actual time that they were born. We could have generations last an entire year on the planet, we could have them last a lunar cycle, etc. It's just an arbitrary unit of time that we give the computer to run through the Auto-evo process and decide who evolves what.

Remember that we add "mutations" to entire populations of a species when the species is chosen to evolve, so we're assuming every mutation was at some point beneficial, and spread to the entire population. We need to understand all of the effects of a mutation, both negative and positive.

I think, actually, that, since your population models are so intriguing, and seem to work so well, we can have it so mutations only directly affect the species mutated, and we don't have to estimate effects on other species arbitrarily, as I was planning to do.
So now, mutations can only increase the birthrate or decrease the deathrate of the chosen species, since a mutation spread to the entire species must be in some way beneficial.

Determining how they affect those two parameters is the hard part.

# Important Post 3

Seregon:

That's pretty much what I though you meant by generation, and actually works perfectly with what I had in mind. So, every generation, we update the population counts and run auto evo, based on information from the previous generation.

Using these models its actually very easy to see which mutations will be benificial, as well as by how much, so it should work very nicely for choosing benificial mutations and applying those (though there will be some randomness added). The models also *only* work with populations, they completely ignore the individual, which in our case is actually rather useful.

Actually, determining the effects on other species (within the same area/biome) is just as easy as determining the effects on the mutated species. However, as I remember the current auto-evo concept, species only react to mutations of other species in the previous time step, not the current one.

One thing I rather dislike about the models in the last post is how disconnected they are. Each species is affected only by its own parameters, whereas in reality they'd all be related. I think the easiest way I can explain the problem is that in the above model, energy isn't conserved. Taking just one interaction as an example:

dx/dt = b * x * y
dy/dt = -c * x * y

Which is the predation of y by x. If b is large and c is small, then we see a large rise in x's population for each y killed, whereas of b is smaller than c, we see a small rise in x's population for each y killed. The former is ok for something like a leafcutter ant predating a tree, the latter is more reasonable for most larger species (e,g,: for a lion, even a meal as large as a wildebeast will only partially feed a new cub). If we allow each species to evolve their parameter independantly, b will be maximized and c minimized, so that you get an unrealistically large increase in x for a very small decrease in y.

To make it more realistic, we have to make it a lot more complicated, by introducing a few new parameters:
s - the ratio of x's body size to y's body size (units: kg per kg, i.e.: none)
e - the efficiency with which x uses a kill (units: individual per individual, i.e.: none)
v - the proportion of hunts which are succesful (units: individual per hunt)
d - the proportion of encounters which lead to a hunt (units: hunts per encounter)

the equations now become:
dx/dt = ((e * v * d) / s) * x * y
dy/dt = -(v * d) * x * y

First, I should explain that this is still a simplification. 'v' encompasses many more parameters, such as relative speed, strength, stealth, toxicity etc. 'd' includes how sensitive creatures are, as well as how quietly they ussually move around, and perhaps how hungry they are. 'e' includes the proportion of y which can be digested by x, how effectively x defends its kill, how large a meal it can eat in one sitting, and how much of its own energy is used in feeding. 's' depends on a whole load of relatively obvious factors.

In effect, each of the above parameters is a compound parameter, itself depending on many more parameters. Both species have traits which affect all of these parameters. The prey species can, for example, evolve toxins to both reduce the success of hunts and make itself less digestable, reducing 'e', the predator can become more stealthy to increase 'v' and possible 'd'. Any changes to these traits will have effects on other areas of a species population dynamics, such as requiring more energy (or other resources), so every mutation has a trade off.

We've now also fixed the energy leak, though that's not immediately obvious. For a loss of 1 individual of y due to predation, x increases by 'e / s' individuals. 's' is easy to explain, as its the size ratio of of the two species, 'x' is 's' times bigger than 'y', so every individual of 'y' contains '1/s' times as much energy as an individual of 'x', so that the equations are ballanced in this sense. 'e' is actually an intentional leak (0 <= e <= 1), '1-e' of every kill is wasted, atleast by the predator, and lost, though we can add that waste into the environment for use by other species, such as detritivores.

… Now that I've written all that, I've forgotten what point I wanted to make with it. Something along the lines of the parameters for each species not being as nicely seperate as I showed above, but also that this doesn't actually matter, it's actually a good thing, as it makes the reactionary mutations we want in auto-evo automatic. If a predator increases its hunting effectiveness in one generation, the prey will be affected, and will be more likely to do something to reduce that hunting effectiveness in the next generation.

Finally, its not quite as clear cut as *only* being able to increase birth rate or decrease death rate, many mutations will change both, perhaps increasing birthrate and only slightly increasing deathrate. Looking back to the first post, remember that 'r = (b - d)', in effect, all mutations should increase r. This may also be a good point to say that r is one possible measure of fitness, something we've had a hard time calculating in the past, but may now be quite possible.

I've actually made some good progress writing a very naive auto-evo implementation using the three species model above. It's got a lot of flaws right now, but I know how to fix most of them, and will post some of the results, along with the next lesson, early next week.

~sciocont:

This seems good, having 'r' be changed instead of b or d. The only problem i can see is r being an oversimplified measurement, since certain interactions only affect b or d directly: mating and fertility affect b, predation and affects d and so on.
With the extra variables you have, (s,e,v,d) we can start incorporating compounds. So for e, we take the masses of each tissue in the prey species and multiply it by the efficiency of the digestion of the predator for each tissue. Whatever mass isn't digested comes out as waste.

Mysterious_Calligrapher:

~sciocont wrote:

This seems good, having 'r' be changed instead of b or d. The only problem i can see is r being an oversimplified measurement, since certain interactions only affect b or d directly: mating and fertility affect b, predation and affects d and so on.
With the extra variables you have, (s,e,v,d) we can start incorporating compounds. So for e, we take the masses of each tissue in the prey species and multiply it by the efficiency of the digestion of the predator for each tissue. Whatever mass isn't digested comes out as waste.

Not all the tissues: most of the nutrition lies in the muscles, organs, and marrow, so cartilage and non-marrow bone is just extra mass to most predators.

In addition, I would think that some things (like suddenly being able to process a new resource) would be very easy with this model, because they'd increase the birthrate, just by taking the assumption that there was more total food available. And being able to outrun your predators decreases the deathrate. Very elegantly done, Seregon.

The second oscillating model <i>does</i> represent carrying capacity, it's just an adjustable one based on the total of the resources there are available at the time. Notice that when there is a situation in which a food web, not a food chain, is being taken into account, the variation decreases greatly, because if one population (we're going to say rabbits) decreases, foxes will prey more upon other species, such as squirrels and mice. This ties in with what I've been pushing since day one here: an increase in biodiversity is an increase in the stability of the whole ecosystem.

~sciocont:

If bone and cartilage cannot be digested by one creature, it may be by another. For instance, heyenas can digest bone. It just means that they can harvest some nutrients from bone, and in this model it simply means that their bone-digestion ability is somewhere beyond 0: maybe .6 or so (1.0 being completely digestible)

Seregon:

~sciocont wrote:

This seems good, having 'r' be changed instead of b or d. The only problem i can see is r being an oversimplified measurement, since certain interactions only affect b or d directly: mating and fertility affect b, predation and affects d and so on.

This is really a question of how much complexity we want to present to the player. Seperating the effects of a mutation into those on birth and death would be useful, all I meant to say is that a mutation is benificial if (and only if) it increases r.

~sciocont wrote:

With the extra variables you have, (s,e,v,d) we can start incorporating compounds. So for e, we take the masses of each tissue in the prey species and multiply it by the efficiency of the digestion of the predator for each tissue. Whatever mass isn't digested comes out as waste.

Mysterious_Calligrapher wrote:

In addition, I would think that some things (like suddenly being able to process a new resource) would be very easy with this model, because they'd increase the birthrate, just by taking the assumption that there was more total food available. And being able to outrun your predators decreases the deathrate. Very elegantly done, Seregon.

This is *exactly* where I was going with this, so nice work figuring that out. I had intended to spend a few more lessons building up to this, but I guess we can skip ahead a little. The basic idea is that every possible interaction between species can be described as a transaction of compounds, and that if we know a species' population/fitness is being limited by a lack of compound x, we can fairly easily find an interaction, and a relevant mutation, which can increase that supply.

Mysterious_Calligrapher wrote:

The second oscillating model <i>does</i> represent carrying capacity, it's just an adjustable one based on the total of the resources there are available at the time. Notice that when there is a situation in which a food web, not a food chain, is being taken into account, the variation decreases greatly, because if one population (we're going to say rabbits) decreases, foxes will prey more upon other species, such as squirrels and mice. This ties in with what I've been pushing since day one here: an increase in biodiversity is an increase in the stability of the whole ecosystem.

Your right, effectively the carrying capacity here is 'f', the amount of sunlight energy entering the system, it's just not as arbitrary as in the previous model. The second effect you mention is related to prey preference: when a predator has a choice of multiple prey, it will hunt whichever is most abundant/easiest to catch/provides the most food etc.

Regarding biodiversity -> stability, there is some evidence (which I now can't find) that suggests that complexity (which isn't biodiversity, but closely related) can actually decrease system stability. It does lead to increased resilience (the ecosystem is more easily able to adapt and recover after a disaster), but left to its own devices its more dynamic, and won't stay stationary for very long. There are a lot of arguments either way though, and conventional wisdom agrees with you, we'll just have to see what happens in our system.

~sciocont wrote:

If bone and cartilage cannot be digested by one creature, it may be by another. For instance, heyenas can digest bone. It just means that they can harvest some nutrients from bone, and in this model it simply means that their bone-digestion ability is somewhere beyond 0: maybe .6 or so (1.0 being completely digestible)

My suggested solution to this is that anything which can't be digested is put back into the environment. Bones would be left at the carcass and available to scavengers, fibre and connective tissue would pass through the gut and be left in the faeces. This distinction probably isn't worth making in code, all we need to know is that there is x amount of undigested bone in the environment, and y amount of partially digested connective tissue.

We could make this system a lot more complicated by protecting some parts of the body from being accessed by most creatures. An easy example is bone marrow, which is digestable to almost any creature, but accessible to very few. We would then need to keep track of the amount of free bone marrow, the amount of bone marrow contained within bones, and probably the amount of bones not containing bone marrow. Doing this may or may not be feasible, but would add several more possibilities for auto-evo to act upon.

That's all from me for tonight, thank you very much for the encouragement and discussion so far, and expect another lesson (though I'm not sure you two need one!) and that naive auto-evo prototype in the next day or two.

~sciocont:

Your solution for non-digested material is what I was thinking of as well. This is why waste is so important.

I think differentiating between b and d is important in the mutation definition process. Pretty much all mutations are there to decrease d (stay alive). Only changes to the reproductive system should influence d directly. Since the d and b multipliers added by mutation multiply the values from the previous generation (values which have already been modified by environmental factors) we don't have the risk of generating increasingly higher values for them, as we would if b and d were based on some absolute scale.

I don't care to go all the way down into the bone marrow with this. What we've been discussing seems fine without introducing the restrictions on materials access. If we really need to do it, we should be able to implement it later. Let's just assume marrow is a part of the bone and thus can only be digested by those who can digest the bone in the first place.

# Important Post 4

Seregon:

I've left this topic for far longer than I meant to… I had promised another lesson, and a naive auto-evo prototype over a month ago, and they are finally included below. Partially I've been distracted with work, but also by trying to coordinate the programming effort, which has sapped some of my motivation for other aspects of Thrive. To make up for that, I'll be concetrating my effort on Thrive on the compound and population dynamics systems for the next few weeks, both of which I find far more enjoyable, so expect quite a few more posts here shortly.

From here on I'll be developing two things simultaneously. Firstly, I'll continue introducing and explaining population dynamics theory, as I have done in the previous two lessons. In part, this is becuase I think many of you will be interested, but understanding some of this will also greatly help you understand (and contribute to) how I'll be using this for auto-evo. Secondly, starting in this post, I will be developing and auto-evo implementation by applying this theory to what we know about how we want Thrive to work.

## Seasonal Forcing

Continueing on from my previous lesson (about 7 posts above this one) we ended with a three species model, representing a resource, a consumer and a predator. This is starting to look a lot like an ecosystem (though as Calli pointed out this is a food chain, whereas we eventually want a food web, with multiple species at each trophic level) with multiple species interacting with eachother, all eventually dependent on the environment (sunlight intensity). In another lesson I will look at expanding the number of species and their relationships (predation, competition, symbioses etc.), although how we do that should actually be fairly easy to imagine from what you've seen already. For now though, we need to look at the other half of the ecosystem: the environment, which up till now has been static. (Note that what we've considered so far, the collection of all species within an ecosystem, is known as the 'community')

In reality the environment is dynamic, with constantly changing levels of sunlight, dissolved nutrients, temperature etc. Building on the three species model, to keep things simple, we have only one environmental variable: sunlight intensity. Me and Scio had a long discussion over PM last month about how to calculate sunlight intensity for different lattitudes, times of year, times of day etc, but for the purposes of this lesson we'll keep it really simple:

S(t) = (1 + sin(t * pi * 2))

where S(t) is sunlight intensity at time 't', where one year corresponds to a change in 't' of 1. Effecitvely, S(t) is smallest when 't' is near a whole number (t = 0, 1, 2. i.e.: the start or end of a year), and greatest in between (t = 0.5, 1.5, 2.5, i.e.: the middle of a year). The results aren't particularly realistic, in the middle of winter S(t) = 0, and in mid-summer S(t) = 2, but they'll do for now.

EDIT - I've just noticed I should've used cos for this, as here we have summer around 0.25 and winter around 0.75, with spring at 0 and autumn at 0.5. That's not very clear, but it works fine for the simulation so I won't change it now.

Plugging this in to our previous three species model, there's only a small change, highlighted below:

dx/dt = (a * x * y) - (b * x)
dy/dt = (-c * x * y) + (d * y * z)
dz/dt = (-e * y * z) + f * S(t) - (g * z)

where 'f' is now the efficiency with which species 'z' converts sunlight into new individuals. The units to this are a little nasty: Sunlight intnsity can be measured as energy per unit area, ussually megajoules per square meter. 'f' then has units: individuals per (megajoule per square meter) per year, or square meter individuals per megajoule year. That doesn't seem to make much sense, so here's an interpretation: 'f' must incorporate both the number of individuals born per sunlight recieved (individuals per megajoule per year), and the area in which those individuals are being borne: given that 'f' isn't density dependant, we'd expect many more cells born in 100m2 than in 1m2. 'f' can then be described as a compound variable: f = A * g, where A is the area of our ecosystem (the area over which sunlight is being captured), and g is the efficiency with which this sunlight is converted to new individuals (individuals per megajoule per year).

## A note on notation

Remember from the first lesson that dx/dt is actually a function of x and t:

dx/dt = f(x,t)

where 't' the time at which we're calculating f, and it is this 't' that is used when calculating S(t). Additionally (I'm not sure if I've explained this before), it's worth mentioning that the 'X' in f(X,t) isn't just the population of species x, it's actually a vector containing the population of each species, such that the above equation becomes:

dx/dt = dX1/dt = f1(X,t) = (a * X1 * X2) - (b * X1)
dy/dt = dX2/dt = f2(X,t) = (c * X1 * X2) + (d * X2 * X3)
dz/dt = dX3/dt = f3(X,t) = (-e * X2 * X3) + f * S(t) - (g * X3)

The three functions (f1, f2, f3) can also be expressed as a single function:

dX/dt = G(X,t)

using matrix calculus rather than the scalar calculus above. That's not something I'm going to show below, and it's not really necessary. Whats important is that you understand that each population is part of a whole, and each equation has information about the whole community, not just its own population. I'll stick to the notation used previoulsy for readability, just remember the 'set' of equations we're developing can be expressed just as easily as a single equation.

Right… unintended detour over, what happens when we seasonally 'force' sunlight intensity? The three species model developed last time settled on a constant equilibrium state. We would expect that this model doesn't, as it's conditions are continually changing, so that the target equilibrium is also continually changing:

What we see is an initial period of stabilisation, as before, followed by a fixed oscillation. This oscillation is stable, and can be considered a cyclical equilibrium (technically a 'centre node' equilibrium, as opposed to the 'node' in the previous model).

What is interesting is just how chaotic the initial stabilisation period is. It looks rather unpredictable, with the prey population jumping from low oscillations to high oscillations. While the eventual stable oscillations are rather dull, this period of chaos before stabilisation could make things far more interesting. Importantly, this stabilisation process will happen any time the system is changed by an outside force, such as a disaster, or to a much lesser degree, a mutation.

## Density dependance

Introducing density dependance to the sunlight intensity term:

dx/dt = (a * x * y) - (b * x)
dy/dt = (-c * x * y) + (d * y * z)
dz/dt = (-e * y * z) + (f * S(t) * z * (1-z)) - (g * z)

changes the behaviour somewhat, with stabilisation being a little more interesting again, and taking much, much longer (over 500 years in this case), but the specific effects aren't quite interesting enough for me to explore here (I have more interesting things in mind!):

That's all the lesson for now, let me know if anything needs more explanation (I expect some of it does).

## Auto-evo

ow for the main event, my first, *very* naive auto-evo implementation. I'll make two disclaimers before you read much further: firstly, it doesn't really work, it has quite a few issues which I'm working on fixing, but it does show the basic idea. Secondly, I wrote the code for this, and produce the figures, over a month ago, so I'm a little fuzzy on how it actually works. Since then I've been working on a far more capable version, but as that's not quite done, and a lot more complex than this, I though I'd present the simple version for now.

## Equations

The equations used are those from the non-forced three species model, except that I've changed the parameter names to be a little more descriptive:

dx/dt = (p_x * x * y) - (m_x * x)
dy/dt = (-m_y * x * y) + (p_y * y * z)
dz/dt = (-m_z * y * z) + e - (d_z * z)

p_x is the number of individuals gained by species x from predation, and m_x is the number of individuals lost to mortality (either natural, or from predation). 'e' is energy from sunlight. Note that the graphs below have an error, p_z should be m_z, and d_z is mortality of the resource due to natural causes.

## Generations and parameter selection

The population levels are updated each generation, which in this case was 1 on the timescale, at each generation, each species also got to pick a mutation. The population dynamics you should be now be familiar with, so I won't say any more about it. To pick a mutation, each species looks at the fitness change which would result from changing each of its parameters. For example, species x can change p_x or m_x (for some reason, species z can also control e). To do this, it calculates the partial derivative of its own function (e.g.: dx/dt = f(x,t)) with respect to each parameter, e.g.: Df(x)/Dp_x. (note 'D' isn't the correct symbol here, but its the best i can do on a forum). I can't explain how partial differentials work here, but they're actually very simple, especially if you already understand ordinary differentials, so have a look at the wikipedia article for more information. In effect though, this partial differential tells you how changing a parameter will effect the rate of change of your population, or more simply, how a mutation to that parameter affects your fitness.

What happens next is fairly obvious, whichever mutation has the greatest effect on fitness is picked (if the effect is negative, the reverse mutation is applied). This is very simple, very crude, and exactly why this model is very naive, but it (sort of) works.

What you can see here (not very clearly) is that the predator increases p_x, the prey slightly increases p_y, then decreases m_y, and the resource decreases p_z (actually m_z) and then later d_z. As I said, this isn't clear, and it's been over a month since I produced it, so I can't explain it much more clearly. In short, each species does what it's expected to, but for the most part they only mutate one parameter, with only the resource switching to mutate a second parameter later on.

## Problems

The problem, as explained in a previous post, is partially that theres no cost to any mutations, benifits from predation are maximised, and penalties from mortality are minimised, wheras in reality theres only so far you can do so. Moreover, while I prevent the parameters leaving the range 0.05 < p < 1, the program doesn't actually detect when a parameter is at that limit, so that it continues to try and change that parameter, when it would be more benificial changing another parameter. Finally, it isn't realistically possible for a species to continually mutate one trait, as it will quickly run out of genetic diversity in that area; there should therefore be a penalty to how much you can mutate each parameter, dependant on how much it has already been mutated recently. All of these are issues I'm addressing in the next prototype.

## Results

These first two plots show the same thing, but at different scales. As you can see the predator population increases to a huge number, and oscillates around 200, whereas the resource appears relatively stable around 20, and the prey oscillates around 0.2. These are huge differences in population levels, and a direct consequence of having no costs associated with mutations. The prey is able to get a huge amount of energy from the small number of prey, keeping its own population high, and the prey population low. This low prey population doesn't do much to harm the resource population, which also stays relatively high. This is a neat (if very artificial) example of a trophic cascade where the abundance of predators indirectly increases the abundance of resources.

These two plots are again the same as above, but over much longer spans of time, showing that the system does eventually stabilise.

## Summary

All in all, the behaviour isn't that dissimilair to the earlier models, mainly becuase auto-evo only actually does something for the first 10 generations, after which the population is allowed to stabilise with somewhat different parameters than before. In reality, these mutations would take place much more slowly, and there would also be many more parameters to choose from, so that auto-evo acted for a far longer time span. Additionally, seasonal forcing as shown above would mean that the environment the species are adapting to would be constantly changing, so that selection pressure would act in different directions at different times. Basically, this has a long way to go before it becomes interesting, but I'm working towards that in the next prototype, which I hope to post sometime in the next week or two.

As usual, I'd be very interested to hear any comments or suggestions!

edit - forgot to mention, next lesson will be on age structured populations.

~sciocont:

Excellent post. With only a month of calculus under my belt I'm able to understand quite well what you're putting forth.
I'd suggest that we simply make each generation equal to one year, since in game time, you'll be playing through a representative sample of yearly conditions, so disparity in the transit time of planets doesn't have a huge effect on the length of a year in real playtime.

For those checking up on this thread, essentially what auto-evo is supposed to do is create a chaotic ecosystem. seregon's plots show that over time theoretical populations settle into stable oscillation- the goal of each ingame population is to break the stable oscillation by adding to its members. Therefore, We won't be seeing portions of even oscillation. Also (seregon as well) remember that the procedure for choosing species who are mutated is included already in the Auto-Evo documentation, so we needn't worry too much about who is getting mutated when right now, but on what effects the mutations will have. The best way to represent mixed and rife effects of mutation is to include many different parameters in the descriptions of organisms, so it comes as no surprise that the auto-evo right now is imperfect.

Seregon:

Thanks Scio. Good to know it's not too difficult to understand, I don't think the math gets much more complicated unless I start doing more in-depth analysis (which are nasty even for me, so I'll avoid doing so if possible). The only thing I may have to do at some point is use vector/matrix calculus instead, but I can give a very quick intro on that when needed.

I've been giving a lot of thought to how long generations should be, or more specifically, how often we should allow mutations. The major problem is this: if we have a generation be one year (for simplicity, lets say that year lines up perfectly with the year of the planet in quetion), then we'll always have a new generation at the same time of year. If that time of year is winter, we'll end up with a lot of species very well adapted to the cold, but not the rest of the year. That's not to say they won't suffer for it, the population dynamics are still calculated for the whole year, but the fitness benifit of mutations is (currently) only calculated at the end of each generation.

There are various solutions to this. The simplest is to have generations be much shorter (in earth terms, about a week would work nicely), and tweak down the mutation rates to be much lower. This has some pretty poor consequences in terms of computation, so isn't ideal. Its something we'll have to think about anyway at some point, when we decide what time scale the player will be experiencing, but this is something we don't need to figure out just yet.

The second option is to try and summarise the fitness benifit of a mutation across the whole generation. That's not exactly trivial, and I've spent a lot of time thinking about how it could be done. I'm not there yet, but I'm fairly sure it is possible, and I'm hoping to use it in the 3rd prototype in a few weeks time.

In terms of *who* gets mutated, I know we have a pretty good concept for working that out. For the time being, I'm assuming (for simplicity) that everyone gets to mutate every generation, and I'm only worrying about what they mutate.

As you say, they more parameters we have, the more complex the mutations can be, and the more diverse our species can be. I expect theres a limit to this idea, and an optimum number of parameters to use (especially when we consider computation). I am, however, certain that the 7 I'm using right now are no where near enough.

Regarding chaos and oscillations, it would actually be nice to see some oscillations, as that's exactly what we see in the real world. Those oscillations will tend to drift as species adapt, and some mutations may break them (sudden things like disasters could easily do so), but we shouldn't expect to see complete chaos. Given Thrive's much faster timeline for evolution, its possible that some timespans will be dominated more by chaos than oscillations, especially after a major disturbance, and that would also be nice to see. I should probably also point out that chaos and oscillations are not mutually exclusive, in fact the Lorenz equations, perhaps the most famous chaotic system, is a chaotic oscillator (better known as a strange attractor).

The Uteen:

Nice work. I don't understand the technical stuff (too many variables), but it's interesting nevertheless. Thanks for the updates.

~sciocont:

I am fairly familiar with the lorentz attractor, at least in general what it does.
The problem with generations lasting only a week is that the definiton for fitness changes seasonally, which means organisms will be constantly evolving to match the changes in the seasons, not evolving in order to outcompete each other. In another thread, we said that a year would equal about 30-120 minutes of playtime, and would probably include around 4-12 discrete "days" (or equivalents) that you'd play through. This means we have plenty of time for the computer to do all of the auto-evo calculations for your biome, and we could make mutations slightly larger. If we make generations equal to the length of a year in playtime, this will make gameplay slow down a little, but you won't be constantly dealing with changing and new information about your environment.

Seregon:

I can see what your saying, in that we want interspecies competition to be a major factor in driving adaptation, but that shouldn't be at the cost of not allowing species to adapt to their environment (and that includes the different seasons). Species interactions also won't be constant throughout the year, e.g.: competition for food will be far greater during the winter (which is why avoiding it by hibernating is a brilliant adaptation).

The timing you describe for generations (1 year, 30-120 minutes, 4-12 days) sound absolutely fine to me. Presumably, within that time you would be experiencing several different seasons (in our case, 3 days each of winter, spring, summer and autumn).

I think what we need is a way of having generations be long (i.e.: 1 year), but have the mutations which take place take account of conditions during the entire generation, not just the point at which the generation ends. It could be we need to tweak how things work to get a good ballance of environmental vs interaction factors for determining mutations.

Rorsten594:

~sciocont wrote:

I am fairly familiar with the lorentz attractor, at least in general what it does.

The problem with generations lasting only a week is that the definiton for fitness changes seasonally, which means organisms will be constantly evolving to match the changes in the seasons, not evolving in order to outcompete each other. In another thread, we said that a year would equal about 30-120 minutes of playtime, and would probably include around 4-12 discrete "days" (or equivalents) that you'd play through. This means we have plenty of time for the computer to do all of the auto-evo calculations for your biome, and we could make mutations slightly larger. If we make generations equal to the length of a year in playtime, this will make gameplay slow down a little, but you won't be constantly dealing with changing and new information about your environment.

about the seasons thing wouldn't you just be able to have adaptation for all the seasons? (rabbit have longer hair and white hair in winter than gray or brown in summer less hair)

~sciocont

Rorsten594 wrote:

~sciocont wrote:

I am fairly familiar with the lorentz attractor, at least in general what it does.
The problem with generations lasting only a week is that the definiton for fitness changes seasonally, which means organisms will be constantly evolving to match the changes in the seasons, not evolving in order to outcompete each other. In another thread, we said that a year would equal about 30-120 minutes of playtime, and would probably include around 4-12 discrete "days" (or equivalents) that you'd play through. This means we have plenty of time for the computer to do all of the auto-evo calculations for your biome, and we could make mutations slightly larger. If we make generations equal to the length of a year in playtime, this will make gameplay slow down a little, but you won't be constantly dealing with changing and new information about your environment.

about the seasons thing wouldn't you just be able to have adaptation for all the seasons? (rabbit have longer hair and white hair in winter than gray or brown in summer less hair)

Ideally, but that gets very complex. We'll have to see what we can do.

gdt1320:

Ok so contributing more ideas to develop a more chaotic auto-evo

So we need to decide what parameters the auto-evo can change,
the list from the wiki is
Quote :

size, mass, speed, type of movement, toxicity, toxic resistance, stamina, armor, specialized defensive organs, specialized offensive organs, camouflage.

(side-note: can we just have mass? size and mass are pretty similar)
and how they affect the growth and death rates.

I'd also like to introduce a food level that is a numerical value for how high up a species is on the food web. (again probably needs to be changed, but just for this idea I'll keep it)

Thoughts for modeling equations

So basically everything with the parameters is going to end up being a mass balance with probability mixed in there as well.

i.e for a growth equation
dX/dt = a*X*Y-b*X

a = (mass of Y/mass of X)*(%recoverable mass)*(Probability)*(food level X-food level Y)

Note how this equation can use the food levels to determine of X preys on Y, or if Y preys on X.
However, this greatly restricts interactions in that species on the same level have no interaction, and interactions can only be allowed for +- 1 food level, otherwise the multiplication factor is off.

The other note point is that there is mass being lost this way and it has to be recovered somewhere.

Expanding on the (Probability) term

So the probability is going to be the most complex term, it has to account for all the other factors, chances of encounter, etc. Here's an example of what probability could look like, but just an abstract one.

(probability) = k*[(f*speed X - e*speed Y)]

k is going to be a factor from 0 to 1. Think of it as the % of time X chooses to interact with Y.
f and e are co-factors to account for complex behavior. I.E. X might be really slow, but good at ambushing, so e is going to be very low (or f very high, or both), or X might have more stamina than Y, so f is slightly higher.
The other thing this contributes is that if Y is much faster than X, then X is just wasting energy pursuing Y, and might actually have a negative coeff even if Y is X's "prey". Toxicity could also come into account here with f having a (toxicity Y- toxic resistance X) and e having (toxicity Y-toxic resistance X)

Auto-Evo

Ok, so we've got what paramaters the auto-evo can change, and how they affect population growth, but no we have to decide what the relationships between all those variables are in order to produce a realistic model.

I'm thinking about balancing almost everything by mass so here is what that would look like:
mass=aa*(speed)+bb*(armor)+cc*(specialized organs)+dd*(toxicity)+ee*(toxic resistance)+ff*(stamina)+gg*(camouflage)

so breaking this down, it means that in order to have more speed, armor, or specialize organ, etc. the species needs more mass. Looking back at the growth equation

dX/dt = a*X*Y-b*X
a = (mass of Y/mass of X)*(%recoverable mass)*(Probability)*(food level X-food level Y)

we see that increasing the mass of X decreases the growth rate if mass of Y stays constant.

The factors, aa,bb, etc. , can be adjusted (or randomized at the start!) This gives different values for different evolution factors, where maybe one species favors camouflage, another favors speed, etc.

back to the k term

So the k term, the one I defined as the % of time X chooses to interact with Y, should also be an evolutionary parameter.

I'm still working out how to make it fit, but the idea was that species would "learn" to avoid predators, toxic species, etc, and also to make a better balance for multiple food sources.

The problem is that the auto-evo might try turning the k very low for predator species, such that prey "never encounter" predators, and are thus not affected, which is not realistic at all.

The balance was going to be that the sum of all the k's for X had to be 1. But I'm probably going to be rethinking this. Might just end up being a probability of encounter which will have to be calculated some other way.

Anyway just more thoughts, sorry I kind of babbled at the end there.

So what's the b factor for in the death term?

This will also be part of the auto-evo, but maybe in a more specialized way.
I was thinking of having this term hold on to the temperature effects (species die faster if too hot or cold), and also have factor's relating to specialized organs. This theory was that by having specialized organs, the species can be more prone to sever injuries that would cause them to die faster on the chance that they become injured.

Anyways, just more thoughts, and perhaps a different way to look at things.

MAJOR EDIT: I'm an idiot. I just read your (seregon's) post in the other thread. I'll see what I can do since mass and energy balances are sort of my thing.

gdt1320:

So i think evolutionary adaptations can be sorted into two categories, mechanistic and behavioral. Mechanistic would cover the species interactions with compounds. I.E. what it can eat, what it is toxic too, what it is resistant against, etc. behavioral would be how it interacts with members of its own species, and other species.

Mechanistic adaptations can be divided into two subgroups, direct and indirect.

Direct adaptations would be altering enzymes, and proteins to be more resistance at something (possibly through changes in amino acid sequences, or glycosylation steps), at the cost of efficiency.

Indirect adaptations would be the development of new compounds within the system to balance out some negative effect. I.E. developing an antidote that neutralizes a toxin or parasite. These would come at the cost of requiring more compounds, or energy. (Developing new limbs, or body parts could probably fit under this description as well)

I'm still looking into behavioral, because I don't know much about AI. But maybe parameters such as aggressiveness, awareness, socialization, would be a good key few.

Daniferrito:

gdt1320 wrote:

I'm still looking into behavioral, because I don't know much about AI. But maybe parameters such as aggressiveness, awareness, socialization, would be a good key few.

I've been thinking on this, and as i see it, a well programmed learning AI can be considered like a behavorial auto-evo. It will try to adapt, learning about new dangers and food sources. Of course, it it sees a new animal that it has never seen before, it will not know anything about him, probably dyeing the first times. But that happens in real life too. A newly introduced species usually has a good starting time because other species don know how to counteract him.

If you are concerned about letting the player choose the behavior, we could allow the player to modify the weights, and in turn allowing him to lower the learning rate in order to allow the artificial changes to stay.

scorpion268:

i know this is an old thread, and my graph reading and variable understanding on much beyond simple statistical line graphs (i think that is what they are called) is a bit rusty, but i have a few things that i feel were overlooked.

1. carrying capacity does not just affect a single environment but the world as a whole because of migratory species and other factors. thus energy flow is dynamic and diffuses across the world as a species migrates and some die in the other environment and therefore there is a fourth factor playing in the environment, energy intake from other environments.

2. also as life becomes more complex, the time it takes to reach the said carrying capacity in an environment changes because the larger an organism is, the more energy it needs to take in, which in some environments it is countered by complex autotrophs, but in others, such as a desert, there are less nutrients available to larger organisms. this adds a fifth, complexity of organisms in the environment.

3. also, as life dies, depending on the complexity of the decomposers in the environment, there is a varying time between the point that the organism dies and the point that the energy is cycled back into the rest of the environment from the decomposers. a sixth factor

4. finally, outside factors play an even larger role because areas such as a volcanic plain will be richer in nutrients than a typical plain because volcanic ash will settle overtime and add new nutrients. seventh factor.

Seregon:

Some good points scorpion, and it's probably about time this thread got revived, though I can't promise I'll do much work on it for atleast a little while longer…

1 - the models develops so far apply only to a single location, in game terms this could be a biome, or a subdivision of a biome. When fully implemented (and I will get to this in a future lesson), this location would be linked to other neighbouring locations, with some species able to migrate between them. To some extent, this will share the resources available to each location, between all locations, as you suggest. Depending on how much detail we go into, resources could also be moved between locations by other factors (especially ocean currents). Note that I mentioned I won't be having an explicit carrying capacity, but energy input into the system is effectively the same thing.

2 - I think your saying that the time taken to reach the carrying capacity depends on the energy available and the growth rate of the organism in question. If so, I think this is covered by r, the organism growth rate, which I did cover above. In most cases energy available won't have much impact on time to carrying capacity, only the size of that carrying capacity.

3 - Yes, energy/compounds from dead organisms will not be immediately available to reuse (except in the microbe stage). I had planned to deal with this by having an additional energy/compound pool (dead matter), which would be processed back into available matter by decomposers. Some organisms may also be able to process dead matter directly, depending on their digestive systems.

4 - Neighbouring locations with significantly different conditions will have a large impact on eachother. In your example, migration from the volcanic plain will bring a lot of energy onto the normal plain, making it far more fertile than it would be otherwise. With just two locations, and balanced migration, the effect is that both locations have conditions which are the average of the original conditions, but we will almost never encounter a system that simple.

scorpion268:

no actually i factoring in that the larger or more aadvanced an organism is, it usually needs more energy to sustain its self, bringing its carrying capacity down. sorry i pretty well badly worded it the first time around

what about photosynthesis bringing in more energy over time? will the amount of energy available slowly increase over time?

Seregon:

This is why I don't want an explicit carrying capacity. Instead, the limit to a populations size is the amount of energy available to it; if a more complex organism requires more energy, then the same amount of available energy will only support a smaller population.

The total energy available to a system is relatively constant, coming in as light and heat from the sun (though chemo/thermosynthesis may open up other sources). This energy is inaccessible to most organisms, except photosynthesising plants and cyanobacteria. In a system with no photosynthesisers there will be little or no energy available, as the total level of photosynthesis increases, the amount of energy which is usable to other organisms increases (as there are more plants which they can eat).

hypoxanthine:

sorry if ive missed the point but i wouldve thought that if you simulate lots of organisms and enable natural selection through genetic material and competition, the general population dynamics curves emerge spontaneously e.g. if you have predators and prey, youll get predator-prey cycles whether you like it or not. how are you proposing to force a population of organisms to follow some equations? All that needs setting is a maximum number of organisms limit which when reached changes the general reproduction-controlling parameters such that an organism can only reproduce once another one has died, and then you might want to weight what each organism contributes to this count according to their energy requirements (e.g. their maximum health since energy and health seem roughly approximate in the game) so that, say, one large organism being killed would mean that two smaller organisms could be born. Everything else is decided by mutation rates. At reproduction, every organism has a mutrate variable or two that seeds a random number generator to decide whether to mutate an organisms genome (a set of variables which should decide an organisms appearance and the structure of their neural network). Why is there a need for this 'auto-evo'? you set up the basic conditions for evolution to happen and it happens! you dont need to randomly select an organism from the entire population to mutate, thats overcomplicating things massively. would you not just rather have an extra variable for each creature? one number? i hope your argument wouldnt be to do with processing because it really wouldnt affect anything at all considering the AI you'll need among everything else (be thankful for the gift of compiled languages!)

Seregon:

Your right, but you are also missing the point. If all we wanted to do was simulate a small population of microbes in a petri dish, we could derive the population curves easily enough, just as you describe.

Whats being discussed here is how we would simulate populations *much* larger than we could feasibly do at the individual level. Agent based simulations get expensive quickly, especially if that's only a small component of what we're doing (rendering, AI, physics etc.), and would allow us to simulate perhaps a few hundred cells, or in later stages a few dozen animals and plants. The methods here would allow us to simulate whats happening to the populations which aren't immediately observable by the player, so that when the player moves into another area, those populations can be updated in a meaningful way (i.e.: not a clean procedural generation). The key is that the computational complexity scales with the number of species, not the number of individuals, so that we can simulate very large ecosystems in seperate biomes relatively easily.

hypoxanthine:

i was writing more in my post while you were reading it so you may want to go back and read it again.

but lets say, ok, we want to reduce the population on a planet to a few key variables along with a list of the species present along with their typical genomes, and then when i come back to it i can regenerate the entire planets ecosystem by throwing the information (along with the time thats passed since the last visit) into a few equations, and our task is to come up with these equations. i think thats the gist of it, correct me if im wrong. so why overcomplicate it? just use your logistic models to get a number for each species then scale them according to predator-prey and an overall carrying capacity. How are you planning on deciding how the species get distributed across the system? will there be a variable for each species which decides whether they get distributed uniformly, randomly or in clumps? stick them in their biomes? i havnt seen any pseudo-code being written so it isnt too clear.

as for evolution happening when you come back, i havnt seen anyone suggesting exactly how the genetic information will be stored for each species, what it will consist of, or even what the organisms will actually have? what AI will be used, which of its variables will be mutatable? how will the morphology and anatomy data be stored? how will this be mutatable? Before you talk about auto-evo, you need to talk about the organisms themselves because otherwise youre just vaguely speculating and its not really any help. if you knew all this, you could just say: right, when i come back, mutate every single species genome a number of times dependent on the time passed since last visit, and then simulate all the agents in fast-forward so that natural selection has a chance to do its work, and then show the player the results and continue from there as normal. agent-focused evolution for a single planet will not be computationally expensive at all (the fact you think it will suggests youre not really sure of how it will actually work). how many creatures are you really simulating for each planet? you really think something like the amount in real life? they didnt even manage that in spore! just make the planets small and give them, say, 50 organisms for each of 6 possible species living on a planet. any more than something similar to that and youre trying to outdo spore (cant remember the actual organism limit on spore but i remember that after it, if you tried to add another creature, another one would disappear). hint: you cant outdo 5 years of professional developer's (the best in their fields) work.

Seregon:

I can't answer every point your raising, there are too many, and they're not all related.

hypoxanthine wrote:

i think thats the gist of it, correct me if im wrong. so why overcomplicate it? just use your logistic models to get a number for each species then scale them according to predator-prey and an overall carrying capacity.

That's the basic idea. The problem is deriving growth and mortality rates from our species geno/phenotype. If that was trivial, then we'd simply plug that in, but it's not. While we could make a very crude attempt, the resulting simulation would be incredibly bland, with many hugely different organisms behaving in almost identical ways at a population level.

hypoxanthine wrote:

how many creatures are you really simulating for each planet? you really think something like the amount in real life? they didnt even manage that in spore! just make the planets small and give them, say, 50 organisms for each of 6 possible species living on a planet. any more than something similar to that and youre trying to outdo spore

This is exactly what we are proposing, and exactly why agent based simulation won't do. That small size of spores ecosystem is one of the major points we want to improve upon. The space your playing in may not contain many more organisms or species, but the overall planet will.

hypoxanthine wrote:

hint: you cant outdo 5 years of professional developer's (the best in their fields) work.

No, we can't, which again brings me back to the point of all this. We cannot create an agent based simulation which is significantly more efficient than what spore had, what we can do is avoid the problem completely by not requiring a huge agent based simulation. I've written enough such simulations to know that the 300 or so creatures your saying a spore world contained would be pretty close to the limit of what an average computer of the time could run. With some clever programming (which we probably can't beat) they may have increased that a little.

Auto evo serves a similair purpose - we cannot afford to simulate darwinian evolution, so we make simplifying assumptions (explained elsewhere, I'll find a link if you need it):
- all individuals in a species are phenotypically identical. Sub-populations may vary slightly, and if the difference becomes signiciant they become a new species. What we don't do is track the genetics of every individual. We therefore do not 'mate' individuals to produce offspring.
- we assume natural selection. In other words, we assume that only benificial mutations will survive, and negative ones will not spread through the population.
What this means is that we don't need to run a genetic algorithm with hundreds of individuals, but instead run a much simpler hill climbing algorithm with dozens of species.

The details of what will be mutated, the genetic structure of the organisms, is a little irrelevant at this point. It certainly won't be as simple as 'predation rate' and 'mortality' mentioned in the examples. Beyond that, I don't see how what we're evolving will have that much effect on how we evolve it. There are some exceptions, but I don't think that's what your trying to get at?

hypoxanthine:

Seregon wrote:

That's the basic idea. The problem is deriving growth and mortality rates from our species geno/phenotype. If that was trivial, then we'd simply plug that in, but it's not. While we could make a very crude attempt, the resulting simulation would be incredibly bland, with many hugely different organisms behaving in almost identical ways at a population level.

why not KISS and just give each species a [slightly randomized if you like] growth factor (r) based on its maximum health/energy? Why is it a problem?
ok thats fine that—wait a second:

Seregon wrote:

Auto evo serves a similair purpose - we cannot afford to simulate darwinian evolution, so we make simplifying assumptions (explained elsewhere, I'll find a link if you need it):
- all individuals in a species are phenotypically identical. Sub-populations may vary slightly, and if the difference becomes signiciant they become a new species.

and that isnt bland? …hang on…

Seregon wrote:

all individuals in a species are phenotypically identical. Sub-populations may vary slightly,

struggling to get my head around this. if all species are phenotypically identical, how do subpopulations vary? but yes, i did say before that the data stored for each species should be the typical genome and its population count. what 'typical' might mean here is that you randomly select one creature and make that genome the archetype (taking an average is too much work). now i know that no known creature is distributed according to the cauchy distribution but i dont think it would matter too much.

Seregon wrote:

we assume natural selection. In other words, we assume that only benificial mutations will survive, and negative ones will not spread through the population.

so the rich get richer? thats not how evolution works, you know it, and it certainly doesnt take into account genetic drift which is one of the most important factors unless you have a very large population size, which we cant have (wait on!). You can't just say 'even though you can only see a few creatures from where you are now, this planet actually has hundreds of them whose population is controlled by these equations.' because your sample must reflect the actual planetary population size , at which point things start getting more and more complicated because you also have the question of distribution across the plant and biomes, and we should say to ourselves 'stop! is there an easier way to do this?'.

Seregon wrote:

What this means is that we don't need to run a genetic algorithm with hundreds of individuals, but instead run a much simpler hill climbing algorithm with dozens of species.

ok, sounds like a plan. ive seen GAs approximated using hill-climbers before (written a few myself…in cryptographical contexts but still…) but tell me how you propose to go about this. saying your going to use a hill-climber to evolve dozens of species doesnt tell me much. what type of hill-climbing are you using and why? what are you using as a measure of fitness and how will this be interpreted as a final genome? this is incredibly vague. please could you provide some pseudo-code, even if its not very detailed? ive noticed that nobody seems to give any such details on the forum, no wonder the programming is slow. they have to work out how to implement your ideas because you wont tell them how.

Seregon wrote:

The details of what will be mutated, the genetic structure of the organisms, is a little irrelevant at this point.

scorpion268:

If we were to take the entire world of the game and only take a chunk of the continent your species was on and fully process the biomes your species was in and the ones that were surrounding the ones that were surrounding the one you were in we could cut out a lot of processing time. Then if we used population pyramids with proportional populations like 15 prey per predator and have multiple species per level competing for dominance, then we could have a much more diverse world than before with the same processing requirements as before in my beliefs at least.

Seregon:

hypoxanthine wrote:

This part of the game could be tested stand alone right now if anyone had the time, and you divulged your secrets.

If you believe I have secrets I'm not divulging, then either you think this system has more merit than your willing to admit, or I'm doing a very poor job of explaining myself.

Yes, there are details of this which reside only in my head, not becuase I'm trying to deprive anyone of them, but becuase they take a huge amount of time and effort to develop to a stage where they're presentable and usable by a coder. That means doing the math, writing prototypes, and tweaking them, to save others the effort. Thats time I really don't have to spare right now, though it definately is something I'll be working on as soon as I do.

- All members of a population of a species (rather than the entire species) are phenotypically identical. Each seperate location which contains this species will have a seperate population. If these are significantly distinct a new species may form. If they are strongly linked by migration, they will tend towards the same genetics via crossbreeding.

- We don't track the genome, only the phenome, which is what makes the above assumptions plausible.

Quote :

so the rich get richer?

- Where did you get that idea? What this means is that the entire population will gain benificial mutations. Non-benificial mutations may arrise at the genetic level in a few individuals, but those individuals would be at a disadvantage and die out, so that the harmful gene will never spread to the population. At the phenotypic population level, these harmful mutations would never be seen, and so are ignored. The exception is where a mostly benificial mutation has some harmful side effects (e.g.: sickle cell), and these should be allowed by the system.

Quote :

- I really don't have the time to produce something like this on demand, and you have no right to demand it.

It would also help me explain this if I knew where you were comming from? Are you a programmer, biologist, ecologist, evolutionary scientist?

Also, please finish your post before posting, having what I'm replying to change while I'm writing a post is more than a little confusing.

@Scorpion - that's part of the idea, and largely what we're doing for the part of the planet observable by the player, this thread deals with what we do for the rest of the planet, rather than simply leaving it paused while the player isn't looking.

hypoxanthine:

Seregon wrote:

i can see why youre saying this, i know im coming across as rude and im sorry about it, but seeing as how the thrive project has ignored reason in the past, its the only way that will do. just be clear that i dont mean to insult anyones intelligence.

Seregon wrote:

If you believe I have secrets I'm not divulging, then either you think this system has more merit than your willing to admit, or I'm doing a very poor job of explaining myself.

the second one.

excuse 1)
Seregon wrote:

Yes, there are details of this which reside only in my head, not becuase I'm trying to deprive anyone of them, but becuase they take a huge amount of time and effort to develop to a stage where they're presentable and usable by a coder. That means doing the math, writing prototypes, and tweaking them, to save others the effort. Thats time I really don't have to spare right now, though it definately is something I'll be working on as soon as I do.

fair enough, dont have the time. perfectly fine.

excuse 2 and 3)
Seregon wrote:

Quote :

- I really don't have the time to produce something like this on demand, and you have no right to demand it.
It would also help me explain this if I knew where you were comming from? Are you a programmer, biologist, ecologist, evolutionary scientist?

I read that all as 'It would take too long to explain. Who are you to tell me what to do you little upstart! Also, I would explain but you probably wont understand it' (ok thats being a little unfair ill admit, but the rough idea is in there). I'm a programmer and a biologist (ecology and evolution come under biology, no? im not a specialist but i do know my stuff) since you asked.

now you misunderstood my request for pseudo-code completely. Given that you said you had an algorithm for auto-evo, all i was asking is for you to reveal it to me. If you cannot reveal it to me, you do not already have an algorithm, which means that you were basically saying 'ohhh…well do it all with a hill-climber' (reminds me of procedural generation here) without having an idea as to how youll do it, which is very bad indeed. I'm not asking you to produce it on demand, because unless your'e BSing, you already have it and should be able to show it to me without any difficulty, unless of course, youve been discussing this for 2 years (i think?) and you havnt ever bothered to write a scrap of pseudo-code for it.

Seregon wrote:

Quote :

so the rich get richer?

- Where did you get that idea? What this means is that the entire population will gain benificial mutations. Non-benificial mutations may arrise at the genetic level in a few individuals, but those individuals would be at a disadvantage and die out, so that the harmful gene will never spread to the population. At the phenotypic population level, these harmful mutations would never be seen, and so are ignored. The exception is where a mostly benificial mutation has some harmful side effects (e.g.: sickle cell), and these should be allowed by the system.

you dont seem to have read the paragraph at all. im not going to repeat myself.

Seregon wrote:

All members of a population of a species (rather than the entire species) are phenotypically identical. Each seperate location which contains this species will have a seperate population. If these are significantly distinct a new species may form. If they are strongly linked by migration, they will tend towards the same genetics via crossbreeding.

ah that makes more sense, but sounds like youre overcomplicating again. why split each species into subpopulations? and you were just talking about processing problems too! having subpopulations would basically be the equivalent of having many more species on the planet and is, in general, a very bad idea which gives me reason to doubt the consistency of your ideas.

Seregon wrote:

We don't track the genome, only the phenome, which is what makes the above assumptions plausible.

em..the genome is the same thing as the phenome for the purposes of the game but it is generally called the genome in these sort of simulators, which brings me back to my point on how an organism's genome will be encoded and why you should be discussing it now before auto-evo. e.g. part of the genome may say something like 'this organism has weapon part number n at body coordinates (x,y,z)' or something similar, and I have no idea what you thought instead (the fact you didn't immediately see this really worries me, how could it be otherwise? this is why i think i havnt understood you correctly.). How the data is encoded strongly influences how you evolve it.

scorpion268:

Ok that makes a lot of sense along the species diversity level. Just to be sure I'm understanding this correctly, there will be more than six organisms per biome.

Mysterious_Calligrapher:

Guys. No fighting on the thread. Hypo, that's not what Seregon said, putting words in his keyboard is a good way to come across as rude.

Hypo, I'd like you to re-read the first post in the thread, and the threads for auto-evo here (depreciated link) and here (depreciated link). (The first one is more programming based, the second has some of the early explanations as to why we came up with auto evo.) They might help you to understand what Seregon isn't getting across to you.

As to why we need auto-evo, the simple explanation is that it's a pure numbers calculation that allows us to simulate extinctions, ecological niches, biomes, and single-species extinctions without hard-coding actions. We will just let the numbers run instead, saving a lot of processing time while still allowing us to run conditions for a lot of species at the same time.

As for the other points, we've got a policy around here of if you think we're not coding fast enough, you can code it yourself, faster. Somewhere deep in the belly of the biomes discussion we've got some food-chain mock-ups that take a look at how we're going to have to run population mechanics when resource availability and predation are both taken into account.

Since you said you were learning biology, just something from an earlier post:
hypoxanthine wrote:

All that needs setting is a maximum number of organisms limit which when reached changes the general reproduction-controlling parameters such that an organism can only reproduce once another one has died, and then you might want to weight what each organism contributes to this count according to their energy requirements (e.g. their maximum health since energy and health seem roughly approximate in the game) so that, say, one large organism being killed would mean that two smaller organisms could be born.

Not quite how it works, but you’re close. Populations generally enter a “boom and bust” cycle, where they overshoot their carrying capacity, die back in large numbers, then slowly build their population back up. This is one of the driving forces of evolution, because the boom allows for greater genetic diversity within the species, and the inevitable bust trims down the population to the point where even small adaptations are a great adaptational advantage. By allowing the population to boom past it's carrying capacity, we can automatically simulate a mini-extinction event, which opens up niches for other species to diversify.

The "maximum number of organisms," as written here, would be overly simplistic given trophic level energy flow and entropy. Essentially put, when producers (plants) use 1000 units of energy to build their mass, a much smaller amount is available to primary consumers, and an even smaller amount to secondary consumers.

In addition, some resources, both nutritional and otherwise, will not be available to all species, just ones with the appropriate adaptations, so instituting a collective, biome-wide carrying capacity would be nearly impossible if we still wanted to run said adaptations, which are currently being discussed in the organ editor thread. And we very much do want to be able to run said adaptations, and to simulate extinctions.

~sciocont:

Hypox, I believe at some point, you were prompted to read our evolution concept. If you haven't seen that page before, we've failed to initiate you properly int othe project.
The question of population dynamics exists to give information to the Census step in the evolution procedure. Questions of what mutations are beneficial and how information is stored are tangential to the actual determination of population sizes.
Some things that may not be clear to you:
-All evolution happens on a local, not planetary scale. The planet is split up into separate biomes, which are self-contained game spaces for evolution. We may include organisms that move in between biomes, but if it is too complex for us to handle, we won't include them.
-Populations of organisms are just numbers. If there are 100 bears in a biome, the game does not store 100 instances of the bear and populate the biome with them. The population level simply influences your chances of seeing that organism: once an organism model is outside of your perception, it is deleted and won't necessarily show up there again, unless it is a stationary organism like a plant or a nest of eggs, or the organism you saw is specifically tied to that area by its behavior, in which case you'll see it pretty much every time you're in the neighborhood.

Also, rather than grilling Seregon about his expertise when he has little time to respond (He's currenlty working on his PhD in theoretical ecology, so he's essentially the best person in the world for this job), why not make some of your own suggestions to the problems you see, since you claim to have some degree of expertise. I don't mean to say that you aren't qualified to discuss this, I believe you are, but I am wondering why you're focusing more on criticism than construction. I am certainly happy to see you interested in this rather technical area, I'd just like you to understand that Seregon and I do not mean any disrespect towards you and are confused as to why your tone has been rather unfriendly.

hypoxanthine:

Mysterious_Calligrapher wrote:

Hypo, I'd like you to re-read the first post in the thread, and the threads for auto-evo here and here. (The first one is more programming based, the second has some of the early explanations as to why we came up with auto evo.) They might help you to understand what Seregon isn't getting across to you.

oh don't worry ive read those before. doesnt answer anything. it gives a framework and then doesnt address any of what ive asked about here, in fact its mainly about the process of fitting a creature to a biome.

Mysterious_Calligrapher wrote:

As to why we need auto-evo, the simple explanation is that it's a pure numbers calculation that allows us to simulate extinctions, ecological niches, biomes, and single-species extinctions without hard-coding actions. We will just let the numbers run instead, saving a lot of processing time while still allowing us to run conditions for a lot of species at the same time.

yesssss, i gathered that.

Mysterious_Calligrapher wrote:

As for the other points, we've got a policy around here of if you think we're not coding fast enough, you can code it yourself, faster.

not quite sure why youve said that. after my exams i will. said this. im not inciting anybody to do any coding. im inciting people to come up with pseudo-code, so that when they/you/i come to code it, we know what were meant to be coding.

Mysterious_Calligrapher wrote:

Since you said you were learning biology, just something from an earlier post:

, yeahhh, this whole paragraph very patronizing. Don't worry, I know how to model populations and I think everyone here knows about trophic levels and r-k selection. Like the first thing you ever learn in ecology when youre about 9. the reason for my simple suggestion was to keep it SIMPLE: a rudimentary carrying capacity type constraint which very roughly takes account of energy requirements. no need for anything else until youve actually got the thing up and running and then you can tune for accuracy. thats what should be happening. i see though that while we wait for progress there is nothing to do but discuss minutiae.

Mysterious_Calligrapher wrote:

Populations generally enter a “boom and bust” cycle, where they overshoot their carrying capacity, die back in large numbers, then slowly build their population back up.

generally what happens? not really, some creatures do and some don't. depends on the growth factor and obviously also on predators.

Mysterious_Calligrapher wrote:

In addition, some resources, both nutritional and otherwise, will not be available to all species, just ones with the appropriate adaptations, so instituting a collective, biome-wide carrying capacity would be nearly impossible if we still wanted to run said adaptations, which are currently being discussed in the organ editor thread. And we very much do want to be able to run said adaptations, and to simulate extinctions.

. see your point. if you must take this into account, why not calculate a carrying capacity for each species as auto-evo is being run? some threshold based on the parts the species has (which indirectly takes account of resources available to that species) or more effectively, have one carrying capacity for each biome and then multiply the one in question by some factor proportional to the area that the biome encompasses. if you use this, you can just model each species with a simple logistic function and then calculate K beforehand by looking up the base value for K for that biome in an array then multiplying it by the area of that biome. e.g. base value in ocean might be 4 creatures/m^2 and for desert, maybe 0.2 creatures/m^2 (im just saying some numbers dont shout at me). simple solution. tell me why you arent doing this.

~sciocont made a post while i was writing this so hello!

~sciocont wrote:

Populations of organisms are just numbers. If there are 100 bears in a biome, the game does not store 100 instances of the bear and populate the biome with them. The population level simply influences your chances of seeing that organism: once an organism model is outside of your perception, it is deleted and won't necessarily show up there again

clearly not read my previous posts. i understand this perfectly, but this sounds like you read my first post on this thread and left it at that.

~sciocont wrote:

you were prompted to read our evolution concept.

Of course Ive read that. Doesnt tell you anything that isnt obvious. I can sum it up in a sentence: randomly decide if there was a mutation for each species with probability scaled by proportions of species and trophic levels, then randomly mutate them. Of course, it doesnt say (as ive been saying) how you are going to mutate a creature. What are you actually changing in a mutation - how is the data encoded for the umpteenth time? It also doesnt say how you intend to scale the probability. theres no pseudo-code, just vague instructions.

~sciocont wrote:

confused as to why your tone has been rather unfriendly.

rants sound unfriendly. its in their nature.

~sciocont:

I assumed you had read that, but I wanted to make absolutely sure. I've read your posts closely, but I like to make my own posts as succinct as possible, so I didn't go much further.
Why don't we have code? We haven't had coders working on this because it's of secondary importance to getting the game engine running, which is what our coders have been working on. Seregon has been working on real-world objectives and anyone else on the forum, with the now advantageous exception of yourself, has been underqualified to discuss the deeper questions you're asking, such as how we will store organism data. You won't find answers to some of your questions because you're the first one around here who's had the understanding to ask them in a meaningful way. It's not that the rest of us haven't thought of them: everyone here knows that we will have to have a fairly modular way to encode organisms, but no one who has the programming knowledge to provide meaningful answers has been working on the task.
I'm really glad you're interested in this, and I'd suggest you make your own concept of how population dynamics (or whatever else you're interested in solving (I'm well aware that you have been making suggestions throughout this thread, and many of them have been quite helpful)) so that we can make progress, rather than just squabble over details that often prove difficult to express coherently in this discussion format.

Daniferrito:

Creatures will just be a conglomerate of organs. Internal organs, like digestive system, and external organs, like legs. They all affect their interaction with the environement. For example, better legs will make it able to run faster so it is easier to hunt, or not get hunted, and better digestive system will make it recieve more energy from anything it eats, so it has to eat less. This is just a broad view at organs, the organ design thread alredy linked is a better place to look at that.

That configuration of organs will be the genome.

Mutations will just be changes to the parameters of said organs, or geting rid of organs or adding new ones. To choose a mutation, just take a random part and modify one of its parameters (like for example make a leg longer). To test if such random mutation is beneficial or not, we will just do a series of very simplified simulations, like for example puting the creature and one of its predators (or prey) in a simplified environement, so we can test the outcome. With a bunch of those simulations, we can see the statistics of how many kills the creature archieves. From there, we go to the population formulas, and do a one-step calculation with the new data, and compare that to a similar one-step calculation with the older data. If the population growth is higher (the mutation made the population grow more), it is considered a good mutation, and it stays. If it is lower, it is a bad mutation, we reject it and do another random mutation.

The mutations not only makes species more likelly to score kills, or defend itself agains predators, but also affect the population formulas in different ways. To keep with the leg example, a longer leg will mean descendants are more costly to produce, and require more intake to keep alive. It also means they give more energy to predators when killed, but that wont show up until the next step of the evolution.

That goes for AI evolution. The player is just given the coice to modify its creature as he wants. As all the creatures evolve at once, we will be evolving AI creatures while the player is in edit mode, which gives us more processing power to work with, and as simulations are not made on screen, we can overclock them as much as the processor allows us to, and do them at parallel, allowing for a lot of that simple simulations being done.

To sum up, creature's genome will be their organs. To mutate them, we randomly modify some parameters and depending on what the populations formulas predict, we decide if they are good or not. We do all those calculations while the player is in the editor

hypoxanthine:

top-notch answer, exactly the detail ive been wanting to know. some problems though:

biggest one:

Daniferrito wrote:

If the population growth is higher (the mutation made the population grow more), it is considered a good mutation, and it stays. If it is lower, it is a bad mutation, we reject it and do another random mutation.

the vast majority of mutations dont do anything in real life. most of those that do decrease fitness. for these reasons, that isnt in any way a realistic model, and exactly the kind of false evolution stereotype that propagates misunderstandings of how evolution takes place. i think we should definitely avoid this unless you want to miseducate people.

This is what I propose:

1) creature chosen for mutation by whatever method you like
2) random genome parameter selected to mutate
3) random increase or decrease of this parameter
4) depending on the genome parameter modified, increase or decrease one of the population parameters for the species (say were using Seregon's split-parameter version of Lotka-Volterra, if the speed of travel is increased by lengthening of legs, which youd test by doing just one quick simulation to measure running speed, then youd increase one of the parameters that make up the overall efficiency of predator-prey-encounter conversion to predator-individuals, like the probability of hunt success)
5) run population dynamics
6) land player on planet
7) probability of creature appearance based on number from population dynamics (in some way i havnt decided on, also based on area of biome and another pop. parameter of distribution)

where a creature has two sets of internal instructions: its individual genome (which should be its neural network structure as well as body by the way) and the species 'populome' - its set of population dynamics parameters. depending on where the players is, the game can then switch between agent-based evolution and auto-evo.

I really have to go now. will be back.

~sciocont:

Thanks for the excellent post, hypox
Quote :

the vast majority of mutations dont do anything in real life. most of those that do decrease fitness. for these reasons, that isnt in any way a realistic model, and exactly the kind of false evolution stereotype that propagates misunderstandings of how evolution takes place. i think we should definitely avoid this unless you want to miseducate people.

We're well aware of this, but running evolution through evolving the population as a whole rather than mutating individuals is how we've been going because it's simpler. The vast majority of mutations do nothing because they don't change the phenotype- they occur either in Noncoding DNA or don't affect the protein they code for to a high degree. We're cutting out the molecular middlemen here and making sure every mutation we try is making some difference. Does that make sense?

I really wanted to stick to Darwinian processes as much as possible, but it's going to be computationally too expensive to run them. That's why I wrote the concept to exclude the individual and modify the population in the biome- it's the end result of natural selection. It's not a perfect system, but it doesn't have to be. We need creatures to appear like they're evolving through selection. Whether they do or not is of no importance to gameplay.

untrustedlife:

Hypo, you say you are a programmer so you should understand that this system will cause processing issues.
This is why auto-evo is the best choice right now.Note that all species will be evolving.

I have wrote evolution simulators before and once you get to a point it is just too hard for the computer to process. We want to keep the frame-rate high on this. (if possible).
It is better to loop through all species (each species as a whole) then it is to loop through every single member. (or in this case have a bunch of different creatures swapping genes at the same time)

hypoxanthine:

its clear that neither you nor ~sciocont read the rest of my post after that paragraph. i was not suggesting agent-based evo at all.

Daniferrito:

hypoxanthine wrote:

the vast majority of mutations dont do anything in real life.

Then we can ignore all of that mutations. If something has no observable consequences we can just get rid of it. If something can be abstracted without losing too much accuracy, we can just abstract it. For example, a car:

A car's motor just makes the wheels spin, which makes the car move forward if the wheels are in contact with the floor. Most simulations just abstract it to that level: if the car is in contact with the ground, accelerate it forward. The real reason for movement is that wheels are spinning. We could simulate to that level, where the motor makes the wheels spin, which in turn moves the car, but the end-result will be quite similar, in exchange of increased computing cost.

But the wheels are spining for a reason. The explosions inside the internal combustion engine are moving the pistons up and down, which through a set of mechanisms make the wheels spin. We could simulate that as well, but while the complexity of the simulation has gone up by a lot, we have barelly won anything in the end result. But why are the pistons moving? We would have to simulate particle physics to simulate how the increase of volume makes the pistons move. Why is the volume getting bigger? Now we have to simulate chemistry, then nuclear physics,…

At the end, we would have an hyperrealistic model of a car that absolutelly no computer can run, but the end result would be the same: press a key, the car moves forward. So we should just simplify it.

hypoxanthine wrote:

A long list of steps

I dont really get you there. Either you are sugesting mutating the whole specie, which would be the same of my post but without checking that the mutations actually make the species more fit, or you are sugesting mutating individuals/small populations groups and let the system do the "only the fittest survive" to trim down non beneficial evolutions.

In the first case, species wont evolve. As most of the possible mutations are bad (IRL, we will have to see how that works in the game) species will just evolve to stupid shapes. Maybe one lucky one will have mostly good mutations because of RNG, but thats it.

In the second case, you have a similar situation. Some creatures will evolve stupidly, while other "lucky" ones will make sense.

On both cases, you would need a quite big amount of cases in order for that lucky ones to be a substantial number, so we can have any kind of biodiversity. And we alredy agreed on that such a big amount of instances would be too much for the game.

hypoxanthine:

if you want to do it that way then, by that logic we should do it like this (which is kind of like yours but looking at it from the other side):

1) select rand species to mutate
2) select rand popdyn parameter and increase by small rand amount
3) each popdyn parameter change has a genomic interpretation. if you split the parameters up more, youll eventually get things like 'speed, stealth, etc.' so if you'd just increased the speed popdyn parameter for example, this would change the leg randomly, then run a simulation to determine if speed had increased and then hill-climb until it actually has. stealth? no simulation needed here probably - hill-climb to a set colour for the particular biome (simplistic i know). you can imagine what else there would be.

neither yours or this are too good in my opinion. imagine a predator mutates and is now much better at hunting. unless the great random mutates the prey in time, theres a significant danger of extinction. this usually happens IRL with invasive species and so on (notwithstanding sentients). the sudden spike in fitness would basically be equivalent to a new super predator arriving. i think we would have to actually run a simulation though to see how much of a problem this would be. a good fix for this might be to weight the probabilities of mutation for a species by its current population count (smaller population => greater selection pressures => mutants are selected for more strongly on an agent level => mutant allele frequency increases much more quickly on population level => so on population level, increase the mutation rate which by the suggested algorithms isnt really a mutation rate but the rate of fitness increase instead so it works here)

also, concerning your 'stick a predator with its prey and see how it does' simulation, how would you do that? if each predator has preferred prey, how is this preference decided for each predator? If you plan to stick your predator with any old prey, that will obviously be unreliable because it could be a really crappy prey which by chance hasnt evolved much, and in any case you wouldnt be taking into account environmental variables and scenarios. ok, so you now run many simulations each with random conditions and prey and take a rate of success and therefore fitness. is finding food all there is to fitness? nope, if the oceans are warming up a fat lot of good sharper teeth will do you if you arent changing something else to deal with it.

~sciocont:

It was never suggested that finding food was the only component of fitness, that was just the example given. We're not idiots.
Quote :

for example putting the creature and one of its predators (or prey) in a simplified environment

Quote :

how would you do that? if each predator has preferred prey, how is this preference decided for each predator? If you plan to stick your predator with any old prey, that will obviously be unreliable because it could be a really crappy prey which by chance hasnt evolved much,

In our food web model, an organism eats anythng that its digestive system can process, and anything it can get a hold of. So for any animal, we'd test a mutation against how well it can stay away from predators and how well it can get a hold of whatever it eats. An increase in escape from any predator (so long as it doesn't come with more serious negative increases) or the ability to obtain any food (again, barring a net negative) would count as a positive mutation. I realize that this is not specific, but it's not too hard to see that we could whittle down your ability to escape and ability to obtain food to a few key mutation areas (speed, comoflague, mass, sensory acuity, etc)
Quote :

2) select rand popdyn parameter and increase by small rand amount
3) each popdyn parameter change has a genomic interpretation.

This is certainly an interesting idea, and I think it solves the testing problem somewhat because popdyn changes can be charted to a list of possible parameter changes (such as speed, weight, etc) which can then be charted to possible mutations. In this way, instead of changing the form of an organism and figuring out the downstream effects, we change the properties of the organism and then mutate the form to reflect that. It gives us a lot more control over the form of the organism and thus an extra layer of insulation against the "ugly creatures" problem.

One interpretation of your popdyn parameter change is to simply boost the population (in the next generation) of the individual selected for mutation by some multiplier (5% or something, we can tinker with it based on the orgs population as a fraction of the community (biome) population) and then find a parameter change that might increase population by that amount. One problem I see with this is that, unless we have many different popdyn parameters for each species, mutations will be more or less arbitrary. Of course, if we're modeling every meaningful two-species interaction, then we need only add the multiplier to one of these parameters and then we have a more specific needed mutation.

scorpion268:

there is another way to work this problem out with a more realistic result.

1. select a random organism to mutate
2. randomly mutate two organs (or other) in said organism (these can either harm or benefit organism, it does not matter, the only required part to this is at least one be beneficial.
3. run simulator with both mutations added multiple times.
4. take results and put successes out of a whole of the simulation. (delete if success is 0 out of total and restart, unless of course you wish to keep it for an extinction)
5.depending on how they do in said simulation will determine the overall population change.
6. back in the environment the results will be reflected by how the population changes.

so to give an example, say we select a population of neon tetras to evolve. the neon tetras are fast river fish with rudimentary camouflage and communication techniques using reflective scales down the length of its body. so we will take the speed and the camouflage and increase camouflage and decrease speed for a swimming technique that saves energy. so out of 10 test, 3 of them it was not found based on the the camouflage and it survived 4 of the test where it was found. so it has a 70% survival rate, since its last one was 60%, the species now has a low natural increase rate of 10%. a high natural increase would be along the lines of 30-40%. this works two ways however because as you are testing the neon tetra, you are also testing the predator, an oscar cichlid, who is also going through its mutations test against he neons as well as two other prey such as guppies and apistogrammas.
in return however the oscar must also test its own survival skills in a similar test against an arapaima.

Daniferrito:

Actually, i dont think selecting a random parameted to addjust would suffice. Modifying any part of an organism has usually more than one parameter affected, which usually is the energy it takes to create a new creature (as it either became more or less complex or big) and another parameter depending on the specific part.

On top of that, increasing any one parameter is not the only way of increasing fitness. In some cases, making a change that gets you killed a few more times can be offset by the fact that now you can have many more offspring.

~sciocont:

Daniferrito wrote:

Actually, i dont think selecting a random parameted to addjust would suffice. Modifying any part of an organism has usually more than one parameter affected, which usually is the energy it takes to create a new creature (as it either became more or less complex or big) and another parameter depending on the specific part.

On top of that, increasing any one parameter is not the only way of increasing fitness. In some cases, making a change that gets you killed a few more times can be offset by the fact that now you can have many more offspring.
The population of one generation helps decide the population of the next, so I think that change would necessarily mean that the # of offspring parameter changes, which decreases overall fitness but adds to the population of the next generation. Interesting.
Your first paragraph is completely valid though, that is a huge problem with a backwards mutation selection system.

hypoxanthine:

if your worried about then why not have associated populome (bugger this im coining this term now) changes for each genome change, or even simpler still, instead of having just one genomic interpretation of a populome change, have more than one associated genome change.

e.g. populome change: speed increased => out of possible genome changes for this event: longer legs selected (then sim to ensure this actually does increase speed). => genome change: more energy required for movement etc.

~sciocont:

hypoxanthine wrote:

if your worried about then why not have associated populome (bugger this im coining this term now) changes for each genome change, or even simpler still, instead of having just one genomic interpretation of a populome change, have more than one associated genome change.

e.g. populome change: speed increased => out of possible genome changes for this event: longer legs selected (then sim to ensure this actually does increase speed). => genome change: more energy required for movement etc.
That's what I was suggesting. A change in speed is the actual number that changes, and the physical implementation can be handled either by a change in leg length, a change in the strength of the leg muscles, a more flexible spine. This should mean that the data for the organism's abilities is stored separately from the data used for its physical model and AI behavior, but the two read and influence each other in the evolution process.

scorpion268:

well there should be negative mutations as well in my opinion because in terms of evolution from many articles i have read, often times something negative comes about occasionally that in the long run results in something positive. to me running said simulator and deleting said mutation just because it does not benefit said population at the time is just to shortsighted. in nature when an organism mutates and its not directly beneficial it does not delete the mutation if the organism does indeed survive by some chance and reproduce, then more of them are out there with the trait and chances are at least a few are going to end up like their parent and end up reproducing and then we have more until they are everywhere.

~sciocont:

scorpion268 wrote:

well there should be negative mutations as well in my opinion because in terms of evolution from many articles i have read, often times something negative comes about occasionally that in the long run results in something positive. to me running said simulator and deleting said mutation just because it does not benefit said population at the time is just to shortsighted. in nature when an organism mutates and its not directly beneficial it does not delete the mutation if the organism does indeed survive by some chance and reproduce, then more of them are out there with the trait and chances are at least a few are going to end up like their parent and end up reproducing and then we have more until they are everywhere.

In the scheme of the game, having a useless trait somehow become useful after a long time is functionally the same as spontaneously evolving that useful trait when it becomes advantageous.

scorpion268:

ok thanks for clearing that up.

hypoxanthine:

so, as weve discussed, its effectively a hill-climbing algorithm. that immediately gives us a problem because hill-climbers are greedy, so they tend to get stuck. Bad mutations is one reason evolution works so well because the ability to step back from a local maximum fitness to a position of worse fitness allows you to 'become unstuck' and climb higher than before. in other words, im suggesting that we should still kind of 'allow' bad mutations, by instead using a simulated annealing algorithm, i.e. (to save you googling if you arent familiar with it, so if you are stop reading now) at each iteration at which the fitness was not improved (child<parent), a random number is generated and compared to an acceptance probability p= e^-d/T where d is the difference between parent and child fitness and T is a 'temperature' which starts at a set value and decrements every time the fitness is improved (when parent<child). this seems a better approximation to real life evolution to me.

Daniferrito:

Seems good to me. Hill climbers always have that problem, no matter how hard you try, they get stuck with local maximums. But evolution does as well, for example sharks found their local maximum many million years ago and havent changed much since. Evolution is a hill-climber as well.

On top of that, that "temperature" or allowance should also allow for worse mutations the more tries we do. That way, if there is no possible mutation that will meet the criteria, it wont get stuck, because eventually it will accept a bad mutation.

That is:
-First iteration, only accept mutation if growth increase is 10%
-Second iteration, only accept mutation if growth increase is 7%

Eventually, it will accept any mutation we throw at it.

~sciocont:

Daniferrito wrote:

Seems good to me. Hill climbers always have that problem, no matter how hard you try, they get stuck with local maximums. But evolution does as well, for example sharks found their local maximum many million years ago and havent changed much since. Evolution is a hill-climber as well.

This is an excellent point- evolution doesn't make perfect organisms, it just makes them "pretty good". If the environment stays essentially the same (as is the case with sharks) there is little selection pressure and the actual changes in evolution start becoming less and less distinct. This is also the case with crocodiles, mice, etc. But the shark is probably the best example.

# Important Post 5

Seregon:

Ok, I'm not sure anyones realised this, but a lot of the discussion on the last page has been had before, on the first two pages of this thread. The idea being discussed is slightly (and only slightly) different, but the problems are the same. I've watched you circle some of the solutions, but also create more problems, so I'll try and fix some of them. As a bonus, I'll even try to include that pseudo code hypo's so desperate for.

## Systems

We're discussing multiple different systems here, they all interlink, but I think theres been some confusion about which ones we're discussing here and how they all relate:
Population dynamics - controls the number of individuals of each species in each location. That's pretty much it, but it ties into pretty much every other system below, making it seem far more complicated than that. It monitors/processes birth/death rates, transfer of compounds between species (predation), migration between regions etc.
Climate - controls temperature and light levels (among others) across the planet, which is fed into the population dynamics. Light levels affect the available energy, temperature may affect metabolism, but also survival chances.
Auto-evo - what we really seem to be discussing here, despite it not being an auto-evo thread (even if it is very closely linked). Auto-evo selects which species get to mutate, and decides which mutations to apply. That's it, details later.
Compound system - controls what compounds have what uses, which can be converted to eachother, etc. It's also the target of most mutations, either by making a process more efficient (by making an organelle better), or enabling a new one, or developing a new compound (toxin). Conceptually the connectiong between the compound system and pop-dyn/auto-evo is the simplest; technically it's probably the most complicated, I'll see if I have time to get into it here or not.

## Stages of auto-evo

This has been mentioned here, but I'll mention it again to make the following clearer:
1 - The player plays for a while, auto-evo is basically idle, though we may pre- or post-process stuff from other generations
2 - A generation ends, either becuase the player reproduces and opens the editor window, or a certain amount of time passes, and we do an auto-evo step in the background
3 - Auto-evo is passed a list of all species populations and their current states
4 - It selects which of those species get to mutate. As discussed here (depreciated link), this could be one species, many species, or even all or none of them. The probability of each species getting to mutate is seperate, and dependant on multiple factors including their population size, selection pressure (i.e.: how unfit they currently are), reproduction rate etc. If the mutation of another species had a particular impact on a species in the last round (someone gave an example of a predator evolving and it's prey not getting a chance), the affected species gets a much improved chance this round. As the discussion here centers around how to select mutations, I'm going to ignore this step and assume that every species gets to mutate every generation for this post.
5 - We take the information about how each species performed last round and decide which mutation is best for it now. In some circumstances it may get to pick multiple mutations, but again for simplicity when explaining I'll assume it only gets one. This is what we're discussing here, so details later.
6 - All the mutations are applied. By doing this after step 5, the order in which species mutate this step has no effect on what they decide to do.
7 - We generate new meshes and animations as needed, and load back into the game.

Apart from the generation of new meshes and animations, all of this is computationally very cheap, and can be done in the background, with biomes the player isn't currently observing being processed while they're playing.

A note regarding 4 - some of the factors for picking who gets to mutate may now be used (in the microbe concept we're discussing in the other thread) to decide how many MP each species gets to work with, so we need to double check this and make sure we're not using the same factors.

## Selecting a mutation

Dani's post was a pretty good explanation of the current system, except in one detail - how we calculate fitness. This has been our problem from the start, and we've made several attempts at solving it, and come pretty close. The solution (I hope - there's no way of knowing for sure until we actually test it) is what was discussed on the first page of this thread, and pretty much just been discussed again on the last page or two, with a few alterations.

I'm going to go over a few of the suggestions since my last post yesterday, some are pretty good, but others have flaws which haven't been pointed out yet.

I'll start with Calli's post last night and work from there. I'm going to ignore whatever questions were left unanswered up to that point, becuase whatever answers hypo was after, you didn't do a very good job of asking the right questions - probably why it keeps looking like we're not reading half your posts, becuase we're simply not seeing whatever question or point you think was implied.

hypoxanthine wrote:

1) creature chosen for mutation by whatever method you like
2) random genome parameter selected to mutate
3) random increase or decrease of this parameter
4) depending on the genome parameter modified, increase or decrease one of the population parameters for the species (say were using Seregon's split-parameter version of Lotka-Volterra, if the speed of travel is increased by lengthening of legs, which youd test by doing just one quick simulation to measure running speed, then youd increase one of the parameters that make up the overall efficiency of predator-prey-encounter conversion to predator-individuals, like the probability of hunt success)
5) run population dynamics
6) land player on planet
7) probability of creature appearance based on number from population dynamics (in some way i havnt decided on, also based on area of biome and another pop. parameter of distribution)

Here we're just applying a completely random mutation (3-4) and seeing what happens. Yes, we update the pop-dyn (4) so that it will have some effect on population levels, but theres no actual selection going on. That is, unless you expect pop-dyn itself to take care of that selection, which it isn't really designed to. Yes, poor mutations will lead to a loss of population, but that loss of population doesn't really feed back into what mutation is chosen, you'll just get loads of very random species, most of which will die out.
We'll eventually get a good species by blind luck, but we're missing most of the aspects that make genetic algorithms effective - species don't mate with eachother, they don't reproduce asexually to produce new species (except when sub-populations speciate, but that doesn't help here). Effectively this is an GA with no interaction between agents, also known as blind trial & error.

hypoxanthine wrote:

1) select rand species to mutate
2) select rand popdyn parameter and increase by small rand amount
3) each popdyn parameter change has a genomic interpretation. if you split the parameters up more, youll eventually get things like 'speed, stealth, etc.' so if you'd just increased the speed popdyn parameter for example, this would change the leg randomly, then run a simulation to determine if speed had increased and then hill-climb until it actually has. stealth? no simulation needed here probably - hill-climb to a set colour for the particular biome (simplistic i know). you can imagine what else there would be.

This is close, but backwards and a little poorly defined. What your saying is that we first pick a random pop-dyn parameter to mutate, then pick a random associated genome/phenome trait to mutate to achieve that mutation, and then test to see whether that genome mutation actually achieved the desired pop-dyn mutation… that seems like a hell of a lot of work compared to the exact opposite:

1 - select species
2 - select a genome trait to mutate
3 - test what effect this has on the pop-dyn parameters, and what affect this has (I'll get to this later in the post) on species fitness
4 - if it's positive, accept the mutation.

Ideally, I'd extend this to trying every possible genome mutation (or atleast a large subset), and picking the most favorable one. That is your hill-climbing algorithm: pick the best possible mutation at every step. How feasible this is depends on the size of the genome and the computation expense of testing fitness, neither of which we're sure of right now, but I'm fairly confident that this is atleast feasible.

hypoxanthine wrote:

imagine a predator mutates and is now much better at hunting. unless the great random mutates the prey in time, theres a significant danger of extinction

I mentioned this in step 4 of the auto-evo process above. When species get mutated is an entirely seperate issue to how they get mutated, so we'd have this problem regardless of the system. Except that we have a solution, discussed in the thread linked in 4 above.

hypoxanthine wrote:

a good fix for this might be to weight the probabilities of mutation for a species by its current population count (smaller population => greater selection pressures => mutants are selected for more strongly on an agent level => mutant allele frequency increases much more quickly on population level => so on population level, increase the mutation rate

Pretty good, and similair to whats discussed in the linked thread in 4.

hypoxanthine wrote:

how is this preference decided for each predator

Prey preference should be an evolvable trait. I think Scio mentioned that we will have a food web for each biome, so we know who is capable of predating on who, all we need to know then is to what degree each predation actually takes place. This is partially preference, partially both predator and preys abilities to detect and avoid/find/chase/kill eachother, and partially availability (the higher the population densities of both predator and prey, the higher the rate of 'collisions' between them, and the higher the interaction rate, regardless of whatever else either species does to modify that rate). The degree to which each predation actually occurs, and how succesful it is, affects the fitness of both parties, and that degree therefore also decides how much of an impact that particular interaction has on each parties fitness, and how important mutations affecting that interaction are.

~sciocont wrote:

We're not idiots.

QFT

~sciocont wrote:

In this way, instead of changing the form of an organism and figuring out the downstream effects, we change the properties of the organism and then mutate the form to reflect that. It gives us a lot more control over the form of the organism and thus an extra layer of insulation against the "ugly creatures" problem.

As nice as this sounds, doing it simply isn't trivial. If we're incapable of figuring out the downstream effects of changing an organism (as suggested here and elsewhere), how do we go about changing those downstream properties, then going back and finding modifications which have the desired effect? The latter is only possible if the former is, and the former is a lot less contorted.

~sciocont wrote:

One interpretation of your popdyn parameter change is to simply boost the population (in the next generation) of the individual selected for mutation by some multiplier (5% or something, we can tinker with it based on the orgs population as a fraction of the community (biome) population) and then find a parameter change that might increase population by that amount. One problem I see with this is that, unless we have many different popdyn parameters for each species, mutations will be more or less arbitrary. Of course, if we're modeling every meaningful two-species interaction, then we need only add the multiplier to one of these parameters and then we have a more specific needed mutation.

I'm interpreting this as "boost a species fitness by an arbitraty value, and then find a mutation which would justify this boost", and it has the same issues as mentioned above. The problem of not having many pop-dyn parameters really is a problem, and we can't expect to have meaniingful or interesting auto-evo with the very few parameters used earlier on in this thread. I mentioned as much then, but only said that we'd need more than 7. We will need a lot more than that, representing things as specific as organism speed, mass, metabolic rate etc. I'll get back to this idea later.

hypoxanthine wrote:

1. select a random organism to mutate
2. randomly mutate two organs (or other) in said organism (these can either harm or benefit organism, it does not matter, the only required part to this is at least one be beneficial.
3. run simulator with both mutations added multiple times.
4. take results and put successes out of a whole of the simulation. (delete if success is 0 out of total and restart, unless of course you wish to keep it for an extinction)
5.depending on how they do in said simulation will determine the overall population change.
6. back in the environment the results will be reflected by how the population changes.

Apart from mutating two traits/organs at a time (why?), I really don't see how this is at all different to what Dani explained on the previous page - you do a random mutation, test if it's benificial, accept or reject it. The only real addition is that the performance in the fitness tests now translates to a population boost (is this a boost to population, growth rate, or what? you don't specify). Simple as that may be, the net effect is that our population simulations no longer obey the conservation of energy. If we give species arbitrary boosts to growth rates, we're giving them energy which they're not obtaining from a source (predation/consumption of another species or photo/chemosynthesis). We could attempt to balance this arbitrary change somehow, but that gets complicated.

Daniferrito wrote:

Actually, i dont think selecting a random parameted to addjust would suffice. Modifying any part of an organism has usually more than one parameter affected, which usually is the energy it takes to create a new creature (as it either became more or less complex or big) and another parameter depending on the specific part.

Good point - another reason we can't choose one pop-dyn parameter to mutate, then look for a genome mutation to achieve that, there would be too many side effects, some of which may make an apparently positive mutation negative overall.

hypoxanthine wrote:

if your worried about then why not have associated populome (bugger this im coining this term now) changes for each genome change

Getting warmer…

hypoxanthine wrote:

instead of having just one genomic interpretation of a populome change, have more than one associated genome change.
e.g. populome change: speed increased => out of possible genome changes for this event: longer legs selected (then sim to ensure this actually does increase speed). => genome change: more energy required for movement etc.

~sciocont wrote:

This should mean that the data for the organism's abilities is stored separately from the data used for its physical model and AI behavior

Do you mean abilities as in speed, strength etc., which are effectively the result of it's physical genome (leg length, muscle mass etc.)? If so, yes, there should be three layers of data:
1 - the genome, which is mutated by auto-evo. We have no way of assessing how fit a genome is without looking further.
2 - the abilities, or phenome (phenome in a different sense to how i was using it yesterday), which are the result of the genome. These are the result of either mini-simulations, or calculations.
3 - the pop-dyn parameters, which are influenced by a species abilities. It's only from these, and their effect on r, that we can actually calculate fitness.

hypoxanthine wrote:

so, as weve discussed, its effectively a hill-climbing algorithm. that immediately gives us a problem because hill-climbers are greedy, so they tend to get stuck

Yes, hill climbers get stuck, that's the advantage of GA's/simulated annealling/swarm sims etc. Simulated annealing may help, but all that really does is allow negative mutations at a small random chance. We already do this by having genetic drift - a small random change in a random trait. Also, I think your suggesting running this at every generation, effectively attempting multiple mutations until we either find a good one or give up and accept a bad one. If we allow this to go on too long, it would be simpler and a lot more efficient to simply try all mutations and pick the best one, or with small random chance pick a bad one.

Also, I really don't see the problem if it gets stuck. If the system finds a very effective genome (e.g.: a shark), why shouldn't that species survive unchanged for a very long time? The problem is if every species does that, and we end up with a static ecosystem, but given that this would require the environment to be static too, it shouldn't really happen. With a seasonal climate, long term climate change, catastrophes, and whatever changes the player makes, there should always be something for the AI species to adapt to, so they should become stationary. The simulations on the first page show that even in a trivially simple system, adding seasonality can delay stabilisation from a few 'months' to hundreds of 'years'.

Finally, if a species gets stuck in a local maximum, it may be unable to adapt to long term changes in its environment. If it doesn't get out of that maximum and find a better one before it's too late, that maximum may get to a point where it can't sustain the population, and it goes extinct. Tbh that's just realistic, species ussually go extinct becuase they're unable to adapt.

## Pieces of the puzzle

Right, now I'm hoping to show how we've already solved most of these issues before. A lot of this comes from the various auto-evo threads, and a lot is relatively new developments from various discussions I've had with Scio and Calli (both on this thread, elsewhere on the forum and off it) and a lot of thinking over the past few months. I really wasn't ready to present this yet, partially becuase theres a lot of more basic things I need to introduce first (which I will briefly do here), and partially becuase there are still some issues I haven't had time to fix (which I'll point out, so we can hopefully work on solving them). First, back to the seperate pieces, from the bottom up:

### Dynamic systems

Each organism is a collection of compounds, which are managed by the compound system. Organisms gain compounds from their environment, and other organisms, they process them internally using organelles or other processes, and they excrete waste compounds back into the environment. Some compounds are necessary for survival, others are harmful, an organisms basic aim in life is to have the right mix of compounds available to allow it to survive and reproduce.

At the population level, species can be represented as the number of individuals in an area, and the average compound contents of it's individual organisms. The compound system again manages these compounds, but the population is managed by population dynamics, which takes information from the compound system. If a population has insufficient access to a particular compound (e.g.: sugar), all it's members will suffer and the population as a whole will suffer starvation, reducing birth rates and possibly increasing mortality.

In addition to information from the compound system (the internal processes affecting a species' members), population dynamics also takes information from external processes, including predation, other interactions (e.g.: symbioses, competition) and environmental drivers (e.g.: light and temperature levels). All of these factors have some effect on a species ability to survive and reproduce, but it's far from sufficient to simply talk about birth and death rates, we need to differentiate (in the non-mathematical sense) these parameters into more specific parts, e.g.:

• Species A mortality due to predation by species B
• Species B energy/compound gain due to predation of species A
• Species C (a plant) energy gain due to photosynthesis
• Species A mortality due to exposure to envionmental hazard (toxin, extreme temperatures etc.)
• Energy expended by species B when searching for prey
• Energy expended by species A/B during a predation encounter (the chase/fight)
• Energy expenditure required for species A to reproduce

This list is far from complete, and deciding all the necessary parameters and related equations won't be easy. This, along with a similair list of 'abilities' I'll mention later, are the two key issues we need to overcome to make this work. They're certainly not impossible though, just hard work.

Now we have something which is far more than a simple logistic equation or predator-prey model. It incudes those two things, but also many more factors, in calculating population levels. This appears overcomplicated for this purpose, but that's not the point. Knowing the population level of each species in each location is a side effect of the population dynamics system, what we actually want is a way of calculating species fitness. The simplest measure of fitness is r, or (b-d) as explained on the first page of this thread. It's pretty clear that it won't be any where near that simple with the parameter list above, but calculating it will be just as simple to the computer.

### Data

Now the other half of the puzzle. Each species has a genome, all members of a species in a particular location/biome (a population) share the same genome. Populations of the same species in seperate locations may differ slightly, and may eventually speciate if they're seperated for too long, but speciation and spatial dynamics (migration) are beyond the scope of this discussion. This genome controls the placement and number of organelles and limbs, the efficiency and size of those organelles, the efficiency of processes not associated to any organelle, the compounds available to the organism.

Derived from this information, and the definitions of each genome, compound, process and what each can do, is the organism/species' phenome. This phenome record the abilities of the organism. For example, if the genome specifies 3 mitochondria with an efficiency of x%, and the mitochondria definition says at that it can produce 1mol ATP per second at 100% efficiency, then the phenome records the ability to produce ATP from sugar at a maximum rate of 3*x moles of ATP per second (depending on the availability of oxygen + sugar). If the organism has the appropriate organelle (golgi apparatus + vesicles?), and the ability to produce a particular toxin, then the phenome records the ability to produce that toxin at a rate dependent on the efficiency of the golgi, and at a strength dependent on the level of the toxin. The phenome will also have a value for the organisms maximum speed, dependent on the types of motion available (flagella, cilia, pseudopodal), their number and efficiency, as well as the size and mass of the cell. Again these are examples from an incomplete list.

We also have a budget of mutation points, or genetic diversity, to spend on mutations. How exactly these will work is still being discuss in another thread, so I'll just assume they're limited, and that they may be split into seperate pools for different types of mutation.

Finally we have data both from the envionment and the Population Dynamics system: the number of each population, the density (dependant on the area of each location), acidity, temperature, light, environmental compound reserves etc.

### Calculating population

Now we have all the pieces we need to calculate population. The population dynamics equations use the environmental, population and compound level data (variables), and each species' phenome (parameters) are combined to calculate a species reproduction and mortality rates, and therefore the change in its population for the next generation. An example:
From populations, we know the density of species A (predator) and B (prey), and therefore how often they are likely to meet eachother. From species A's phenome we know how likely it is to detect B upon meeting it, as well as how capable it will be of chasing B down. Combining this with B's phenome telling us how well it can escape or fight A off, and some other details from each phenome, we can calculate the chance of a meeting resulting in an individual of B being succesfully brought down. We also calculate how much energy this hunting process (succesful or not) costs each species, each species loses this much energy regardless. We then multiply the encounter chance by the chance of a succesful kill to find an overall predation rate. Population B loses members, and their embodied energy and compounds at that predation rate. Population A gains some of those energy and compounds at a rate depending on their digestion efficiency and their ability to defend the kill and consume it before being chased off. What doesn't get eaten by A is returned to the environment as a carcass, which may be decomposed or scavanged, whatever material isn't digested by A is returned as faeces. This is only one interaction between two species, there will be many more between both species and the environment.

All of this information is fed back into the next generation as changes to species populations, their compound reserves, and the environment - some of the data in the previous section.

## Auto-evo

Finally we come to the question of mutations. Everything else about auto-evo is pretty irrelevant at this point - we've picked a species, possibly becuase of a mutation to another species, possibly at random; we may or may not also apply a completely random 'genetic drift' mutation - all we're worried about here is picking the best possible mutation given all the information we have.

1. What we do is pick a set of traits in the genome, this may be small or may include all traits depending on how computationally intensive this all turns out to be.
2. For each one we then increase and/or decrease it as far as our mutation budget allows(for some upgrades we simply can't afford, we stop here and move on to another trait). We also consider one genome where no mutation takes place.
3. We then calculate the resulting phenome for each such possible change.
4. We calculate the predicted population growth rate in the next generation for each phenome.
5. Whichever change results in the greatest population growth provides the best fitness boost, so we choose that mutation. If all growth rates are negative, we choose the least negative. These population growth 'estimates' are calculated exactly as in the previous section, and include input from interactions with other species and the environment. Phenomes for other species are kept at that set at the last generation, so all species have the same information about eachother.

Steps 3 and 4 are the difficult bit. Wherever possible we need to find equations for these calculations, and I'm fairly confident that we can do this for most if not all situations. Where we can't, we resort to the mini-simulations discussed in the previous few posts, but that should be a last resort.

If your wondering, steps 2 and 5 are the hill climbing parts; in 2 you choose a few possible directions, then in 5 you find out which of those directions is uphill. I have just realised that this is a very naive hill climbing system, and we might be able to reduce the number of mutations we need to test drastically by choosing a better one (Nelder-Mead comes to mind). However, I need to think this over some more, and even if we can't I'm really not that worried.

At this point all that's left is to make the chosen changes to the genome and update the phenome. Once all mutations for this generation are done we calculate population growth rates for each species via standard population dynamics and update all the population levels, along with compound levels in species and those in the environment. The last step is to create any new meshes and animations needed, then go back to gameplay.

## Summary

I'm not sure if there's much more to say. I've probably made a few mistakes here, it's gone 5am and I've been writing this since before midnight, so I'll try and clear up anything obvious tomorrow. I also mentioned at the start that I was far from ready to present this, so not everything is as well developed as I'd like.

I should also point out that while there are bits of this which would be difficult to program, theres nothing here which I couldn't program (and I'm definately not the best programmer here), and an aweful lot of it is similair to the sort of stuff I do every day, so it's certainly possible. I can provide much more detailed program flow and pseudo code when needed, but that really isn't a priority right now.

Again, a lot of whats been discussed here the past few days is similair to this. Also, of all the criticism the various ideas have recieved, the only truely valid one I can see is that this is really rather complicated. To that I can only say that I can't think of a simpler system which will produce similair or better results for a reasonable amount of computation (and thats not for lack of trying). Also, while the whole system is definately complex, the individual components are actually very simple, and even the ways they interact are fairly simple too.

### A few points on computation

I run these sorts of simulations and computations almost daily, and I know we can run probably hundreds of thousands of them per second. Given the few complicating factors (these equations are a fair bit more complicated, they'll be running in c++ which is a lot faster than what I use, we need to run a game at the same time) I'm pretty confident that computation isn't going to be an issue, so long as we don't resort to too many mini-sims.

In addition to this, we won't be running this in anywhere near realtime. Auto-evo only needs to run on each location maybe once every 2 minutes, if that? Locations not observable by the player can be run even less frequently, and be done in the background while they're playing, so that only the observable location needs to be run while the player is in the editor.

The biggest computational workload to auto-evo will still be the generation of any new meshes or animations, and this only really needs to be done for the observable location. Other locations can have these generated as and when needed as the player moves around.

Finally, this wasn't supposed to be a rant, sorry if some of it came accross that way. What it's supposed to be is a summary of most of the relevant concepts we've discussed on various parts of this forum about auto evo and population dynamics. A lot of this was discussed and practically decided in the first 2 pages of this thread, I've just filled in the blanks from what I've been thinking about over the past several months.

tl;dr - I wasn't BSing

~sciocont:

That was probably the best post ever written here. I only have a few things to comment on.

Seregon wrote:

Whichever change results in the greatest population growth provides the best fitness boost, so we choose that mutation. If all growth rates are negative, we choose the least negative.

We don't even necessarily need to pick the best one. It makes no difference whether we do or not computing-wise, but I think after some testing we'll have to decide how efficient we want evolution to be, meaning how well it solves fitness problems. The efficiency of NPC auto-evo could even provide a sort of difficulty level for the player.
Seregon wrote:

Also, I really don't see the problem if it gets stuck. If the system finds a very effective genome (e.g.: a shark), why should that species survive unchanged for a very long time? The problem is if every species does that, and we end up with a static ecosystem, but given that this would require the environment to be static too, it shouldn't really happen.

I absolutely agree.
Quote :

In addition to this, we won't be running this in anywhere near realtime. Auto-evo only needs to run on each location maybe once every 2 minutes, if that?

From past discussion, I believe we were thinking of anywhere from 10 to 30 minutes for a generation, I'll have to find the thread, we were discussing in-game time. Here it is (depreciated link).

Seregon:

Thanks scio, I agree on your points too - there's no nead for auto-evo to choose the best possible mutation, but having the option to is a good starting point for tweaking. Linking efficiency to difficulty might be interesting too…

I think I confused the auto-evo generation length with the population dynamics step length. Having auto-evo happen less often is even better computation wise, anything over 2 minutes is doable, 10-30 minutes is plenty. We'll probably want to update population dynamics and compound levels more often, maybe twice a minute, but computationally that's much cheaper than an auto-evo step. Also, I'm not sure I've ever seen that thread, will have to have a look over it.

hypoxanthine:

Well, OP delivered.

blown away, everything explained. definitely one of the most informative posts on this forum, (if any are more informative they are also by you too i think). using population growth immediately afterwards looks like the most true-to-life measure of fitness, i like that. my only confusion is about the mutation budget. im sorry if this has already been in another thread, but would this just be the number of mutation/hill-climbing/whatever optimization algorithm iterations allowed for a creature to attain its maximum fitness before the algorithm cuts out?

Seregon:

Mutation points are being discussed here (depreciated link).

The way they're spent is that each mutation has an associated cost. What exactly this will be hasn't been decided, but it will be something like:
- 1 MP gets you an x% increase in your overall metabolic rate
- you can add a new organelle/limb for 50 MP
- upgrading your mitochondion organelle to level 2 (if we have levels) costs 5MP

So depending on the MP available, you may be able to upgrade some traits more than others, which should be taken into account when chosing what to mutate.

The number of iterations auto-evo goes through when decided a mutation will either be set/balanced by us, or controlled by the code in an effort to keep computational expense reasonable, it probably won't be influenced by any ingame value.

Karthas077:

Going back to the topic of actual population dynamics, I have a question for Seregon: is there a particular reason you're using the Lotka - Volterra predator prey model?

They're only accurate if you have good α or β values. Further, it looks like you either made a mistake or over-simplified your equations.

(For clarity I'm going to use your variables)

You said, "(x * y) is the encounter rate between the species, i.e.: how many times (per year) you can expect two individuals to meet. 'a' is the efficiency with which these predations are converted into more predator population"

However in the traditional Lotka-Volterra model, entire term "(a*x*y)" is the rate at which the predators kill prey. The variable a is set to quantify not only the relative frequency of meeting but also the rate of success of predation events. It's units are 'predator kills per predator per prey'.

Returning to my actual question, determining a good 'a' value to model the rate of predator kills is not a simple matter. Much of it is done through experimental analysis, something which can't be done for the dynamic predators and prey of Thrive.

After spending a few minutes slogging through my browser history, I found an article I read about modeling predator prey interactions off of collision theory. It claims to be more robust than Lotka-Volterra (In fact the article specifically mentions the 'shortcomings' of Lotka-Volterra as it pertains to more complex predator prey relationships.)

In it, it gives a series of relatively simple equations that model prey survival as a function of time using the size of the shared habitat, the movement patterns of both predator and prey, the speed at which both predator and prey move, and the "predator prey encounter distance" (A value that could easily be determined based on the camouflage and size of the prey as well as the evolved perception of the predator (smell, vision, etc.)).

The study seems to be well documented and supported by not only it's data but by sound mathematics grounded in Kinetics.

scoicont said you were working on a PhD in theoretical ecology, so forgive me if I'm just extremely naive, but your explanations did not line up with what I remember learning, and upon in depth study of the wiki article that /you/ linked to, I am unable to find cohesion between what the article describes and what you try to explain in your early post.

PS: I tried to link the article, but I'm too new here so just Google "Mean free-path length theory of predator–prey interactions". It's kind of a dense read, but if I managed to make any sense of it, you shouldn't have a ton of trouble.

EDIT by Seregon, a link to the paper

Seregon:

Hi Karthas, and welcome to the team. I'm afraid I was in a bit of a rush when I wrote some of the earlier posts in this thread (I was eager to move onto developing the models for use in Thrive). As a result, my explanations of Lotka-Volterra were from memory, and may have been a little inaccurate. All I had really intended was to use that model as a very basic example of a two species population model, with the simplest possible interactions (birth, death and predation). I should also admit that at the time I didn't actually read the wiki article I linked.

As you say, Lotka-Volterra is far too simplistic for our needs, and what I meant when I said 'a few modifications beyond the classical Lotka-Volterra model' was not to simply calculate a & b, but expand them to account for all the factors which influence birth and death rates, such that the population growth rates for each species are the sum of many different factors.

Your explanation of predation rate is a good example of one such factor. I had actually developed a similar model last year, but never got round to posting it (I will definitely check out the article you linked though, as having a published model to go off is good) accounting for predator and prey densities, detection ranges, chase speeds and stamina, though I hadn't managed to incorporate movement behaviours.

Also a note on encounter rates. When x and y are variables representing the density of individuals of a species, then x * y is a good first estimate of the rate of encounters between individuals of different species, assuming that individuals are uniformly distributed, move randomly, and detect each other within an area A such that (x = x' * A) is the relationship between the number of individuals (x') of a species and their calculated density (x). That's a few assumptions which aren't realistic, and models like the one you linked attempt to relax those assumptions.

That's, unfortunately, all I have time for right now. If your not satisfied with this reply, or you have any more issues with anything in this thread, I would be very happy to discuss it further. I will be rather busy for the next week though, and thought it was better to post a quick reply now, than make you wait that long for a detailed one.

Karthas077:

Thank you for the quick response. I'd be interested in discussing this with you more further, as I'm in the process of coding an abstracted population simulation, and while I've begun implementing the functions I mentioned earlier, I'd prefer it if they more closely related to what was going into the game.

Seregon:

I'll be checking on this thread when I can, so if you go ahead an post what you have already, and what your working on, I'll get back to you when I have some time. I may split this off into a new thread if needed too.

After next week I'll either have a lot more free time, or none at all, but I'll try to make some time then to go over all the work I did on this last year, and get some more of it written up for you.

{~}:

This is a prototype formula for Encounter rate:

The encounter rate of two distinct species of mobile organisms in a section of a biome for which: n= the volume of the space around an organism such that it encounters to organisms of the other species in that space, and v=the volume of the section of the ecosystem, and p[1] is the population distribution of the first species of organism, and p[2] is the population distribution of the second species of organism, r[1]=The distance that a member of species 1 roams during the time interval, r[2]=The distance that a member of species 2 roams during the time interval is:

Is
(p[1]p[2]n^(2/3))(r[1]+r[2])
v

camouflage and sensory organs could determine what n is. p[1] and p[2] and r[1] and r[2] would be evolve-able behaviors of species 1 and species 2.

tjwhale:

{~} wrote:

This is a prototype formula for Encounter rate:

The encounter rate of two distinct species of mobile organisms in a section of a biome for which: n= the volume of the space around an organism such that it encounters to organisms of the other species in that space, and v=the volume of the section of the ecosystem, and p[1] is the population distribution of the first species of organism, and p[2] is the population distribution of the second species of organism, r[1]=The distance that a member of species 1 roams during the time interval, r[2]=The distance that a member of species 2 roams during the time interval is:

Is
(p[1]p[2]n^(2/3))(r[1]+r[2])
v

camouflage and sensory organs could determine what n is. p[1] and p[2] and r[1] and r[2] would be evolve-able behaviors of species 1 and species 2.

Nice formula, is it from a book or is it your own? It seems reasonable on first glance.

Seregon's got a big post coming about the compound system / population dynamics and we are getting to the point where we need to think about predation.

Other interesting questions include

1) How do you model fighting? We need to know what percentage of these encounters are successful.

2) How do you model the amount of compounds transferred per successful encounter? Is it a simple parameter or does it depend on the prey in some way? Can I make my species "hard to eat" in the hopes of starving my predators.

3) How is this limited? For example it isn't possible for one lion to eat 100,000 gazelles in one day, even if the equations say it should, how do you limit how many it can eat? maybe take a function of your formula above.

Anyway some of these questions will be hard to consider until you see Seregon's post (he's got some good stuff and it may take a while) and you can see how things are structured. Keep thinking about it! All ideas welcome.

{~}:

yes, It is my own formula.

2) Predators can eat some tissues more effectively than other tissues, so we should list their efficiencies separately.
Example:
Predator 1
Efficiency for bone: 0
Efficiency for ligaments: 0
Efficiency for fat: .5
Efficiency for muscle: .75
Predator 1 wouldn’t get any nutrients from bone or ligaments. Predator 1 would only get half of the nutrients in the fat of its prey. Predator 1 would get three fourths of the nutrients in the fat of its prey.
This predator would starve if its prey is mostly bone and ligaments.

3) I thought that predators wouldn't hunt again right after they hunted (they are too tired or they are too full, but I didn't yet put this in a formula.

tjwhale:

Have a look at Functional Response on wikipedia. I think this is probably a good way of modelling predator satiation.

moopli:

That's perfect — feed in the encounter equation to a functional response equation and we get the frequency of feeding attempts. Next step is to figure out whether an attempt is successful, and I'm currently approaching that case-by-case.

Stealth (ie, stealthy predators catching victims unawares), I assume, we can model the same way we'd find the encounter volume n. Not a solved problem, but we avoid adding new parameters at least.

I'm currently trying to model the dynamics of a chase; trying to figure out what variables affect a successful catch. Not much luck yet getting sims to spit out anything I can make a suitable equation for.

Fights are a whole 'nother ball game, of course.

{~} wrote:

Not in the slightest, actually — this is about controlling the player creature, and even on that barely came up with anything of consequence.

EDIT: Some more details on my simulation:

Predator and prey start close to one another, if they're ever within a small enough distance of each other the trial is a success.
Their paths are based on fBm, with prey tending to run straight away from predator, and predator tending to run straight to prey.
Predator and prey are described by 3 parameters each:
Speed: how fast they go
Twitchiness: for the prey, how likely it will change heading drastically
Lookahead: for the predator, how likely it will aim ahead of where the prey is going
Endurance: how far either is willing to run

Edit: Some thoughts on cooperation — considering the way many cooperative hunters hunt, tiring out their prey by taking turns; it seems like cooperative hunting serves as an endurance multiplier, at least.

Edit: Added a max distance as a failure condition, now the results are much more interesting. Previously, a predator with more endurance than its prey would almost certainly succeed, even if the prey is faster. Now we reduce the endurance successes to cases where the predator is perceptive enough to track where the prey has gone (like a human hunter-gatherer would).

tjwhale:

moopli wrote:

Fights are a whole 'nother ball game, of course.

One idea I had for fighting is to make "fight" into a compound. I've talked to Seregon about it a bit but we didn't make any decisions (also we should get him involved with this kind of discussion as this really is his wheelhouse).

Basically your species burns energy (ATP, sugar, whatever it is) to make "fight" in the same way as it would for any other compound and then fight drains away over time. What this represents is the difference between a hedgehog and a cat. A hedgehog has a lot of defensive tools but very little "fight" (it will curl into a ball) but cats only have claws and teeth but loads of "fight" which lets them hunt very efficiently. What "fight" really costs you is just energy.

When you are calculating predation (and it looks like the compound system / pop dynamics will be heavily averaged over many encounters) the fight component is just the amount of tools your species has multiplied by how much "fight"it has in it's pool at that time.

"Movement" can work the same (you burn energy to make it as a compound, it drains away over time) (we could even have 2 types, sprint energy and sustainable travel) and even things like "intelligence" or your "lookahead" could be modelled like that.

Then auto-evo can adjust the amount of fight and movement you are making (maybe it's better to be a galapagos turtle than a bull, you save so much energy) and we can use those numbers in calculations of combat, chases etc.

But as I say Seregon is going to do a big post about where we've got on the compound system / population dynamics and when we can plug all this into that. It could be a while (as life is busy and it's a big post) and he is a brilliant guy and well worth waiting for!

page revision: 6, last edited: 25 Aug 2016 11:30