Maximum Escape Angle

From RoboWiki
Jump to: navigation, search

When firing, the Maximum Escape Angle (MEA) is the largest angle offset from zero (i.e., Head-On Targeting) that could possibly hit an enemy bot, given the Game Physics of Robocode.


Let's assume a triangle with sides a, b and c and angles (vertices) A, B, and C. A is the angle opposite to a, B is opposite to b, and C is opposite to c. The Law of sines says that:


Now let's say that your bot is in the vertex A and the enemy bot is in the vertex C. We will fire a bullet with angle A to hit the bot in vertex B. We know the value of b (it is the distance D from your bot to the enemy). We don't know c, but we know that it will be the distance traveled by the bullet. Also, we know that a will be the distance traveled by the enemy bot. If we put a, b, and c as a function of time, we have:

b = D
c = Vb * t (Vb is the bullet speed)
a = Vr * t (Vr is the enemy bot velocity)

Now, using the Law of sines:

   a/sin(A) = c/sin(C) 
-> Vr*t / sin(A) = Vb*t / sin(C) 
-> sin(A) = Vr/Vb * sin(C) 
-> A = asin(Vr/Vb * sin(C))

We don't know the value of C, but we can take the worst scenario where C = PI/2 (sin(C) = 1) to get a Maximum Escape Angle of A = asin(Vr/Vb * 1) = asin (Vr/Vb).

With a maximum Robot velocity of 8.0, a theoretical Maximum Escape Angle would be asin(8.0/Vb). Note that the actual maximum depends on the enemy's current heading, speed, and Wall Distance.

Prove by Beaming

Main article: Thread:User talk:Xor/Better MEA formula/Tradiotional MEA proof

First of all we notice that even the slowest bullet is faster than a bot at full speed. Thus any bullet eventually hits a bot. Now we assume that both the bot and the bullet are spherical points and move in vacuum :), also that there are no walls. We also assume that the bot can reach maximum speed instantaneously.

Let's put the firing bot in the origin and the target somewhere on the right of the x axis (no y displacement). Now we notice that in order to hit the bot, the bullet must have exactly the same y projection of the speed as the target bot.

Vbullet_y = sin(theta)*V_bullet = Vbot_y

Sin V_bullet is fixed in a given situation, the maximum theta (MEA) will be when Vbot_y is maximized, i.e. V_bot_y = V_bot. Substituting it above, we obtain traditional formula

MEA = asin( Vbot/Vbullet )

See Also

v  d  e 


Firing Angle
See Also: Category:Targeting
Personal tools