Fingers of Death The Art of Shooting
Fingers of Death The Art of Shooting
Fingers of Death The Art of Shooting
First-person shooter killing algorithms are fine, but some situations can be handled more
accurately and efficiently by including geometry, statistics, probability, and aggregation.
Massively Multi-player and Real-time Strategy games particularly include a lot of action
that does not have to be modeled with individual line-of-sight (LOS) and targeting for a
headshot. These and other games can also benefit from the inclusion of multiple kill types
that are based on real live-fire experiments. First-person shooters may equip AI’s with
some of these algorithms while leaving the more detailed LOS algorithms for the avatar
controlled by the human player.
Hitting a Ribbon
The first finger of death presents a simple method for determining whether a shooter will
hit a ribbon target like a road, river, long convoy of vehicles, or a serpentine creature
(Figure 1). If the target is so long that it is impossible to overshoot or undershoot its
length, the probability of hitting the target is dependent only upon the width of the target
and the standard deviation of the shot pattern of the weapon. This simple algorithm is
also a good way to introduce the logic and mathematics behind several of the attrition
algorithms that follow [Parry95]. Deviations in the impact point of the munitions being
fired are due to factors such as the quality of the weapon, steadiness and skill of the
human operator, variations in the construction of the projectile, and wind conditions.
σx
W
W
σx
1
Game Programming Gems 4
Equation
The equation for calculating the probability of hit (Ph) for a ribbon target is:
Ph = 2W 2πσ x
where,
W is the width of the target, and
σx is the standard deviation of the bullet dispersion in the x dimension.
This assumes that the pattern is normally distributed with the same standard
deviation in both the x and y dimensions.
[Note: The code for all of these algorithms can be found on the CD-ROM.]
The algorithm is driven by two very simple variables – the radius of the target and the
standard deviation of the rounds. This deviation is based on a normal distribution in
which the mean value is zero because the shooter is aimed directly at the center of the
target [Parry95]. The algorithm determines whether each shot will hit the target, but does
not calculate the actual impact point of the round. This simplification eliminates
calculations that would have to be done to distribute the round normally in both the x and
y dimension.
σx r
Equation
The equation for calculating the probability of hit (Ph) for a round target is:
Ph = 1 − e − (r 2σ x )
2 2
2
Game Programming Gems 4
where,
r is the radius of the target, and
σx is the standard deviation of the bullet dispersion in the x dimension.
Hitting a Rectangle
Most targets are not shaped like bullseyes, so we need a more flexible algorithm to shoot
rectangular targets like the torso of a human or a vehicle. This algorithm includes
measures for the length and width of a rectangular target [Parry95].
σx σy W
L
Equation
The equation for calculating the probability of hit (Ph) for a rectangular target is:
Ph = A * B
A = 1 − e −(2 L πσ x 2 )
2
B =1− e
(
− 2W 2 πσ y 2 )
where,
L is the length of the target in the x dimension,
W is the width of the target in the y dimension,
σx is the standard deviation of the bullet dispersion in the x dimension, and
σy is the standard deviation of the bullet dispersion in the y dimension.
Weapons often have different standard deviations in the x and y dimensions. For
example, when a football quarterback throws a pass, the variation from the aim point
along the axis of flight is usually greater than the variation left or right of the aim point.
The same is true for missiles being fired at a combat vehicle or rocks being thrown at a
dinosaur.
3
Game Programming Gems 4
Some weapons unleash a barrage of rockets, bomblets, or explosive munitions all at once
in an attempt to totally overwhelm the target and blow it to smithereens. When this
happens, there are much faster ways of determining the killing effect of the entire barrage
than calculating the impact points and lethality of each rocket individually and then
accumulating them.
This algorithm calculates the probability that one of the munitions’ lethal areas will
overlap with the point target. The size of the target is not considered in these calculations
because it is assumed that the lethal blast area can encompass an entire target [Parry95].
σx
T
n Simultaneous
Rounds
Shooter
Figure 4. Probability of Killing a Target with a Simultaneous Barrage of Munitions
Equation
Pk = 1 − e − (na 2πσ x )
2
where,
n is the number of rounds in the barrage,
a is the lethal area of a single round against this target, and
σx is the standard deviation of the bullet dispersion in the x dimension.
4
Game Programming Gems 4
Spotter
a
Simulated Correction
Communication σx
T
n Sequential
Corrected Rounds
Shooter
Figure 5. Lethality of Walking Artillery with a Spotter
Equation
⎛
( )∑ ⎞
n
−⎜ a 2 2σ x 2 ∗ ( i −1) i⎟
⎜ ⎟
Pk = 1 − e ⎝ i =2 ⎠
where,
n is the number of rounds fired in the barrage,
a is the lethal area of a single round against this target, and
σx is the standard deviation of the bullet dispersion in the x dimension.
These four kill types can be pictured as a Venn diagram (Figure 6). Though this form
clearly communicates the relationships between the kill types, in order to be applied, it
has to be separated so that a specific kill type can be determined quickly for each
engagement. This separated data is usually represented as a kill thermometer (Figure 7).
Normalizing the kill types in a single space as represented in the thermometer allows a
5
Game Programming Gems 4
Mobility Firepower
Kill M&F Kill
Kill
K
Kill
No Kill
1.0
Catastrophic
Kill
Pn+Pm +Pf +Pmf
Mobility and
Firepower Kill
Pn+Pm +Pf
Firepower Kill
Pn+Pm
Mobility Kill
Pn
No Kill
0.0
There are live-fire projects that determine the probability of each kill type under different
conditions by firing real weapons at real targets and measuring the result. Most
simulations and games do not have access to such a rich source of information.
Therefore, we have to identify common trends in experimental data and create equations
that mimic those while remaining flexible enough to be applied to new weapon/target
pairs. One simulation project noticed a distinct relationship between the mobility,
firepower, and catastrophic kill data they had received from live-fire experiments. This
relationship allowed them to create simple equations that use the root of a single
“probability of mobility or firepower kill” (PMoF is the union of all of the shaded areas
above) to calculate all of the other probabilities. The trend they noticed was that a
mobility kill occurred 90% of the time that damage was done (PM = 0.9* PMoF); a
firepower kill occurred 90% of the time (PF = 0.9* PMoF); and a catastrophic kill occurred
50% of the time that damage was done (PK = 0.5* PMoF).
6
Game Programming Gems 4
However, this information cannot be applied directly to the kill thermometer in Figure 7.
PM does not say that 90% of all engagements result in a mobility kill. It says that 90% of
mobility-or-firepower kills include a mobility kill. Therefore, it has to be separated to
make it possible to draw a single random number and determine which kill to apply to the
target. These independent kill probabilities can be extracted as shown below.
Equation
Pn = 1.0 − PMoF
Pm = PMoF − PF = 0.1 ∗ PMoF
Pf = PMoF − PM = 0.1 ∗ PMoF
Pk = 0.5 ∗ PMoF
Pmf = PMoF − Pm − Pf − Pk = 0.3 ∗ PMoF
where, the small subscript indicates the probability that only one type of kill occurs. For
example, Pm is the probability of only getting a mobility kill, but not getting any other
form of kill. Pn is the probability of no kill occurring.
These independent kill probabilities determine where the breakpoints fall in a kill
thermometer and can be easily programmed as shown in the code on the CD-ROM.
Equation
Pk = (
3 nwr )
2π ∗ e −0.5∗(k ∗d
2
nwr )2
where,
n is the number of rounds impacting at a specific point,
wr is the weight of the chemical inside of each round (in kilograms),
d is the distance that the rounds fall from the target location (in meters), and
k is a constant representing the dispersion characteristic of the chemical. For these
experiments we recommend beginning with a value of 0.00135.
This equation allows you to deal with each round individually or to aggregate multiple
rounds into a single attack centered at the same impact point. The equation also
7
Game Programming Gems 4
incorporates the constant k that represents the density and viscosity of a chemical
compound. You can adjust this value to create the effect desired.
φ2
φ1
Equation
where,
n is the number of fragments or projectiles in the missile warhead,
Av is the vulnerable area of the target presented to the missile (in sq meters),
r is the range from the detonation point to the target (in meters),
φ1 is the angle from the trajectory of the missile to the near edge of the
vulnerability area of the target, and
φ2 is the angle from the trajectory of the missile to the far edge of the vulnerability
area of the target.
8
Game Programming Gems 4
As before, this approach is very valuable when the hunting and killing is being conducted
by AI controlled hunters and especially when it is happening off the player’s screen.
The algorithm is structured to calculate the change in the population of the prey based on
the number and efficiency of the hunters. It also accounts for different types of prey and
hunter animals, e.g. small rodents, medium-sized wolves, and large elephants.
To use the algorithm, we must define a probability of detection for each type of hunter
against each type of prey under the given conditions (open terrain, forest, city, etc.). We
must also select a “hardness” factor that differentiates the ability of the prey to elude,
escape, or survive the actions of the hunter. These numbers are usually determined
heuristically through experimentation and observation.
p p h
h p h
p
h h
p h
p h
p
p p h
Equation
x = ⎛⎜ (k j p ) ∗ ∑ Di , j * hi ⎞⎟
n
⎝ i =1 ⎠
−x
A j = p j * (1 − e )
where,
Aj is the number of kills of animal type j,
pj is the number of prey of type j,
kj is a hardness measure of the prey in the range [0,1],
p is the total number of prey of all types,
n is the number of prey types
Di,j is the probability that a hunter of type i can detect a prey of type j, and
hi is the number of hunters of type i.
9
Game Programming Gems 4
a hundred of them in the search area than if there are just two or three. Therefore, they
created a variation known as the Lulejian model [Shubik83] in which the spacing
between the prey is an important factor. The visual picture for this algorithm is the same
as that above, but the mathematics differ to account for the spacing of prey. The
definition of kj also varies slightly in that Lilejian defines kj as the average destruction of
the hunters on prey type j.
Equation
x = ⎛⎜ ∑ k j * hi ⎞⎟ (s * p )
n
⎝ i =1 ⎠
A j = p j * (1 − e − x )
where,
Aj is the number of kills of prey type j,
pj is the number of prey of type j,
s is the average spacing between the prey in the search area (in meters),
p is the total number of prey of all types,
n is the number of prey types
kj is the average destruction of the hunters on prey type j, in the range [0,1],
hi is the number of hunters of type i.
Conclusion
The ten fingers of death described in this chapter are just a few of the combat killing
algorithms that can be applied to computer games. The concepts of geometry, probability,
statistics, and physics used in the ten fingers of death are good examples of approaches to
many problems. Game developers should do what military modelers do to improve these
– apply experience, mathematics, creativity, and other sciences to find equations that
work well for your game. Don’t be afraid to experiment!
References
[Ball85] Ball, Robert E. The Fundamentals of Aircraft Combat Survivability Analysis and
Design. AIAA Press, 1985.
[Epstein85] Epstein, Joshua M. The Calculus of Conventional War: Dynamic Analysis
without Lanchester Theory. Brookings Institution, 1985.
[Parry95] Parry, Samuel, Editor. Military OR Analyst’s Handbook: Conventional
Weapons Effects. Military Operations Research Society, 1995.
[May02] May, Janet O. “OneSAF Killer/Victim Scoreboard Capability for C2
Experimentation”, Proceedings of the 2002 Conference on Behavioral
Representation in Modeling and Simulation, 2002.
[Shubik83] Shubik, Martin, Editor. Mathematics of Conflict. Elsevier Science Publishers,
1983.
[Army90] U.S. Army. Field Artillery Handbook. U.S. Army, 1990.
10