Difference between revisions of "GuessFactor"

From Robowiki
Jump to navigation Jump to search
(New page: 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 f...)
 
m (fix)
 
(13 intermediate revisions by 5 users not shown)
Line 1: Line 1:
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.  
+
[[Image:GuessFactors.png|frame|An example of a GuessFactor calculation, in this case using [[Maximum Escape Angle/Precise|precise predicted maximum escape angles]].]]
  
A GuessFactor of 1.0 represents the furthest point that the enemy could reach if he continues moving in his current direction relative to the firing bot (i.e., clockwise or counter-clockwise), while -1.0 represents the furthest point that the enemy could reach if he reversed directions.
+
'''GuessFactor (GF)''' is a way of measuring firing angles 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 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]]).
 +
 
 +
GuessFactors are essentially normalized angles. They are relevant for [[Wave Surfing]], in which all GuessFactors of each [[Wave]] are assigned a predicted danger, allowing the robot to move in the direction ([[Wave Surfing/True Surfing|True Surfing]]) or to the point ([[Wave Surfing/GoTo Surfing|GoTo Surfing]]) of least danger. Some [[Targeting|guns]] also use GuessFactors, in that they pick a GF and shoot at it. GuessFactors are also viable in [[Melee]], but since in melee, bots are not typically moving perpendicular to you, GuessFactors are generally less useful. Alternatives to GuessFactors include [[Play It Forward]] and [[Displacement Vector|Displacement Vectors]].
 +
 
 +
<!-- We need to be sure the image won't overlap with the sample code. -->
 +
<div style="clear:right"></div>
 +
== Calculation ==
 +
<syntaxhighlight>
 +
int lateralDirection = ...;
 +
double bearingOffset = normalRelativeAngle(...);
 +
double maxEscapeAngleClockwise = ...;
 +
double maxEscapeAngleCounterclockwise = ...;
 +
 
 +
double maxEscapeAngle = (bearingOffset < 0) ?
 +
    maxEscapeAngleCounterclockwise : maxEscapeAngleClockwise;
 +
double guessFactor = lateralDirection * bearingOffset / maxEscapeAngle;
 +
</syntaxhighlight>
 +
 
 +
=== 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|maximum escape angle]], while simultaneously ignoring its [[lateral direction]]. <code>lateralDirection</code> can be calculated directly by <code>sign(lateralVelocity)</code>, but a more complex equation may be needed for accuracy when [[lateral velocity]] is close to 0. <code>bearingOffset</code> can be calculated using [[waves]]. <code>maxEscapeAngleClockwise</code> and <code>maxEscapeAngleCounterclockwise</code> can be calculated by any maximum escape angle algorithm.
  
 
== See also ==
 
== See also ==
 
+
* [[Displacement Vector]]
 
* [[GuessFactor Targeting]]
 
* [[GuessFactor Targeting]]
 +
* [[Maximum Escape Angle]]
 +
* [[Play It Forward]]
 +
* [[Waves]]
  
 
[[Category:Terminology]]
 
[[Category:Terminology]]

Latest revision as of 02:56, 27 September 2017

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

GuessFactor (GF) is a way of measuring firing angles 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).

GuessFactors are essentially normalized angles. They are relevant for Wave Surfing, in which all GuessFactors of each Wave are assigned a predicted danger, allowing the robot to move in the direction (True Surfing) or to the point (GoTo Surfing) of least danger. Some guns also use GuessFactors, in that they pick a GF and shoot at it. GuessFactors are also viable in Melee, but since in melee, bots are not typically moving perpendicular to you, GuessFactors are generally less useful. Alternatives to GuessFactors include Play It Forward and Displacement Vectors.

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