Difference between revisions of "Random Targeting"
Jump to navigation
Jump to search
(new RandomTargeting page, lean and mean) |
(No difference)
|
Revision as of 03:00, 12 November 2007
A method of Targeting that simply chooses a random angle among the angles that could possibly hit the opponent. Some successful NanoBots use this firing method. Its implementation is very small and for unpredictable movements, it will give a consistent hit percentage.
Example
public void onScannedRobot(ScannedRobotEvent e) { double randomGuessFactor = (Math.random() - .5) * 2; double bulletPower = 3; double maxEscapeAngle = Math.asin(8.0/(20 - (3 * bulletPower))); double firingAngle = randomGuessFactor * maxEscapeAngle; double absBearingToEnemy = e.getBearingRadians() + getHeadingRadians(); setTurnGunRightRadians(Utils.normalRelativeAngle( absBearingToEnemy + firingAngle - getGunHeadingRadians())); fire(bulletPower); }