Friday, February 12, 2010

Examining average number of attacks more closely.

We examine the result from the last post.

With a probability p of hitting a monster, the average number of attacks it takes to hit is 1/p.

On a d20 (with the mods backed out), the probability of rolling greater than or equal a particular number is:

10 = 55%
11 = 50%
12 = 45%
13 = 40%
14 = 35%
15 = 30%
16 = 25%
17 = 20%
18 = 15%
19 = 10%
20 = 5%

Examining this more closely, we have 1/p for various probabilities p:

prob = 55%, average number of attacks = 1.82
prob = 50%, average number of attacks = 2
prob = 45%, average number of attacks = 2.22
prob = 40%, average number of attacks = 2.5
prob = 35%, average number of attacks = 2.86
prob = 30%, average number of attacks = 3.33
prob = 25%, average number of attacks = 4
prob = 20%, average number of attacks = 5
prob = 15%, average number of attacks = 6.67
prob = 10%, average number of attacks = 10
prob = 5%, average number of attacks = 20

As the probability to hit gets smaller than 25% (ie. greater than 16 on a d20), the average number of attacks it takes to hit such a monster goes up considerably. To minimize combat from becoming too frustrating, it would be optimal to keep the probability to hit in the range of 25% to 50% which would correspond to the range 11 to 16 on a d20. (Less than 10 would be too easy). As one may have experienced, requiring a minimum roll of 18 or 19 to hit a monster can be very frustrating.

From the 4E DMG, the generic monsters typically have minimum defenses which scale as 12+level. So even for level 1 players fighting level 1 monsters, AC/fortitude/reflex/will are at least 13. A minion may only require an 11 or 12 to hit.

Number of attacks to hit

We will examine the number of attacks it takes on average to hit a target monster.

Assuming a probability p of hitting a monster, the probability of missing is 1-p.

The probability of hitting on the first attack = p.

The probability of missing on the first attack, but hitting on the second attack = p(1-p).

The probability of missing on the first two attacks, but hitting on the third attack = p(1-p)^2 .

In general, the probability of missing on the first k-1 attacks, and hitting on the kth attack is: p(1-p)^(k-1) .

To determine the average number of attacks to finally hit a target monster, we take the expectation value of the number of attacks:

sum{k=1, infinity} k p(1-p)^(k-1)

which gives the answer 1/p. (This is using the infinite series 1/(1-x)^2 = 1 + 2x + 3x^2 + 4x^3 + 5x^4 + ...).

With some more work, the variance can be calculated to be (1-p)/p^2.

This probability distribution is better known as the geometric distribution.

http://en.wikipedia.org/wiki/Geometric_distribution

More generally, the problem can be generalized to the case of the average number of times it takes to hit a monster N times. Without going through all the math, one could guess and formally show that the average number of attacks it takes to hit a monster N times is N/p.

In conclusion. With probability p of hitting a monster, the average number of attacks it takes to hit a monster once is 1/p. More generally, the average number of attacks it takes to hit a monster N times is N/p.