Difference between revisions of "Head-On Targeting"
Jump to navigation
Jump to search
m (marks as stub, too short really) |
m (Fix syntax highlighting) |
||
| (6 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
| − | {{ | + | {{Youtube|C9Wmo94TUpw}} |
| − | The simple strategy of aiming where you last saw the enemy. Works surprisingly well against surprisingly many bots | + | 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: | ||
| − | < | + | <syntaxhighlight lang="java"> |
double absoluteBearing = getHeadingRadians() + e.getBearingRadians(); | double absoluteBearing = getHeadingRadians() + e.getBearingRadians(); | ||
setTurnGunRightRadians( | setTurnGunRightRadians( | ||
robocode.util.Utils.normalRelativeAngle(absoluteBearing - | robocode.util.Utils.normalRelativeAngle(absoluteBearing - | ||
getGunHeadingRadians())); | getGunHeadingRadians())); | ||
| − | </ | + | </syntaxhighlight> |
| + | |||
| + | A code like this was found in <code>sample.Fire</code>. | ||
| + | |||
| + | <syntaxhighlight lang="java"> | ||
| + | double turnGunAmt = (getHeadingRadians() + e.getBearingRadians()) - getGunHeadingRadians(); | ||
| + | //You can make this setTurnGunRight(...) or setTurnGunRightRadians(...) with an AdvancedRobot | ||
| + | turnGunRight(turnGunAmt); | ||
| + | </syntaxhighlight> | ||
== See also == | == See also == | ||
| Line 18: | Line 26: | ||
* [[Musashi Trick]] | * [[Musashi Trick]] | ||
| + | {{Targeting Navbox}} | ||
[[Category:Simple Targeting Strategies]] | [[Category:Simple Targeting Strategies]] | ||
[[Category:Code Snippets]] | [[Category:Code Snippets]] | ||
Latest revision as of 13:51, 25 August 2025
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
| ||||||||||||||||||||||||||||||||||||