An Adventure in Genetic Animation Algorithms
Oct 13th, 2010
1 Comment

Here’s a project that I did a couple years ago. I’ve had the videos posted for a while but never had a good write up. I was taking an artificial life course at the time and was given the chance to come up with my own project. My idea was to evolve a walking animation for an artificial creature. So given a physical model for a creature and some set of constraints I wanted to see an organic looking walk evolve. To make things interesting I chose to model my creature after a spider since it would have many legs and many degrees of freedom for its movement. In the end it was fairly successful:

However, getting to this result took some time.

Initially I made a spider with a high center of gravity and lots of joints. I implemented a very simple genetic algorithm that fed target joint velocities to PhysX. Each animation was scored based on how far the spider traveled. Many animations were tested in each generation and the best survived to be the basis for the next generation. I gave the animation about a day to evolve and came back to find some unexpected results:

There were many things wrong this, probably the most important being the design of the spider itself–it was top heavy and stiff. I tweaked the spider a bit and gave it another go. The result was that the spider did indeed move forward now:

Although, this was mostly due to it twisting around. Something fundamental was clearly wrong. I went back to the drawing board and simplified the spider. I removed some of the mid-leg joints to make the animation simpler. I also noticed that real spiders tend to have a low center of gravity. I did my best to replicate this by lowering the body. In addition, I changed how the motion controller worked. Instead of maintaining a table of joint velocities I evolved a Fourier series for them and gave each leg its own amplitude and domain offset. The result was a spider that looked nice (well, nicer at least) and wanted to walk. It couldn’t walk far, but it certainly wanted to:

I gave a bit more weight to the feet after this and let the joints exert more force. After a few hours of simulation, the result was something that moved significantly further forward than anything before:

The animation was doing exactly what I asked “move as far forward as fast as you can”. Clearly I had to better state what I wanted. I refined the animation’s objective to be “move as far forward as fast as you can without letting your main body touch the ground”. Now I was getting there:

The spider had a nice awkward walk at this point. It would eventually drift off course though, so it had to be corrected. I made a few minor tweaks to the body and let it evolve for a week. The end result was far from life like, but it worked and could continue walking indefinitely.

If I had to do this project over again I would keep two things in mind: 1) a good animation only comes from a good model. Get the model right the first time and you won’t waste much time. 2) describe precisely what you want the animation to do in your objective function. In this case I realized that moving forward is not the same as walking forward.

For anyone that’s interested here’s what the final spider looks like without any animation forces applied:

This entry was posted Category: Articles, Projects
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One Response to “An Adventure in Genetic Animation Algorithms”

  1. Mark F says:

    Really, really cool! Thanks for posting

Leave a Reply