Cover Image for Darwin, An Evolutionary AI

Darwin, An Evolutionary AI

David Lythgoe

The Last Defender is our first title featuring a mash-up of the Survival, Defence and Strategy genres. One of the core design decisions was to promote replay-ability without the player simply relying on pattern recognition to defeat the waves. With set enemies coming from set directions, it would be fun the first few times but that anticipation and excitement a gamer feels when prepping defences becomes somewhat lost once they know ahead of the time what the enemy will do. We aim to change that with the Darwin AI system.

In this post, we discuss the design features of our Darwin AI system, what it does and how it can promote interesting sandbox and roguelike gameplay.

All of this, is by accident

The discovery of the evolutionary process in the real world was largely documented by Charles Darwin in the famous 'Origin of Species' literature. Through countless observations and record keeping, it was found that the way life adapts to its environment was through a process of 'natural selection', whereby, simply surviving long enough to reproduce in an environment meant you were suitable for it. The traits of the survivors are passed onto their children who are then born equip to survive. The traits of those that didn't survive to have offspring or not long enough to reach sustainability would simply die out.

This is all well and good, but how do you know if some other characteristic would thrive better in this new world? Humans look at 'design problems' and then design solutions to these problems but natural selection doesn't have the luxury of conscious foresight, it uses a far simpler and slow burn technique - and that is random birth defects. These defects that occur during birth, could actually turn out to be very effective in the world they are tested within and over time, become the norm because these traits allow them to survive longer. In summary, the evolving design of how effective life is to its environment, is purely by accident.

This is all very simplified science but it made us think how we can apply this model to our enemy waves and allow them to evolve to better suit their 'environment'.

Life as an enemy

The enemies in The Last Defender are fielded by a special commander, an AI that doesn't cheat, doesn't look at your base defences and make decisions, it simply 'breeds' the best performing soldiers so their children carry the same traits and go on to make future attacks.

You can think of enemy waves as generations of these children, their direction of attack and type as traits and performance as 'time survived' or 'damage done'. As an enemy launches its attack, some will be more effective against your defences and others not so. The enemies that performed better, then create more of that type of enemy from the most effective angle of attack to be used in the next wave. It's a trial and error process much like 'natural selection' discussed previously.

Of course, the human players adapt and change their defences, weapons, colonists positions constantly so what might have been an effective evolution last wave, is now not so. However, if we factor in the 'birth defects', there's a chance a small random percentage of enemy selected for the wave perform even better than those spawned as the 'norm' (traits based on previous waves best performers) which then go on to be the dominant traits for the next wave.

This is why we've named it Darwin.

Visualising Darwin

Below is a video showing the early stages of Darwin development, more specifically, passing on the traits of 'angle-of-attack'. You'll notice over the generations, the enemy (the balls) adapt to attack where defences are weakest.

Darwin will also take into account the best performing enemy types, so if players decide to use bolster precision damage like sniper rifles. It's likely the enemy evolution will start to favour enemies that are harder to hit. This ever changing battle and evolution means the waves are never the same which makes for a very interesting game dynamic.

Darwin's role in determining difficulty

Darwin AI, like many things in software, come with many editable parameters to fine tune and balance it through play sessions. They also become a great base for tuning difficulty and offering players a suite of properties to set up custom games. Let's explore some of those:

  • Base Wave Constant (Float) - this is the base wave power that is used in the power formula
  • Wave Power (Derived) - this is the total power limit that a wave cannot exceed. It is derived from Wave Number * Base Wave Constant * Session Difficulty Factor * Player Count Factor
  • Darwin AI (Allowable Types - Presets) - the allowable enemy types for the wave. Allowing more variety earlier can add to the difficulty
  • Darwin AI (Top % - Range (min/max)) - the percentage of the end-of-wave ranked score that is used to seed the spawning of the next wave. The smaller the percentage, the higher the fidelity of more effective enemy
  • Darwin AI (Random % - Range (min/max)) - the percentage of randomly spawned enemies. The higher the percentage the less effective enemies are spawned. This cannot be zero otherwise the algorithm cannot learn from random success/fails but can be adjusted for difficulty
  • Darwin AI (Segment Count - Range (min/max)) - segments are pie pieces. The more segments you have, the more narrow (and thus accurate) the spawning is which can target base weaknesses more effectively
  • Darwin AI (Harassment - (Presets)) - the frequency of out of wave random attacks that help seed Darwin to produce an effective big wave

As you can see, Darwin adds a lot of variety and dimensions to difficulty which we hope will really boost the longevity of play sessions but also create some crazy custom experiences that would be fun to watch unfold.

The rest is secret

Gamers are smart and often find ways to 'cheese' games by identifying their AI flaws or weaknesses. We are under no illusion that the same could happen to our baby Darwin! For these reasons, we sprinkle the evolution AI with a touch of battlefield tactics that would normally be employed by an experienced commander. An example would be, don't keep doing the same thing if it's not working.

We won't tell you what those are for the sake of spoilers but we can say our AI will never cheat. It can't see what it hasn't seen and can't act on information unless that information is explicitly gathered.

All in all, we hope you're as excited to play against Darwin as we are!

Follow Us

A new world exploration, survival and defence game that uses a genetic algorithm so enemies learn the best lessons from the last wave to use in the next.

No more set directions, set enemy types or set strategies. No wave will ever be the same!