# Accuracy vs distance formula

Consider a shooter and a target. My question is if there is any realistic approximation of calculating with which probability the shooter hits the target.

Neglecting the weapon and shooter skill, I guess the first order approximation should be that the probability to hit would be proportional to 1/r^2, where r is the distance to the target.

The motivation to this relation comes from using the idea that the area of a sphere centered at the shooter decays as r^2. So, the probability to hit a target should be, in worse case scenario, decaying as 1/r^2.

I've tried Googling some relation for any weapon, but I didn't find any...

EDIT:

More on the question: I'm considering a tactics game. In particular, I would like to model the shooting between two units (so, not a FPS game, the player does not aim, it issue orders). To do that, I'm considering that the unit has some experience, the weapon has some accuracy, and the environment (foggy, vegetation, etc) effects the overall accuracy. Before working some difficult model, the simplest model to test is considering all factors constant, and accuracy only depending on distance.

The question is how does this accuracy should depend on the distance. My first guess would be a 1/r^2 decay. But, has well mentioned on comments, this looks like a very rapid decay.

• 1/r^2 falls off rapidly. Seemingly, most FPS modify your aiming point in a solid angle and trace a ray. The bigger the angle, the harder it is to hit distant targets. Commented Apr 27, 2012 at 16:50
• Perhaps you can use the Inverse Square law to come up with one? Commented Apr 27, 2012 at 16:51
• Inverse Square law is what I'm saying in the post... that is the 1/r^2... -.- Commented Apr 27, 2012 at 17:00
• Of course. Must be why I thought of it. But you're missing the 4π and you're just using 1 for P. You can essentially use the intensity from that equation to equate to accuracy. Commented Apr 27, 2012 at 17:16
• I don't think his game design is relevant, as he's asking for "realistic approximation" and "neglecting the weapon and shooter skill". With those constraints it seems like a basic mathematical issue. Commented Apr 28, 2012 at 13:30

Your approximation basically dictates shots are landing on a part of the surface of a sphere, determined by angle; the target area within that surface is a constant; the probability distribution is constant within the surface and zero elsewhere.

Gajet has already given a number of good reasons why some of these assumptions fall flat, but holds on to the same inaccuracy model: a bounded error in angle. The result still falls off with r^-2, but with a small constant.

Say the shooter has a maximum spread of 5°. He has a chance of firing between a 0° and 1° error, but the area of the ring between 4° and 5° is much larger than the area of the ring/circle between 0° and 1°. Larger errors have a larger probability of occuring. Increase the error any further, and the probability suddenly drops to zero, because we're out of the five degree limit. That doesn't seem very realistic.

A more accurate representation would be to have a guassian distribution of angular error, i.e.: A(ϕ) = sqrt(a/π) exp(-a ϕ²). The variable a can be used to include the shooter's skill etc. Note this solution is one-dimensional. If your target is very tall compared to its width, you might omit the vertical error altogether and just assume the shot landed at the correct elevation. Alternatively, you can run the calculation twice and multiply the result, assuming the target is roughly rectangular.

To get from the probability function to the actual probability of hitting a target, we integrate the function A and end up with an expensive error function - which is actually called the error function: p(ϕ) = erf(ϕ sqrt(a)). The angle ϕ equates to the angle between the targeted point and the target's edge. In terms of target size s and distance r: p(r) = erf(arctan(s/2r) sqrt(a)). This function is plotted below for a target of size 1 and accuracy values of a=2 and a=10.

Note that unlike a falloff of r^-2, the probabilty neatly stays below one, no matter how close the target is. In fact, even a target at exactly zero distance can be missed, due to the extremely small probability the error is more than 90°.

Like I said before, the error function is quite expensive, but its argument ϕ sqrt(a), doesn't vary all that much for any sensible shooter scenario. We can do a lot better by evaluating part of the Taylor series instead and capping the result. First, we map x = arctan(s/2r) sqrt(a), then evaluate: 2 x - (2/3) x^3 + (1/5) x^5 .... Omit or add as many terms as deemed necessary, but keep in mind an even number of terms will cause unwanted behavior for low distances. Plotted below is the real error function, compared to the first three non-zero terms of its Taylor series.

As a final note, this is purely mathematics. Throw in a couple of sine functions, random coefficients and logarithms and your game might be equally fun.

The probability certainly is a function of 1/r^2 but does not fall off as fast as 1/r^2 itself. Let't do a simple math, and for the ease of calculation I shall first go with a 2D shooting which will result in 1D error in shooting. The target always has a same width, for example we know that target has a width of one meter. And we also know that while shooting the gun can miss the target with at most 5 degrees. here is a figure showing the situation:

Now look at these three states. assume that they have h1, h2 and h3 distance from the corner. Based on these values and the angle, we can calculate how much the distance is at those state. It's calculated as simple as h*tan(10/2)*2 (as shown in figure 2).

We know that h/l = cos(theta/2) and r/l = sin(theta/2) => r/h = sin(theta/2)/cos(theta/2) = tan(theta/2) => r = h*tan(theta/2) => edge length = h*tan(theta/2)*2

At other hand we know the target itself is 1 meter wide, so as long as that value is less than one meter we will always hit. after that part it has a probability of "target surface"/"hit area" which is equal to 1 / (h*tan(10/2)*2). Note that we can always assume all of target surface is inside cone of fire. it's doesn't really affect game-play that much but ease calculations very much!

now back to our 3D problem with a 2D target. Since it's a cone we are talking about the bullet will always pass through a circle of certain diameter when passing the target. again we need to compute it's radius, then the area of that circle. As I've explained before we can use r=h*tan(10/2)*2 and hence the surface area is pi*r^2 = h^2*tan^2(10/2)*4 * pi. And in the end we know probability is "target area"/"circle area" = 1 / h^2*tan^2(10/2)*4 * pi. as I said it's a function of h^2 but since tan^2(5) is very small, it takes a long time before that probability falls very low.

For this, you need a defined concept of "inaccuracy". What is inaccuracy? How does it work? If you code an AI which shoots and it computes the exact path every time, then obviously the inaccuracy is 0 over any distance.

Any shooting AI defines the perfect path first, and then adds aiming inaccuracy. This inaccuracy is entirely defined by you, and that definition is necessary before any probability can be computed.

• As I said in the question, accuracy is Probability of hit because I was neglecting unit's accuracy (e.g. experience) in this first approximation. Commented Apr 27, 2012 at 19:55
• @J.C: But you didn't define any reason or means that the unit's accuracy would not be 100% every time. Commented Apr 29, 2012 at 14:30