
Many survival games face the problem that the late game becomes boring—once you’ve become stronger, the animals in the area are no longer challenging. Additionally, there’s often a lack of diversity in the environment, making gameplay repetitive.
One common solution is to remove the level cap, allowing animals to have levels beyond a fixed maximum (like 150). This makes them harder to defeat, but it still feels repetitive since the only change is that animals have more health or do more damage.
My solution is to let the animals evolve and adapt. This way, animals can change in response to your playstyle or the environment. For example, over time you might encounter entirely new animals, or an herbivore might evolve into a carnivore and start attacking you. Some animals might migrate to new areas if they can’t survive where you are.
By implementing this kind of evolving ecosystem, the game would feel less repetitive, and your decisions would have meaningful consequences in the world. This dynamic environment could make survival games more engaging and unpredictable, especially in the late game.
Research
Evolution Theory
The creator of the evolution theory is Charles Darwin, he said that species can change, so that would mean that every animal or species have the same ancestor. But over a long time the genetics changed for a specie, so that is how different animals originated. Darwin called this process “descent with modification”, later this was changed in evolution.
Natural Selection
Of course Darwin did not just propose that organisms evolve. He said that the method for evolution was called natural selection. His concept for selection was based on several observations.

- Traits are passed to the next generation. This means that when an offspring is made, the characteristics from the parents are passed down. For example the color of the parents.

- More offspring then capable. The amount of offspring an organisms can produce is more then the environment can support. There for a competition for resources is started.

- Offspring have different traits. Each offspring got different traits from there parents. There for there is a diversity in each generation.
From these simple observations, Darwin concluded that some individuals inherit traits that help them survive in their environment. As a result, these individuals are more likely to survive and reproduce, having more offspring than others. Because they produce more offspring, their advantageous traits become more common over generations. Over time, this process leads to populations that are better adapted to their environment.
An important aspect of natural selection is that it depends entirely on the environment. This means that traits favored by natural selection are those that increase survival and reproduction in a specific environment—not necessarily traits that are inherently “superior.” A trait that is beneficial in one environment may be harmful in another.
Another crucial point is the need for heritable variation. Natural selection requires differences in traits within a population, and those differences must be inheritable. The greater the genetic variation, the more effective natural selection can be in promoting the best traits.
Finally, this variation originates from mutations—random changes in genes passed down to offspring. Mutations introduce new traits, providing the raw material for evolution to act upon.
Mutations
A mutation is a change in your DNA. For example, if everyone in your family has blue eyes but you have brown eyes, it could be because of a mutation in your DNA. Normally, you would inherit blue eyes like your family, but the mutation caused you to have brown eyes instead. Since mutations change DNA, your offspring also have a chance to inherit the mutation.
There are also mutations that can occur later in life, but these are not heritable and won’t be passed on to offspring. Mutations can happen spontaneously in genes or be caused by environmental factors such as exposure to radiation.
Some mutations are beneficial, increasing a species’ chance of survival. These beneficial mutations tend to become more common over time and may eventually become the norm in the population. Other mutations may be harmful, reducing survivability, and thus become less common or disappear over generations. Mutations play a crucial role in the process of evolution.
Most mutations occur randomly and are quite rare. However, environmental factors like UV radiation, chemicals, or other mutagens can increase the likelihood of mutations by damaging DNA.
Genetic algorithm
Genetic algorithms are inspired by the principles of natural selection and genetics. They simulate evolution by favoring individuals that can adapt and survive in a given environment, allowing them to reproduce and pass on their traits.
These algorithms model the genetic structure and behavior of a population’s chromosomes. The foundation of genetic algorithms consists of four main components:
- Individuals compete for resources and mating opportunities.
- The most successful individuals reproduce, creating more offspring than others.
- Genes from the fittest parents are passed on to the next generation.
- Over successive generations, the population becomes better adapted to the environment.
Each individual has a fitness score that measures its ability to compete and survive. Those with higher fitness scores are more likely to be selected for reproduction, increasing the chances their genes will be passed on.
To implement a genetic algorithm, you start by creating an initial generation of individuals. Each individual’s genes form chromosomes, which are stored in a list to be used in the selection and reproduction process.

Offspring produced from two parents inherit genes from both individuals. This means each gene in the child has the same value as either parent 1 or parent 2. Typically, about 50% of the offspring’s genes come from parent 1, and the remaining 50% come from parent 2.
The gene inheritance can occur through a 50/50 crossover mechanism: the chromosome is split roughly in half, with the first half of the genes inherited from parent 1, and the second half inherited from parent 2.

There is also a fully random crossover method for gene inheritance. This means that for each gene, a random parent is chosen—like flipping a coin—to decide whether the gene comes from the mother or the father.

When genes are passed down to offspring, there is a small but consistent probability of mutations occurring. Although the chance of mutation is low, it ensures that genetic variation is continuously introduced in each generation.

