Difference between revisions of "Random Targeting"
m (Very minor edit.) |
|||
(One intermediate revision by one other user not shown) | |||
Line 24: | Line 24: | ||
== Selecting firepower == | == Selecting firepower == | ||
− | The advantage of a random gun is that it should have a roughly equal hit rate | + | The advantage of a random gun is that it should have a roughly equal hit rate against all types of [[Movement]]. This makes ideal firepower selection pretty easy to pre-calculate. In the following equations x is the choice of firepower. It is assumed that damage output per tick is the quantity you're interested in maximizing, it may not be. |
Bullet damage, assuming firepower > 1: | Bullet damage, assuming firepower > 1: | ||
Line 33: | Line 33: | ||
The smallest size of a robot, in radians: | The smallest size of a robot, in radians: | ||
− | <math>s= | + | <math>s=\frac{36}{d}</math>, where <math>d</math> is the distance to the other bot. |
Line 63: | Line 63: | ||
Expected damage <math>E_{x,d}</math> per tick of combat: | Expected damage <math>E_{x,d}</math> per tick of combat: | ||
− | <math>E_{x,d}=E \cdot F = D \cdot P \cdot \frac{1}{ceil(10H)} =\frac{(6x-2) \cdot min(1,\frac{ | + | <math>E_{x,d}=E \cdot F = D \cdot P \cdot \frac{1}{ceil(10H)} =\frac{(6x-2) \cdot min(1,\frac{16}{d \cdot asin(\frac{8}{20-3x})})}{10+ceil(2x))}</math> |
Optimization of <math>E_{x,d}</math> is left as an exercise for the coder. | Optimization of <math>E_{x,d}</math> is left as an exercise for the coder. |
Latest revision as of 16:55, 6 February 2013
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 targetAngle = getHeadingRadians() + e.getBearingRadians();
double bulletPower = Math.max(0.1,Math.random() * 3.0);
double escapeAngle = Math.asin(8 / Rules.getBulletSpeed(bulletPower));
double randomAimOffset = -escapeAngle + Math.random() * 2 * escapeAngle;
double headOnTargeting = targetAngle - getGunHeadingRadians();
setTurnGunRightRadians(Utils.normalRelativeAngle(headOnTargeting + randomAimOffset));
setFire(bulletPower);
// ...
}
A simpler solution
A simpler method is to assume that the enemy is traveling in a circle around you (see Musashi Trick), 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.
Selecting firepower
The advantage of a random gun is that it should have a roughly equal hit rate against all types of Movement. This makes ideal firepower selection pretty easy to pre-calculate. In the following equations x is the choice of firepower. It is assumed that damage output per tick is the quantity you're interested in maximizing, it may not be.
Bullet damage, assuming firepower > 1:
<math>D=4x+2(x-1)</math>
The smallest size of a robot, in radians:
<math>s=\frac{36}{d}</math>, where <math>d</math> is the distance to the other bot.
The total escape area, in radians:
<math>\alpha=2 \cdot asin(\frac{8}{20-3x})</math>
Probability of a hit, assuming uniform spread of bullets over <math>\alpha</math>:
<math>P=min(1,\frac{s}{\alpha})</math>
The expected damage from a shot:
<math>E=DP</math>
The heat created by a shot:
<math>H=1+\frac{x}{5}</math>
The firing frequency:
<math>F=\frac{1}{ceil(10H)}</math>
Expected damage <math>E_{x,d}</math> per tick of combat:
<math>E_{x,d}=E \cdot F = D \cdot P \cdot \frac{1}{ceil(10H)} =\frac{(6x-2) \cdot min(1,\frac{16}{d \cdot asin(\frac{8}{20-3x})})}{10+ceil(2x))}</math>
Optimization of <math>E_{x,d}</math> is left as an exercise for the coder.
See also
|