backspaces/agentscript — pull request #5 by sfentress (2013-03-25 20:20:52+00:00)
Title: Add ability to speed up or slow down model

These commits separate out the repaint cycle and the step cycle into two different timers (for discussion on this see http://www.chandlerprall.com/2012/06/requestanimationframe-is-not-your-logics-friend/).

This then allows us to change a model's step frequency (slowing down or speeding up) without affecting the repaint cycle. The model will always try to repaint at the browser's "natural" frequency (using setAnimateFrame), but will use setTimeout to schedule the next step.

I have found in the Global Climate model that the model can be sped up to about 80 steps/second, without the repainting getting choppy.

This can be seen by moving the Speed slider below the model at http://concord-consortium.github.com/agentscript/models/global-climate.html

Please let me know if you have other ways you might want to accomplish this. I'd be very happy to discuss other solutions that would achieve the same effect.