Difference between revisions of "Head-On Targeting"

From Robowiki
Jump to navigation Jump to search
m
 
(13 intermediate revisions by 7 users not shown)
Line 1: Line 1:
== Description ==
+
{{Youtube|C9Wmo94TUpw}}
The simple strategy of aiming where you last saw the enemy. Works surprisingly well against surprisingly many bots, especially in [[Melee]] battles.
 
  
== Example ==
+
The simple strategy of aiming where you last saw the enemy. Works surprisingly well against surprisingly many bots (Mainly against Oscillator Movement and sometimes random movement). It also works especially well in [[Melee]] battles. [[HawkOnFire]] and [[Shiz]] both use it.
 +
 
 +
== Examples ==
  
 
In <code>onScannedRobot</code>, add:
 
In <code>onScannedRobot</code>, add:
  
<pre>
+
<syntaxhighlight>
 
double absoluteBearing = getHeadingRadians() + e.getBearingRadians();
 
double absoluteBearing = getHeadingRadians() + e.getBearingRadians();
setTurnGunRightRadians(robocode.util.Utils.normalRelativeAngle(absoluteBearing - getGunHeadingRadians()));
+
setTurnGunRightRadians(
</pre>
+
    robocode.util.Utils.normalRelativeAngle(absoluteBearing -  
 +
        getGunHeadingRadians()));
 +
</syntaxhighlight>
 +
 
 +
A code like this was found in <code>sample.Fire</code>.
 +
 
 +
<syntaxhighlight>
 +
double turnGunAmt = (getHeadingRadians() + e.getBearingRadians()) - getGunHeadingRadians();
 +
//You can make this setTurnGunRight(...) or setTurnGunRightRadians(...) with an AdvancedRobot
 +
turnGunRight(turnGunAmt);
 +
</syntaxhighlight>
 +
 
 +
== See also ==
 +
 
 +
* [[Musashi Trick]]
  
[[Category:Targeting:Simple Targeting Strategies]]
+
{{Targeting Navbox}}
 +
[[Category:Simple Targeting Strategies]]
 +
[[Category:Code Snippets]]

Latest revision as of 02:46, 29 October 2013

Youtube
Youtube has a video of Head-On Targeting in action: click here to watch

The simple strategy of aiming where you last saw the enemy. Works surprisingly well against surprisingly many bots (Mainly against Oscillator Movement and sometimes random movement). It also works especially well in Melee battles. HawkOnFire and Shiz both use it.

Examples

In onScannedRobot, add:

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

A code like this was found in sample.Fire.

double turnGunAmt = (getHeadingRadians() + e.getBearingRadians()) - getGunHeadingRadians();
//You can make this setTurnGunRight(...) or setTurnGunRightRadians(...) with an AdvancedRobot
turnGunRight(turnGunAmt);

See also