Ludum Dare: Evolution

This past weekend was a Ludum Dare Competition.

The comp starts on Friday night for the East Coast, but I was out doing Friday night things, and didn’t even know the theme till Saturday morning. Evolution.

After a few days of hacking away, I had a rough game to submit: Biods.

[![](http://daydalus.net/DaydalusStudio/wordpress/wp-content/uploads/2012/08/Biods1-300x223.jpg "Biods1")](http://daydalus.net/DaydalusStudio/wordpress/wp-content/uploads/2012/08/Biods1.jpg)
Biods
# Evolution:

I’ve always been fascinated with the interplay between finite, discrete rules and infinite, random output. Conway’s Game of Life was what first got me excited about emergence. Emergence goes hand and hand with evolution – you could even call evolution a subset of emergence: the pieces of a system changing over time to better adapt to their environment. The fact that the objects will automatically fine-tune to better survive in the world is pure emergence.

For Biods I started out with the code: Genetic Code that is. The basis of the simulation was the DNA of each Biod. In this case it was 7 attributes that described how a Biod would live. Color, Speed, Size, Features (like feathers, horns), Personality, Reproduction and BroodSize.

The different colors were essentially different species. Only like colors would mate, and Aggressive biods would only attack differing colors.

Each biod also required energy, which was replenished by eating food (or killing an enemy Biod). Depeleted of energy, the Biod would die.

And each biod could also act out 4 different actions, based on some rudimentary AI: Move, Eat, Fight, or Mate.

The key to evolution was adding in some randomness, accomplished by mutation. Each time a Biod reproduced, the offspring could have slightly different DNA.

So now we had all the elements of life. I drew the Biods on the screen with some simple cartoonish circles, and let them move around with basic acceleration and velocity.

The first few builds all the carnivores devoured each other and a single color quickly dominated the entire screen.

I tweaked a few variables and rebuilt. Now, nothing would live more than a few seconds, leaving a wasteland.

And so it went for hours. There were dozens of variables to tweak, from the size of the biods, the speed they could traverse the screen, how much energy they would get from eating or killing, how fast they would starve, the rate of mutation, etc. Tweaking each one of these variables could drastically affect the outcome.

Sure, the behavior was emergent, but it didn’t mean it was “interesting” emergence. Let alone something that would be useful in a game.

In the end, I decided that a few of the variables would comprise the gameplay itself: Starvation and Mutation Rate.

Starvation and Mutation:

Decreasing the Starvation Rate means that biods won’t ever die. The dominant biods will quickly fill the screen, and there won’t be any evolutionary pressure in the game. Only aggressors (carnivores) will be able to kill other biods.

[![](http://daydalus.net/DaydalusStudio/wordpress/wp-content/uploads/2012/08/Biods2-300x168.jpg "Biods2")](http://daydalus.net/DaydalusStudio/wordpress/wp-content/uploads/2012/08/Biods2.jpg)
High mutation and starvation means lots of diversity and changing populations
Increasing Starvation will quickly kill off the weaker Biods. If carnivores have prey (herbivores) they will live longer, but as soon as the prey dies off, the predators will die off a few rounds later. Slow moving or static biods live longer and flourish.
[![](http://daydalus.net/DaydalusStudio/wordpress/wp-content/uploads/2012/08/Biods3-300x169.jpg "Biods3")](http://daydalus.net/DaydalusStudio/wordpress/wp-content/uploads/2012/08/Biods3.jpg)
Reduce mutation rate and populations will start to stabalize
Most games will work well with around 5 for the Starvation Rate.

Increasing Mutation will mean that offspring will differ greatly from the parents. This can be useful to add a lot of variety to the game, and eventually you’ll probably uncover every combination of Biod. You’ll end up with a lot of diversity, but no one color will dominate.

[![](http://daydalus.net/DaydalusStudio/wordpress/wp-content/uploads/2012/08/Biods4-300x167.jpg "Biods4")](http://daydalus.net/DaydalusStudio/wordpress/wp-content/uploads/2012/08/Biods4.jpg)
Only a few species of carnivores are left after a few rounds. Note the large amount of uneaten food.
Decreasing Mutation will keep offspring the same as the parents. This is key to completing the missions in the game, where the goal is to grow certain populations.
[![](http://daydalus.net/DaydalusStudio/wordpress/wp-content/uploads/2012/08/Biods5-300x169.jpg "Biods5")](http://daydalus.net/DaydalusStudio/wordpress/wp-content/uploads/2012/08/Biods5.jpg)
With no herbivores to eat, the populations of carnivores die out.
Usually you’ll want to increase mutation and starvation until you get a population you like, then decrease both and let those populations grow.

Interesting Patterns:

One of the fascinating things about the game was how lifelike the emergent behavior became. It almost reminded me of bacteria growing in a petri dish. As soon as a niche opened up, a biod population would evolve to fill it. Lots of food on the board? Asexual herbivores with large numbers of offspring would take over. High diversity of colors, but not a lot of food? Carnivores would dominate.

Static biods would also form little colonies in a single space. Since they couldn’t move, if food was plentiful, they’d always have a mate nearby. And since dead biods had a chance to drop food, the static colonies could feed themselves with corpses of their siblings (coral reef, trees?)

These kinds of behaviors made playing around with the simulation potentially more fun than the actual game.

[![](http://daydalus.net/DaydalusStudio/wordpress/wp-content/uploads/2012/08/Biods6-300x168.jpg "Biods6")](http://daydalus.net/DaydalusStudio/wordpress/wp-content/uploads/2012/08/Biods6.jpg)
Low starvation and mutation leads to homogenized populations that can be wiped out relatively easily.
# Design:

But design was still paramount. Each one of those 7 behaviors that made up the DNA contributed to the final emergence. Also, I used discrete values for each behavior, instead of a continuous value. So I had to tune each category. Getting those values wrong could lead to boring or overly chaotic behavior, which would ultimately be less interesting for the player/user.

In the real world, reality “emerges” from every level below it, from particles, to atoms, to molecules, to biochemistry, to cells, to organisms, to ecosystems. In a simulation, we have to pick a perspective, and draw a hard line in the code: these are my axioms.

So design will always be key.

[![](http://daydalus.net/DaydalusStudio/wordpress/wp-content/uploads/2012/08/Biods7-300x130.jpg "Biods7")](http://daydalus.net/DaydalusStudio/wordpress/wp-content/uploads/2012/08/Biods7.jpg)
A group of herbivores moving towards available food.
# Biods: The Game:

The actual game of Biods was tacked onto the simulation. The screens and controls were tacked on top of that. So if any polish needs to be done, it’s to the actual “game” parts.

The “goal” of each level is to raise a certain population of biods (50 Reds, 300 Orange, etc). Currently, this is defined by color, but could be changed to account for any number of traits.

It’s quite a challenging (and probably frustrating) game. I’ve been able to beat every level except 5. I assume the feeling of defeat is similar to that of a biochemist that discovers a contamination in his experiment, ruining the entire thing.

Just like in real life, once it gets going in all its messy chaos, it’s probably impossible to untangle. Better to just hit reset.

I’m still debating whether the game would be better if the player had more control. If they could tweak each individual gene, rather than hitting Mutate, would it make the game trivial? What about pausing the simulation, mutating what needs to be done, and then resuming?

[![](http://daydalus.net/DaydalusStudio/wordpress/wp-content/uploads/2012/08/Biods8-300x170.jpg "Biods8")](http://daydalus.net/DaydalusStudio/wordpress/wp-content/uploads/2012/08/Biods8.jpg)
A decimated population of homogenized species, once the starvation rate was increased.
# On Ludum Dare:

LD48 is a great thing for the indie scene. It’s really awesome to have hundreds (thousands?) of game developers think outside the box and hack away for a weekend.

I’m really interested to see what’s out there! Will be putting up my top 10 games shortly.