Difference between revisions of "Head-On Targeting"

From Robowiki
Jump to navigation Jump to search
(use <syntaxhighlight>)
Line 19: Line 19:
 
* [[Musashi Trick]]
 
* [[Musashi Trick]]
  
 +
{{Targeting Navbox}}
 
[[Category:Simple Targeting Strategies]]
 
[[Category:Simple Targeting Strategies]]
 
[[Category:Code Snippets]]
 
[[Category:Code Snippets]]

Revision as of 18:17, 1 April 2011

Youtube
Youtube has a video of Head-On Targeting in action: click here to watch
This article is a stub. You can help RoboWiki by expanding it.

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