Difference between revisions of "Random Targeting"
Jump to navigation
Jump to search
(new RandomTargeting page, lean and mean) |
(adding David's simpler, "assume orbital" solution) |
||
Line 16: | Line 16: | ||
} | } | ||
</pre> | </pre> | ||
+ | |||
+ | == A simpler solution == | ||
+ | |||
+ | A simpler method is to assume that the enemy is traveling in a circle around you, which is often true among NanoBots and [[:Category:1-vs-1 Bots|1-vs-1 bots]]. If the enemy is traveling in a circle around you, the maximum distance it can cover before a bullet reaches it is <code>enemy velocity / bullet velocity</code> (in radians). For example, a power 3.0 bullet fired at an enemy going at full speed should be fired at a [[Bearing Offset|bearing offset]] between -8/11 and +8/11. | ||
== See also == | == See also == | ||
* [[Maximum Escape Angle]] | * [[Maximum Escape Angle]] |
Revision as of 02:19, 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); }
A simpler solution
A simpler method is to assume that the enemy is traveling in a circle around you, which is often true among NanoBots and 1-vs-1 bots. If the enemy is traveling in a circle around you, the maximum distance it can cover before a bullet reaches it is enemy velocity / bullet velocity
(in radians). For example, a power 3.0 bullet fired at an enemy going at full speed should be fired at a bearing offset between -8/11 and +8/11.