Sponsored By

Featured Blog | This community-written post highlights the best of what the game industry has to offer. Read more like it on the Game Developer Blogs.

Anime 3D SFX's third game, Darwin's Nightmare, harnesses the power of evolution to generate a wide variety of evolving, mutating foes.

Thibaud de Souza, Blogger

April 21, 2014

6 Min Read

One the features of Darwin's Nightmare is the use of evolutionary computation to drive the exploration of a large combinatorial space defining the behaviour and appearance of enemy crafts.

In this game, all enemy craft designs are obtained by varying a unique genotype: whenever a new ship appears on the screen, individuals are selected from a mating pool and their digital DNA is recombined to create a new type. 

Early design for The strain's Logo

Ontogenesis: the mapping between genotypes and phenotypes

Since Darwin's Nightmare was a first for me (I did have experience using evolutionary algorithms for business applications or generative art) I decided to design simple, 16-bit genotypes. Each gene commands a specific ability (for example "shoot" or "speed boost").
(Occasionally, abilities collide or tend to override each other - if so, we 'just figure something out'). 

With my original design, setting genes was roughly equivalent to enabling power-ups:

  • [0000-0000-0000-0000] dumb, sluggish

  • [1111-1111-1111-1111] demi-boss

Is anything wrong with this? It depends. If you just want a game that gets harder as it goes, I guess it's fine...

...If, on the other hand, you'd like to use evolution as an exploratory/creative tool, this isn't a great start.

I wasn't especially happy with this situation. Instinctively, I started balancing the effect of genes, so that, for example, a "velocity" allele commanding faster speed would also trigger a debuff (say, slower firing rate).

Balancing the effect of genes in this way is a bit awkward. It's like saying that you don't want either foe to be stronger than the next. Even so it appears to work better than simple, linear combinations of power-ups so it's probably a good choice if you wanted to retrofit an evolutionary strategy onto an existing game system. 

Each game is seeded with 2 abilities (2 genes are set); others appear via mutations (A good trick that can be used to improve asset revelation).

Choosing a fitness fuction

Choosing a fitness function needn't be difficult. We would like the game to become increasingly challenging over time so what we need is a measure of how dangerous an enemy craft is.

As I designed Darwin's Nightmare as a casual shooter, I decided to go with the dreaded one hit kill. Consequently we can't rate the lethality of crafts within the scope of single match.
Fitness is determined by rating accuracy: the distance between the player and enemy bullets determines how accurate their aim is.

I factored in the distance from enemy crafts to the PC since a foe can also crash into the player ship. Sometimes the game can get into a pattern where enemy crafts stop firing and seem to be 'content' with grazing the player. I tweaked the game to ensure that this doesn't happen a lot but couldn't get myself to remove that component from the fitness function.

Don't take your fitness function for granted.

The pitfalls of implicit selection

In my original design, Foes would appear at the top of the screen like in your typical vertical shooter. Whatever enemies reached the bottom of the screen would be put into a (fixed size) mating pool. To generate each new ship, parents are selected using tournament selection (2-3 rounds).

This approach is intuitive: after a battle, the most skilled fighters are recombined to generate the next wave.

Interestingly, this introduces implicit (and mostly undesirable) pre-selection: in order to generate offsprings, an enemy ship must survive! What resulted from this was CYA style fighting, where enemy crafts would mostly evolve towards "zooming out of the screen as fast as possible" rather than hitting the PC.

Changing the original rule to "enemies that moved out of the screen, or died, are added to the mating pool" meant that dying early confered additional fitness(!).

I eventually solved the problem by adding foes to the mating pool as soon as they enter the game area. Not very intuitive but 'well behaved'.

Implicit selection criteria needn't be a problem - in fact, enemy pilots that value their own crafts might be more interesting opponents than suicide-fighters(!). 

Implicit (one might say 'natural') selection criteria, however, may easily upset the balance of an existing design.

Tweaks can have unpredictable effects

Like with most games that comprehend dynamic systems of sorts, even minor tweaks to the mass of underlying numerical parameters can have significant effects on gameplay.

Hiding behind the genotype-phenotype tandem inherent to our design, there is a set of meta-parameters (evocatively, I think of it as the game's own "DNA")  driving gene expression. Velocity gene? How fast? Rapid fire? How quick? Stealth? How does this translate to alpha values? ....

The way genes associate power-ups with debuffs makes Darwin's Nightmare very sensitive to numerical adjustments. This is a double edged sword: we can refresh gameplay from one release to the next, but once I get any significant success with a given variant, I may find myself reluctant to update anything at all for fear of upsetting the game's balance.

Making evolution visible

While it made sense to promote the game's evolutionary twist, this requires that evolution be as visible as possible.
To begin with, reproduction happens off-screen. Not ideal.

Ever played "Space Invaders Infinity Gene"? I really can't convince myself that this game involves Darwinian evolution of any kind. "Designing a game about evolution" is a designer thing. Making a game that utilizes evolution is another.

The blind watchmaker may turn out to be invisible as well.

While I think evolution should be a lot more visible (I even considered displaying infographics) in the game, it would appear that early adopters are somewhat satisfied with the following finds (paraphrasing what I heard on gaming forums):

  • "There is a great variety of enemy crafts" - players expect some kind of combinatorial/generative system; they are satisfied to see that the game fulfills this promise. 

  • "The game gets hard pretty quickly with lots of bullets flying around" - survival of the fittest?


Introducing evolutionary components in a game needn't be hard and can add replay value. If you're touting evolution as a game feature, be prepared to spend more time since it may be easier to use evolution as a "blind game designer" than to provide a shiny/transparent demonstration of its applications.

One regret (so far) is that I didn't find the time to put more thought into the genotype-phenotype mapping: feeding non-linear, complex mappings into your evolutionary algorithm will compliment its creative potential.

Darwin's Nightmare is a mobile game available on the iPhone, iPad and iPod Touch.


Read more about:

Featured Blogs
Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like