## SCV Acceleration

Below is a graph of the position, velocity, and acceleration of an SCV while it travels from one point to another with a distance of 4 grids between them. The SCV only changes position at every game tick, so the distance traveled function is not continuous and therefore not differentiable.

We can approximate the velocity at game tick $i$ using: $v(i)=\frac{d(i)-d(i-1) }{\frac{1}{16}}\frac{\text{grids}}{\text{game seconds}}$

Approximate the acceleration at game tick $i$ using: $a(i)=\frac{v(i)-v(i-1) }{\frac{1}{16}}\frac{\text{grids}}{(\text{game seconds})^2}$

We must also define the boundary values $v(0)=0$ and $a(0)=0$. The rest of this post covers some of the details of how to perform the calculations using a program such as Matlab/Octave. The distance values were obtained by using the programming features of the map editor to measure the distance of the SCV from its starting point at intervals of one sixteenth of a game second. Here is the code to create a vector with the distance values:

d=[0,
0.0293,
0.0586,
0.0977,
0.1465,
0.2051,
0.2734,
0.3516,
0.4395,
0.5371,
0.6445,
0.7617,
0.8887,
1.0254,
1.1719,
1.3281,
1.4941,
1.6699,
1.8457,
2.0215,
2.1973,
2.3730,
2.5488,
2.7148,
2.8711,
3.0176,
3.1543,
3.2813,
3.3984,
3.5059,
3.6035,
3.6914,
3.7695,
3.8379,
3.8965,
3.9453,
3.9844,
4.0000,
4.0000,
4.0000];

And this code creates the vector of time values at which each of the distances was measured:

t=0.0625*[0:1:39];

Here is the code to calculate the vector and acceleration values:

v=[0;diff(d)/(1/16)];
a=[0;diff(v)/(1/16)];

And the graph can be created using the plot function:

hold on;
plot(t,d)
plot(t,v)
plot(t,a)
hold off;

This entry was posted in Game Mechanics and tagged , , , , , . Bookmark the permalink.