Difference between revisions of "Historical Velocity Recall"

From Robowiki
Jump to navigation Jump to search
(categorizing, adding "Mean Targeting" to "See also")
m (Using <syntaxhighlight>.)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
A method of targeting that uses the most common enemy velocity as input to a [[linear targeting]] or [[circular targeting]] algorithm.
+
A method of targeting that uses the most common enemy velocity as input to a [[linear targeting]] or [[circular targeting]] algorithm. The effectiveness of this targeting strategy can be greatly increased by implementing [[Segmentation]].
  
 
== Example using linear targeting==
 
== Example using linear targeting==
  
<pre>
+
<syntaxhighlight>
 
int[] _velocityCounts = new int[9];
 
int[] _velocityCounts = new int[9];
  
Line 23: Line 23:
 
         mostCommonVelocity * goingBackwardsMultiplier);
 
         mostCommonVelocity * goingBackwardsMultiplier);
 
}
 
}
</pre>
+
</syntaxhighlight>
  
 
== See also ==
 
== See also ==
Line 34: Line 34:
  
 
[[Category:Simple Targeting Strategies]]
 
[[Category:Simple Targeting Strategies]]
[[Category:Targeting]]
 

Latest revision as of 09:28, 1 July 2010

A method of targeting that uses the most common enemy velocity as input to a linear targeting or circular targeting algorithm. The effectiveness of this targeting strategy can be greatly increased by implementing Segmentation.

Example using linear targeting

int[] _velocityCounts = new int[9];

public void onScannedRobot(ScannedRobotEvent e) {
    int goingBackwardsMultiplier = (e.getVelocity() < 0 ? -1 : 1);
    int enemyAbsVelocity = (int)Math.round(Math.abs(e.getVelocity()));
    _velocityCounts[enemyAbsVelocity]++;

    int mostCommonVelocity = 0;
    int mostCommonVelocityCount = _velocityCounts[0];
    for (int x = 1; x < 9; x++) {
        if (_velocityCounts[x] > mostCommonVelocityCount) {
            mostCommonVelocityCount = _velocityCounts[x];
            mostCommonVelocity = x;
        }
    }

    fireWithLinearTargeting(e.getHeadingRadians(), 
        mostCommonVelocity * goingBackwardsMultiplier);
}

See also