Difference between revisions of "Maximum Escape Angle"

From Robowiki
Jump to navigation Jump to search
(adding category "Robocode Theory")
(Cleaning up formatting)
Line 3: Line 3:
 
== Calculation ==
 
== Calculation ==
  
Let's assume a triangle with sides <code>a</code>, <code>b</code>, and <code>c</code>; and angles (vertices) <code>A</code>, <code>B</code>, and <code>C</code>; where <code>A</code> is the angle opposed to <code>a</code>, <code>B</code> to b, and <code>C</code> to <code>c</code>. The [http://en.wikipedia.org/wiki/Law_of_sines Law of sines] says that:
+
Let's assume a triangle with sides <code>a</code>, <code>b</code> and <code>c</code>, and angles (vertices) <code>A</code>, <code>B</code>, and <code>C</code>, where <code>A</code> is the angle opposed to <code>a</code>, <code>B</code> to b, and <code>C</code> to <code>c</code>. The [http://en.wikipedia.org/wiki/Law_of_sines Law of sines] says that:
<pre>a/sin(A) = b/sin(B) = c/sin(C)</pre>
 
  
 
<pre>
 
<pre>
 +
    a/sin(A) = b/sin(B) = c/sin(C)
 +
 
                   A
 
                   A
 
                   /\
 
                   /\
Line 29: Line 30:
 
-> A = asin(Vr/Vb * sin(C))
 
-> A = asin(Vr/Vb * sin(C))
 
</pre>
 
</pre>
We don't know the value of<code>C</code>, but we can take the worst scenario where
+
We don't know the value of <code>C</code>, but we can take the worst scenario where
<code>C = PI/2</code (<code>sin(C) = 1</code>) to get a [[Maximum Escape Angle]] of  
+
<code>C = PI/2</code (<code>sin(C) = 1</code>) to get a Maximum Escape Angle of  
<code>A = asin(Vr/Vb * 1 ) = asin (Vr/Vb)</code>.  
+
<code>A = asin(Vr/Vb * 1) = asin (Vr/Vb)</code>.  
  
With a maximum Robot velocity of 8.0, a theoretical [[Maximum Escape Angle]] would be <code>asin(8.0/Vb)</code>. Note that the actual maximum depends on the enemy's current heading, speed, and [[Wall Distance]].
+
With a maximum Robot velocity of 8.0, a theoretical Maximum Escape Angle would be <code>asin(8.0/Vb)</code>. Note that the actual maximum depends on the enemy's current heading, speed, and [[Wall Distance]].
  
 
== See Also ==
 
== See Also ==
  
* [[Precise Maximum Escape Angle]] - Some bots use a more sophisticated calculation for [[Maximum Escape Angle]], using [[Precise Prediction]].
+
* [[Maximum Escape Angle/Precise]] - Some bots use a more sophisticated calculation for Maximum Escape Angle, using [[Precise Prediction]].
  
 
[[Category:Robocode Theory]]
 
[[Category:Robocode Theory]]

Revision as of 01:50, 12 November 2007

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

Calculation

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

     a/sin(A) = b/sin(B) = c/sin(C)

                  A
                  /\
                 /  \
             b  /    \  c
               /      \
              /________\ 
            C     a      B

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</code (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.

See Also