The Pole Balancing Problem

The pole balancing problem is a classic in control theory. The case I've set up here is very simple, push the cart left or right in order to balance the pole.

You can also write some code in the editor below to control the motiion of the pole. A good controller should be able to keep the pole balanced and the cart central, even if you nudge it with left or right.

Instructions

Write some JavaScript to keep the poll upright and the cart central for as long as possible. You can nudge the cart with left and right (on the keyboard or the buttons). Click start to get going.

Grumpy cat.
Sorry, your browser doesn't support canvas. We don't need your sort here.