Invaderz is a cool little microgame (space bar to shoot, A/left arrow and D/right arrow to move) which demonstrates some big potential for artificial life in games: It's basically like the classic game Space Invaders, but any time you kill an invading alien, a genetic algorithm passes its genes on to the next generation of invaders. Sometimes those genes mutate, and sometimes those genes make the invaders more dangerous. In other words: The aliens artificially evolve to become better predators.
"Usually in a more traditional genetic algorithm," developer Victor Ribeiro tells me, "A mutation has only a small chance to happen, like 1%." To speed this evolutionary simulation up, he coded the mutations to happen 10% of the time. "Playing the game you might see some enemies that are very similar to another, with just one small difference: the mutation. That small difference will affect how the enemy moves; maybe it will affect it in a positive way, maybe not. The thing is, that mutation is unique."
So over time, they could theoretically evolve to the point where the aliens are better than the human player. (Darwinian theory in action, only with more pew-pew-pew sounds!)
In tests, Victor has seen the aliens evolve to become faster, so "by the time [the bullet] arrives at the enemy's location, the enemy will be long gone."
The code is available on his GitHub if you want to play with it. Seems like this could be a great system to implement into full-fledged simulation games. The thing to keep in mind, as Victor cautions, is that evolution is a long process and most mutations are not a benefit or disadvantage, especially in a game context:
"You just have to think carefully about the genes of the thing you are trying to model," as he puts it. "If you look at us, humans, we have a gene that is responsible for the colors of our eyes, skin, hair, a gene that is responsible for our physical traits, to our intellect... You just have to do the same for your more complex games." In other words, maybe concentrate on mutations that are visible in gameplay, for instance: "If I cross an enemy that is very strong with one that is very fast, I might have a super enemy that is both fast and strong."
Hat tip: Jason Kottke's blog.
Comments