Avoid "spiral of death" by capping maximum number of ticks per frame #42
Labels
Bug
The observed behaviour is incorrect or unexpected.
C-Low Hanging Fruit
Ideal issue for new contributors.
S-Moderate
The fix or feature would substantially improve user experience.
T-UI
Involves the user interface.
Z-User Experience
This issue seeks to make the game more enjoyable to play.
At the moment, Swarm is susceptible to the "spiral of death" described at https://gafferongames.com/post/fix_your_timestep/ : when the amount of computation we have to do for a frame takes longer than the amount of time allotted for the frame, it starts getting further and further behind. This could in theory be triggered either by a lot of robots doing a lot of computation, or by the user pushing the ticks/second rate too high. If this happens, each frame will take longer than the previous frame and the game will essentially grind to a halt as it tries futilely to catch up but only gets further and further behind.
There is a simple way to avoid this, which is simply to cap the maximum number of ticks per frame (based on my own experience so far, a cap of around 25 seems reasonable). When it hits the cap, the game will slow down: it will essentially be running at a slower ticks/second rate than requested. Perhaps we could signal this by e.g. drawing the ticks per second rate in red, or something like that.
The text was updated successfully, but these errors were encountered: