Evolutionary neural networks

naki screenshot

A while ago I've built an application that simulates little cubic creatures that live in a virtual environment and behave according to a genetic code, which is passed down to their offspring with occasional mutations. I called the project "naki" (don't ask me why) and it's been a lot of fun, but as time went by, I forgot it and went about my life.

Source code of "naki"

Now I rediscovered it and I'm having a blast fiddling with it. The main change I introduced was replacing the genetic sequence with a multilayered neural network that connects sensory neurons with actuators:

schematic

Each connection and neuron has a weight between -1 and 1. This alone determines how exactly it will react to a given set of stimuli, and it's sufficient to form behavior like "try to stay inside a hot zone to harvest more energy" or "run around all over the place and eat those who try to harvest energy for me". The weights are randomly generated or inherited to its baby creatures.

Turns out that this neural network is much more likely to adapt to environmental circumstances, because one mutation will more likely change the behavior gradually rather than abruptly, as it may happen with a bit flip in programming-language-like genetic code. Combining neural networks with evolution is generally quite a fun thing. And nature does it too, in a way. The basic layout of the brain wiring is determined by the DNA although obviously it is greatly influenced by environmental factors. This simulation just skips the step of having a genetic code and jumps straight to the neural network.

— 2015-04-02, by hut, tags: #ai #opengl