
In 1997 I was working with Chris Hecker on a game physics simulator that never quite saw the light of day. Chris was the one into the physics, so he wrote most of the simulator and I wrote the more traditional game code. Apart from Seamus Blackley and David Wu, very few people at the time were doing anything like what Chris was trying to do with physics simulation, and as such, he pretty much had his hands full doing the necessary research to get everything working. So while he was working on improving the physics, one of the things I often did was write little physics test setups.
One day I thought it might be interesting to create a little "gymnast rings" simulator. So I wrote some code that called the physics simulator to create some rigid blocks. I constrained them together to form a seven-segment "gymnast", and set the constraints such that the three body links could only bend along one axis, but the four arm links could rotate arbitrarily relative to the body. Finally, I constrained his two "hands" to absolute positions in the world so that he would hang as if holding imaginary rings.
After getting the setup right, I was pleased to see that the simulator ran the gymnast perfectly. He hung gracefully in one place, and using the mouse-spring, I could pull him around and see that everything worked well. So I took the logical next step, which was to hook up a keyboard input to his torso.
My goal was to make it so that you could push the up or down keys to exert positive or negative torque about the torso, allowing you to control the bending of the body and maybe work up enough momentum to do some interesting gymnast-like things. But as luck would have it, a stray typo in the code made it so that instead of using the value from the keys to exert torque, it actually used the result of a computation that was a completely bogus residual value from some floating point computations about the body position.
But I didn't know that yet. So I ran the app, expecting to start controlling the gymnast with the keyboard. But instead of seeing the gymnast hang still, waiting for me to push a key, immediately upon running the app I saw the animation depicted in the attached video.
As you might imagine, I was completely shocked. I had no idea what was going on. It was a classic "ghost in the machine" moment. The flipping never really stopped, it would just keep doing crazy random gymnast maneuvers as long as you ran the program. If for some reason he stopped, you could just pluck him with the mouse-spring and he would start right back up again.
Chris wasn't in the office when this happened, and so when he returned, I played it cool and just said, "Hey, check out this gymanst simulator I did." He was as shocked as I was, and couldn't believe I had perfected so much controller logic in a matter of hours. But sadly, I had to confess that in fact I hadn't done any controller logic at all, and actually, I didn't have any idea what was going on.
We later went back and tried to figure out what had happened. Although we quickly saw the bug in the code that caused the behavior, it was never really intuitively clear to us how it did what it did. It was basically just an extremely strong discrete positive or negative torque applied to the torso based upon floating point noise coming out of some joint calculations. So in the end, our takeaway was very simple: random noise produces really amazing motions when you feed it through a good physics simulator :)
Fast forward ten years, and I'm catching up on my daily TIGSource when I see a 2D version of the same thing! The first thought that crossed my head was, I wonder if he's tried feeding it random sawtooth-shaped noise yet? I hope so :)
Chris and I chatted in e-mail about the link, and we decided it might be a good time to get a video capture up of our old "hangman" (the name I gave the gymnast's executable) for those who never saw it at the time.
Recommend this page on: Twitter, Digg, Delicious, StumbleUpon, Reddit, Facebook