Difference between revisions of "GuessFactor"

From Robowiki
Jump to navigation Jump to search
(Adding image caption and example calculation)
m (Fixing typos)
Line 3: Line 3:
 
A way of measuring a firing angle which, unlike a raw [[Bearing Offset|bearing offset]], takes into account the enemy's relative direction at fire time and the [[Maximum Escape Angle|maximum escape angle]] for the specific firing situation.  
 
A way of measuring a firing angle which, unlike a raw [[Bearing Offset|bearing offset]], takes into account the enemy's relative direction at fire time and the [[Maximum Escape Angle|maximum escape angle]] for the specific firing situation.  
  
A GuessFactor of 1.0 represents the bearing offset that the enemy would reach if he maximized his escape angle while moving in his current direction relative to the firing bot (i.e., clockwise or counter-clockwise), -1.0 represents the bearing offset that the enemy would reach if he maximized his escape angle after reversing directions, and 0.0 represents the bearing offset that points directly at the enemy (as in [[head-on targeting]]).
+
A GuessFactor of 1.0 represents the bearing offset that the enemy would reach if it maximized its escape angle while moving in its current direction relative to the firing bot (i.e., clockwise or counter-clockwise), -1.0 represents the bearing offset that the enemy would reach if it maximized his escape angle after reversing directions, and 0.0 represents the bearing offset that points directly at the enemy (as in [[head-on targeting]]).
  
 
<!-- We need to be sure the image won't overlap with the sample code. -->
 
<!-- We need to be sure the image won't overlap with the sample code. -->
Line 14: Line 14:
 
double maxEscapeAngleCounterclockwise = ...;
 
double maxEscapeAngleCounterclockwise = ...;
  
double maxEscapeAngle = (bearingOffset) < 0 ?
+
double maxEscapeAngle = (bearingOffset < 0) ?
 
     maxEscapeAngleCounterclockwise : maxEscapeAngleClockwise;
 
     maxEscapeAngleCounterclockwise : maxEscapeAngleClockwise;
 
double guessFactor = lateralDirection * bearingOffset / maxEscapeAngle;
 
double guessFactor = lateralDirection * bearingOffset / maxEscapeAngle;

Revision as of 01:43, 13 December 2007

An example of a GuessFactor calculation, in this case using precise predicted maximum escape angles.

A way of measuring a firing angle which, unlike a raw bearing offset, takes into account the enemy's relative direction at fire time and the maximum escape angle for the specific firing situation.

A GuessFactor of 1.0 represents the bearing offset that the enemy would reach if it maximized its escape angle while moving in its current direction relative to the firing bot (i.e., clockwise or counter-clockwise), -1.0 represents the bearing offset that the enemy would reach if it maximized his escape angle after reversing directions, and 0.0 represents the bearing offset that points directly at the enemy (as in head-on targeting).

Calculation

int lateralDirection = ...;
double bearingOffset = normalRelativeAngle(...);
double maxEscapeAngleClockwise = ...;
double maxEscapeAngleCounterclockwise = ...;

double maxEscapeAngle = (bearingOffset < 0) ?
    maxEscapeAngleCounterclockwise : maxEscapeAngleClockwise;
double guessFactor = lateralDirection * bearingOffset / maxEscapeAngle;

How it works

The idea of the GuessFactor calculation is to express the enemy's bearing offset as a fraction of its maximum escape angle, while simultaneously ignoring its lateral direction. lateralDirection can be calculated directly by sign(lateralVelocity), but a more complex equation may be needed for accuracy when lateral velocity is close to 0. bearingOffset can be calculated using waves. maxEscapeAngleClockwise and maxEscapeAngleCounterclockwise can be calculated by any maximum escape angle algorithm.

See also