Difference between revisions of "Head-On Targeting"

From Robowiki
Jump to navigation Jump to search
m
Line 8: Line 8:
 
<pre>
 
<pre>
 
double absoluteBearing = getHeadingRadians() + e.getBearingRadians();
 
double absoluteBearing = getHeadingRadians() + e.getBearingRadians();
setTurnGunRightRadians(robocode.util.Utils.normalRelativeAngle(absoluteBearing - getGunHeadingRadians()));
+
setTurnGunRightRadians(
 +
    robocode.util.Utils.normalRelativeAngle(absoluteBearing -  
 +
        getGunHeadingRadians()));
 
</pre>
 
</pre>
  
 
[[Category:Targeting:Simple Targeting Strategies]]
 
[[Category:Targeting:Simple Targeting Strategies]]

Revision as of 20:30, 11 November 2007

Description

The simple strategy of aiming where you last saw the enemy. Works surprisingly well against surprisingly many bots, especially in Melee battles.

Example

In onScannedRobot, add:

double absoluteBearing = getHeadingRadians() + e.getBearingRadians();
setTurnGunRightRadians(
    robocode.util.Utils.normalRelativeAngle(absoluteBearing - 
        getGunHeadingRadians()));