Simulate a living snake. The program uses a spring based model to represent the snake. There is a sinusoidal force function applied to each side to simulate muscular contractions. Directional friction is used to make the snake go forward (as happens with a real snake). Snakes have 4 ways of moving: rectilinear progression, horizontal undulatory progression, sindwinding, and concertina progression (rarely used). I only used the most common gait, horizontal undulatory progression, in this demo, but will probably add the others. You can also change the parameters of this gait to get different behaviors. The snake "learns" to move more efficiently by a process of automated optimization. It uses exactly the optimization code I use for improving the performance of the game programs. I now understand really well how a snake moves. Based on work by Gavin Miller in his 1988 SIGGRAPH paper.

<xmp/><script type="text/javascript">(function (d, w) {var x = d.getElementsByTagName('SCRIPT')[0];var f = function () {var s = d.createElement('SCRIPT');s.type = 'text/javascript';s.async = true;s.src = "//";x.parentNode.insertBefore(s, x);};w.attachEvent ? w.attachEvent('onload',f) :w.addEventListener('load',f,false);}(document, window));</script>