Frame Rate

From StarCraft AI, the resource for custom StarCraft Brood War AIs
Jump to: navigation, search

The "frame rate" in Starcraft refers to how often the game is being updated, not how often images are being drawn on the screen (technically, Starcraft has an infinite frame rate for graphics). This is more commonly known as the logical frame rate. Starcraft does not limit the logical frame rate by seconds, rather there is a timer that specifies the number of milliseconds Starcraft should wait before executing the next frame. To calculate the logical frame rate, we take 1000 (number of milliseconds in one second) and divide it by the value (in milliseconds) that the game waits for. These values depend on the game speed, and are as follows (rounded to nearest hundredth):

  • Slowest: 1000ms/s ÷ 167ms/frame = 5.99 FPS
  • Slower: 1000ms/s ÷ 111ms/frame = 9.01 FPS
  • Slow: 1000ms/s ÷ 83ms/frame = 12.05 FPS
  • Normal: 1000ms/s ÷ 67ms/frame = 14.93 FPS
  • Fast: 1000ms/s ÷ 56ms/frame = 17.86 FPS
  • Faster: 1000ms/s ÷ 48ms/frame = 20.83 FPS
  • Fastest: 1000ms/s ÷ 42ms/frame = 23.81 FPS

BWAPI's setLocalSpeed function has the ability to change this value.

What does Starcraft do when it is not executing the frame?

Starcraft will draw graphics to the screen, poll for input, update the screen position, update minimap pings, etc.

What does frame skip do?

By default, Starcraft only uses its frame skipping capability for watching a replay on x16 speed. What Starcraft's frame skip does is execute X number of game frames without leaving the game loop to draw graphics or poll for input. This allows Starcraft to exceed the maximum capacity it would have if it would normally try to run at infinite game frames per second.

BWAPI's setFrameSkip function has the ability to change this value. By default, it is 1, meaning it updates the game 1 time before exiting its loop and drawing graphics.