First test with genetic algorithms

What can be seen on the video are 10 lines that evolve so that their tips get closer to the target. When the target is moved by the user, the lines follow.
After every frame the best 5 lines, that is, the lines with tips closer to the target, are selected to continue to the next frame. They are duplicated and all of them are subjected to mutation. When the lines get mutated their joints’ angles change a little. Before the next frame the selection of the 5 best happens again and the process repeats. This process drives the lines’ tips closer and closer to the target.

On the video you can see all the lines being reset several times. When this happens they all are regenerated and start with totally random positions but quickly converge towards the target again. It can also be observed that the number of joints are increased and decreased sometimes, and some aspects of the drawing are changed (curved lines are replaced by straight lines, black dots appear on every joint).

This is my first experiment with genetic algorithms. This application was done so that I could put to practice some of the basic principles of genetic algorithms and also learn more about them.

After I came to the idea of making a platform game using genetic simulation on it, making a test applications using those algorithms was a good way to see them working in practice and start having ideas of how to use them on the actual game.

The application was made in Xcode using openframeworks with a modified version of the ofxDna add-on.

Leave a comment