Mutations can be positive or negative. Even the negative mutations are important because they introduce genetic diversity into the population, which is essential for evolution. While harmful mutations may reduce an individual’s chances of survival and eventually die out, they contribute to the overall genetic variation necessary for natural selection.
Positive mutations, on the other hand, improve an individual’s ability to survive and reproduce in its environment, increasing the likelihood that these beneficial traits will be passed on to future generations.
Implementation
Environment

Before animals can roam and food can spawn, there needs to be a suitable environment. To achieve this, I created a bounding box that defines the area where bushes (food sources) will be spawned.
To control the bush spawning, I introduced a few configurable variables:
- Bush amount: Determines how many bushes to spawn.
- Minimum radius between bushes: Ensures bushes are not placed too close to one another.
During the spawning process, each bush is given a random position within the bounding box. If a newly placed bush is too close to an existing one (closer than the defined radius), it will attempt to find a new valid position. This helps create a more natural and evenly distributed environment for herbivores to explore and feed.

Each bush has the ability to generate food. When the simulation starts, each bush has a chance to spawn food immediately, ensuring there is always some food available at the beginning.
After the initial spawn, food generation occurs on a timed basis, with the interval between spawns randomized to add variability. When food spawns, it appears at a random position within a circular area around the bush.
Before placing the food, the system checks if the chosen position is on the ground. If it isn’t, the bush will try a different position. To prevent endless attempts, there is a maximum number of retries after which the spawn attempt is aborted.

Each food object has a script called FoodController attached to it. This script includes a decayTime property, which determines how long the food remains in the world. If the food exists longer than this decay time without being consumed, it will decay and be automatically removed from the environment.

Organisms
DNA
Each animal need to have inheritable genes, these are:
| Gene | Effect | Trade-Off | Reason |
| Life(Health) | Longer survival, bigger size | Takes longer to mature, lower reproduction rate slower movement speed | Larger animals tend to reproduce slower and move slower |
| Walkingspeed | Faster movement | Higher energy drain | The faster you move the more energy you use |
| Sense | Better awareness | Higher energy drain, longer reaction time | It cost more energy to see and feel everything in a large area, and it takes longer to process |
| Energy | More stamina | Needs more food | Higher energy means it needs more food to stay energetic |
But with these genes you can create different values:
| ValueName | Effect | Influence |
| Size | Size of animal | Life >, Size > |
| ReproductionRate | How fast it can mate | Life > , Rate < |
| ReactionTime | Time it takes to react | Sense >, Time > |
| Hunger | Time it takes to get hungry | Energy >, Time < |
The heritable values are saved in a dictionary called Chromosomes. And the other values are set based on the chromosomes.

Behaviour

Each organism can be in different states, such as Roaming or Eating. To handle this, I implemented a state machine. Since organisms frequently change states, I created a clear diagram to visualize all possible transitions.
To support multiple states, I designed an abstract base class for states. This class defines core functions such as:
OnEnter– called when a state is enteredOnExit– called when a state is exitedOnUpdate– called every update cycleWalkTowards– moves the organism toward a targetArrivedAtTarget– checks if the organism has reached its target
There are also helper functions, such as adjusting the organism’s speed when its energy is low. The WalkTowards function is used in almost every state since movement depends on the target defined by that specific state. Similarly, ArrivedAtTarget checks whether the organism is close enough to its current target.

Every state consumes energy. The amount will be different on every state. So will the walking state consume less energy then running. There is the base consumption and that has to do with the sense radius. And then the extra amount will be calculated for every state.
Roaming state
The Roaming state represents an idle behavior where the organism wanders around the environment without a specific goal. For herbivores, however, this state includes an additional behavior such as remembering the locations of food.
To determine a movement target, the organism selects a random position within its sense radius. It then checks whether this position is on navigable ground. If valid, the organism begins walking toward that location.
Energy consumption during movement is calculated using the formula:

Hungry
Every organism experiences hunger. To simulate this, I implemented a hunger score and a hunger consumption rate, which varies depending on the organism’s current state. For example, more active states may consume hunger faster, while idle states consume it more slowly.
When currentHunger drops below a certain percentage of the total hunger capacity, the organism transitions to the LookingForFoodState.
This state functions similarly to the RoamingState, with one key difference: the organism actively seeks out food. If the organism is a herbivore, it will first check its memory for known food locations and attempt to walk toward the closest one.

After it finds food it will start to eat, and regenerate energy. If it has eaten the organism will go back to roaming state or any other state.
Mate
To simulate evolution, organisms need the ability to reproduce. An organism can only mate once it has reached maturity. After maturing, a reproduction timer starts. Once this timer reaches a specified threshold, the organism becomes eligible to reproduce and transitions into the LookingForMateState.
In this state, the organism searches for a suitable mate. Once a mate is found and the conditions are met, the organisms reproduce, leading to the creation of a new offspring.


