Difference between revisions of "Head-On Targeting"

From Robowiki
Jump to navigation Jump to search
(adding "Musashi Trick" to "See also", it's specific to HOT)
m (removing "Targeting" category)
Line 11: Line 11:
 
         getGunHeadingRadians()));
 
         getGunHeadingRadians()));
 
</pre>
 
</pre>
 
[[Category:Simple Targeting Strategies]]
 
[[Category:Targeting]]
 
[[Category:Code Snippets]]
 
  
 
== See also ==
 
== See also ==
  
 
* [[Musashi Trick]]
 
* [[Musashi Trick]]
 +
 +
[[Category:Simple Targeting Strategies]]
 +
[[Category:Code Snippets]]

Revision as of 17:11, 29 November 2007

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()));

See also