Tech Post #1 - Creatures and Evolution


The most crucial part of this project is the evolving ecosystem, so this post will give some context as well as share some preliminary work in developing this system. 


An Evolutionary Algorithm requires two basic components:  a fitness function (how "correct"/ successful a solution is) and a way of encoding traits that use the fitness function.   This encoding also has to support partial inheritance of traits from parents.  The concept is simple, the difficulty is in finding a creative implementation that works. 


For this project, we have Populations (which share common genes between individuals) which in turn belong to species (groups that can produce offspring).  This helps differentiate between species and allows forming of niches where some species may thrive.  Each species will have its own chromosomes, which hold the potential for that species.  Each chromosome will have a set of patterns (genes) that,  if present  determine the traits and attributes of that creature.  Sounds a lot like biology right?  If done correctly, THIS is what holds the potential for truly unique creatures.  More diverse genes means more unique creatures. 


As for the fitness function, traditionally this is something we want to "solve".  But in our case, it needs to be fluid and change as our ecosystem changes.  Taking inspiration from nature, we can simplify our equation to be a combination of "ability to find food" and "ability to survive".  The first part can mean that high competition can result in low scores, as there are too many mouths to feed.  The second means that each species must account for other species that prey upon them.   Once players are added, they will especially factor into this second part as well.  This could mean that creatures with desirable drops must either adapt against player strategies or become extinct. 


This all sounds good in theory, but what about in practice?  I prototyped a simple example using Python (note: THIS project uses Unreal Engine and C++) to evaluate the concept.  Here's what I saw after running several species for 100 generations:


In the above example, creatures with "arn" at the end are simple carnivores (only gain food by eating others) while the others are simple herbivores (gain food from a shared,  limited source).  Before going into what this means, here's a (very) simple overview of attributes:


Strength (stre) - ability to deal damage by force

Dexterity (dext) - ability to deal damage by precision

Vitality (vita) - ability to absorb damage

Agility (evas; was formerly evasion) - ability to escape combat/ sneak up on prey

Knowledge (know) - ability to "hedge your bets", lowers max possible combat effectiveness

Intuition (intu) - ability to avoid combat (by spotting enemies)

Foresight (plan; was formerly planning) - ability to outnumber a foe, raises minimum effectiveness in combat

Luck (Luck) - all around modifier limited to certain max/min benefit


In reality, these attributes would be a small part as many modifying genes would play a part (horns, pack hunting, armor, hooves, etc.).  However for our prototype we focused on a simple fitness function.  Even with this, we consistently see not only a variety of winning patterns but niches form!  

  • "Barn", a predator focusing on stealth (evas) and combat skills (stre and dext) with a reasonable amount of luck.  This is similar to a tiger, an apex predator
  • "Carn" is a slightly less powerful predator, but compensates with higher ability to spot and avoid other predators. 
  • "Aarn" is nowhere near as good a hunter, and relies in luck and avoiding the other predators, an effective scavenger strategy.   
  • Even for herbivores, while most adopt a "deer-like" strategy of spotting and avoiding threats (intu), "A" has actually developed to stand it's ground and look for opportunities to escape (high dext, moderate stre, high evas).


It's incredibly good to see this behavior, given how incredibly simple the design is already.  As more traits are added (many with a sort of rock-paper-scissors behavior), we should see way more variance in survival strategies.  Just to verify that this was "evolved behavior" and not artificially random,  we can look at how these species changed over time:


Even at a glance we can see some non-intuitive behavior, carnivores de-evolving strength and herbivores de-evolving intuition, in order to create a niche for themselves to survive in.  Very promising!


Tl;dr, even in a very simple setup we can see our creatures evolving different patterns for survival.  Ideally, as we add more and more traits we'll see more and more diverse strategies.  Remember that with a limited number of genes, creatures will have to specialize to survive!


Next post will include the initial work done in Unreal Engine while I prepare for living, "thinking" creatures!  Once we can simulate creatures moving/existing in an environment, we can start tracking their evolution patterns and survival strategies on a more practical level.  Sorry for any text-walls, I'll try to include more images/gifs in future posts!

Comments

Log in with itch.io to leave a comment.

(1 edit)
"Aarn" is nowhere near as good a hunter, and relies in luck

I can't help but feel personally called out by this aspect of the evolutionary algorithm.