When two organisms reproduce, the child inherits each chromosome with a 50% chance of coming from either the mother or the father. After inheritance, there is a chance for mutation to occur on one of the genes.
If a mutation happens:
- There is a 50/50 chance that the mutation is positive or negative.
- A random gene is selected to be affected by the mutation.
- The mutation is then applied, modifying the gene’s value accordingly.
This mechanism introduces genetic variation across generations, which is essential for simulating evolution.
Hunting
Of course, the simulation doesn’t include only herbivores—otherwise, evolution would be influenced solely by the environment. To create a more dynamic and realistic system, predators (hunters) are also introduced.
Hunters behave similarly to herbivores in most aspects, but with one key difference: instead of searching for plants, they hunt other organisms for food. While in the HuntingState, a predator will search for the most suitable prey based on criteria such as proximity, size, speed, or vulnerability.
This predator-prey interaction introduces natural selection pressures, making the evolution process more complex and lifelike.

When selecting a target, predators follow a few simple but realistic rules to mimic real-life hunting behavior:
- If the prey is already dead → Eat the prey immediately.
Dead prey is an easy source of food and requires no energy to catch. - If the prey is alive → Only pursue it if its size is less than or equal to 1.25× the predator’s own size.
This reflects how most predators avoid attacking larger or equally sized animals—especially when hunting alone.
These decision-making steps help simulate realistic predator behavior, where energy efficiency and survival odds are important, and hunting strategies align with natural instincts.

Conclusion
With this prototype, I’ve created a basic simulation of survival of the fittest. In this ecosystem, herbivores roam freely, eating and mating, while predators—which can be spawned by the user—create pressure that forces herbivores to adapt in order to survive. This interaction also helps prevent overpopulation of herbivores, maintaining ecological balance.
To further expand and enrich the simulation, several improvements and additions can be made:
- Introduce flying and aquatic animals: This would add diversity to the ecosystem and create new environmental challenges and evolutionary paths.
- Enhance animal AI: The current AI is relatively simple. Improving decision-making, learning behaviors, and adding more nuanced state transitions would result in more realistic behavior.
- Advanced mutations and trait evolution:
- Allow for adaptive trait shifts, such as herbivores evolving into omnivores or carnivores when food is scarce.
- Add more detailed DNA traits, such as:
- Bite force (important for predators)
- Camouflage level
- Aggression level
These additions would deepen the evolutionary dynamics and allow for more emergent, lifelike behaviors within the simulated world.
Sources
- Khan Academy. (n.d.). https://www.khanacademy.org/science/ap-biology/natural-selection/natural-selection-ap/a/darwin-evolution-natural-selection
- Than, K., Taylor, A. P., & Garner, T. (2022, October 14). What is Darwin’s Theory of Evolution? livescience.com. https://www.livescience.com/474-controversy-evolution-works.html
- Mutation. (n.d.). https://education.nationalgeographic.org/resource/mutation/
- Mutations are the raw materials of evolution | Learn Science at Scitable. (n.d.). https://www.nature.com/scitable/knowledge/library/mutations-are-the-raw-materials-of-evolution-17395346/#:~:text=Mutations%20are%20essential%20to%20evolution,a%20defining%20aspect%20of%20evolution.
- DNA – Inheritance and genetics – KS3 Biology – BBC Bitesize. (2023, October 23). BBC Bitesize. https://www.bbc.co.uk/bitesize/articles/zc8txbk#zt8txbk
- Mutations are random. (z.d.). https://evolution.berkeley.edu/dna-and-mutations/mutations-are-random/
- GfG. (2024, 8 maart). Genetic algorithms. GeeksforGeeks. https://www.geeksforgeeks.org/genetic-algorithms/
- Mallawaarachchi, V. (2023, 21 september). Introduction to Genetic Algorithms — Including Example Code. Medium. https://towardsdatascience.com/introduction-to-genetic-algorithms-including-example-code-e396e98d8bf3
- 9. Evolutionary computing. (z.d.). https://natureofcode.com/genetic-algorithms/
- AncestrySupport. (z.d.). https://support.ancestry.com/s/article/Unexpected-Ethnicity-Results?language=en_US#:~:text=Only%20half%20of%20a%20parent%27s,your%20DNA%20with%20each%20other.
- The Organic Chemistry Tutor. (2021, 6 april). Work, Energy, and Power – Basic Introduction [Video]. YouTube. https://www.youtube.com/watch?v=_MR1Dp8-F8w

Vervolgstappen en overwegingen voor 27 maart ’24:
1. Probeer je niet alleen maar bezig te houden met het developen, maar ook met het uitzoeken van mogelijke oplossingen van wat je probeert te doen.
2. Probeer wat meer focus aan te brengen op je werk: is het een evolutie simulatie of biodiversiteit (meerdere soorten die met elkaar leven).
3. Sensors voegen een hoop toe, misschien dat je dit kan superchargen?