PDA

View Full Version : Probability Problem: Homebrew Horde Handling



Stubbazubba
2015-04-13, 09:21 PM
I'm tinkering with a loosely d20-based fantasy system that is level-less. So to handle fighting hordes of weaker enemies I have created a mechanic, but I wanted to see if it's actually any better than simply using the base iterative attack scheme I have. The maths get a little complicated, and I am not a maths person, so I wanted to let you fine number-crunching eggheads help me out, and hopefully have fun solving a quick little optimization problem:

Iterative attacks: Attacks are simply d20+modifiers vs. defense TN, and if you beat the enemy's attack by 10 or more you get to make another attack at full attack bonus, regardless of how many enemies you have targeted. There is no cap on the number of successive attacks you can make this way. E.g., Aragorn has a +12 attack bonus against an Orc with a defense of 11, so if he rolls a 21 or better (60% chance), he gets to make another attack, which also has a 60% chance of giving him yet another attack, and so on.

Attacking multiple targets: You can take a -3 penalty to attack an additional target with the same attack roll, e.g., Aragorn takes a -3 penalty to target 2 Orcs (net +9 bonus), a -6 penalty to attack 3 Orcs (net +6 bonus), a -9 penalty to attack 4 Orcs (net +3 bonus), etc. If you fail to hit the DC, you can still hit a number of targets equal to the number of targets you tried to hit subtract how much you missed by, e.g. if you targeted 4 opponents with a defense TN of 14 but only roll a 13 you still hit (4 [# tried for] - (14 [TN] - 13 [result])) = 4 - 1 = 3 targets. IOW, if Aragorn targets 3 Uruks (defense TN 15), he takes a -6 penalty (net +6 bonus), and on a 15 he would hit all 3 (60% chance), on a 14 he would hit 2 (5% chance), on a 13 he would hit 1 (5% chance), and on a 0 or below he would hit nothing. And if he rolled 25 or more (10% chance), he would hit 3 and make an iterative attack.

Variables: I'm looking at these three variables - attack bonus, defense TN (and, by implication, the delta between these two), and number of enemies targeted. Assume for now that any hit will kill a target.

The Question: Under what conditions, in terms of those three variables, are you statistically better off taking your full attack bonus and hoping for successive iterative attacks than attacking multiple targets with a single attack? IOW, Aragorn is facing hordes of Orcs, and he has the option of attacking 1 with his full +12 bonus (60% chance of iterative attack) or attacking some number of them with a single attack. Aragorn's player is a first-rate min-maxer, so how many Orcs does he decide to attack to maximize the number of Orcs hit/killed?

Thank you! I hope someone has fun with this.

weaseldust
2015-04-15, 05:52 PM
PART 1 OF 2

I have no idea why I spent so much time playing around with this. It’s good practice, I suppose. I’m not sure how much use the numbers are really going to be to you. I don’t have a nice, simple answer to your question, except maybe the response ‘get a computer to do it for you if possible, rather than working everything out by hand like I did’. Or make an educated guess. In any case, it’s very possible that I’ve made mistakes somewhere in the following, so take it with a pinch of salt.


Say that A is Aragorn's Attack bonus and he's attacking something with defence value X (by the way, what exactly does 'TN' stand for?). I'm assuming in the following that all possible targets have the same defences. I'm not sure how your mechanics work when attacking mixed groups. Define D to be the difference A - X.

For attacking a single target, the probabilities are fairly easy to calculate, though the formula will depend on what range D is in.

-If D is less than -20, Aragorn can't hit at all.

-If D is at least -20 and less than -10, Aragorn can hit but can't make a second attack. The expected number of creatures he hits is therefore equal to his probability of hitting, which is (21+D)/20 (bearing in mind that D is negative in this range).

-If D is at least -10 and less than -1, Aragorn's probability of hitting is (21+D)/20, his probability of hitting twice is (11+D)/20, and his probability of hitting but not gaining another attack is always 1/2. Therefore, the expected number of creatures he hits is (1/2)*(1) + ((11+D)/20)*(1/2)*(2) + ((11+D)/20)*((11+D)/20)*(1/2)*3 + ..., which simplifies to (1/2)*(1 - ((11+D)/20))^-2 using a know identity for the sum from 1 to infinity of k*x^(k-1). That further simplifies to give an expected number of 200*(9-D)^-2.

-If D is at least -1 and less than 9, Aragorn will always hit, but might miss the chance to attack again. If we define p to be (11+D)/20, which is his chance of succeeding well enough to hit again, the expected number of creatures he hits is 1*(1-p) + 2*p*(1-p) + 3*(p^2)*(1-p) + ..., which turns out to equal 20/(9-D) using the same identity as before.

-If D is 9 or more, Aragorn always hits and always gets another attack, so he immediately slays everything in reach.

For instance, you use the example of Aragorn attacking an orc, where A is 12, X is 11, and D is therefore 1. If Aragorn is surrounded by orcs, so he always has a target for his attacks, and they all have the same defence value of 11, then since 1 is between -1 and 9 we use the formula 20/(9-D), which gives us 20/8 = 2.5 as the expected number of hits.

weaseldust
2015-04-15, 05:57 PM
PART 2 of 2

How set are you on allowing attacks that target multiple creatures to also spawn iterative attacks if they succeed by 10 or more? That makes doing the calculations much more time consuming. I did some calculations with that rule in place, but also without it, and the latter is much more convenient, so I’ve mostly discussed that case.


Assume attacks against multiple creatures don’t spawn further attacks when they succeed by 10+. Take D to be the same as before, and let N be the number of creatures Aragorn chooses to attack.

If D – 3(N-1) is -1 or more, Aragorn hits them automatically, so the expected number of creatures hit is just N. If it is less than -20, he can’t hit at all. The interesting case is when D – 3(N-1) is at least -20 and less than -1. Aragorn’s probability of succeeding on the roll and hitting all N targets is (21+D – 3(N-1))/20. However, he also has a 1/20 chance of failing by only 1 and hitting N-1 of them, and a 1/20 chance of hitting N-2, etc. The obvious calculation to do for the expected number of hits, which is right in almost all cases, is N*(21+D – 3(N-1))/20 +(N-1)*(1/20) + (N-2)*(1/20) + … + 2*(1/20) + 1*(1/20). That eventually simplifies to give an answer of (47N + 2DN – 5N^2)/40 (honestly).

However, there are a few possible cases in which that calculation gives a slightly wrong answer. For instance, if D is 4 and N is 3, then Aragorn hits all 3 targets on a 2, and has the usual 1/20 chance of hitting only 2 targets (by rolling a 1), but doesn’t get the usual 1/20 chance of hitting only 1 target because there are no numbers below 1 on the die. The expected number of hits is therefore 3*(19/20) + 2*(1/20) = 59/20 or 2.95, whereas the above formula would give the value 3 instead. The other combinations of D and N that have this issue are: D=6, N=4, for which we expect 3.85 hits; D=7, N=4, for which we also expect 3.85 hits; and D=8, N=5, for which we expect 4.7 hits. I think you can mostly ignore these cases, as they require high values of D and don’t differ much from what the formula gives you.

How many targets should you attack? To cut a long story short, plugging N=1 into the formula gives you an expected number of hits of (21+D)/20, the same as making one attack when you have no chance of gaining another. Plugging in N=2 gives you (37+2D)/20, a difference of (16+D)/20. That’s an improvement (or at least, not a loss) as long as D is at least -16. So you should attack at least 2 if D is at least -16, but only 1 otherwise. N=3 gives you (48+3D)/20 hits, a difference of (11+D)/20 from N=2. That’s a good deal if D is at least -11. It turns out that N=4 is a good deal if D is at least -6, N =5 is good if D is at least -1, etc., with the threshold value of D increasing by 5 each time. So in the example with Aragorn and orcs, since D is 1, it’s a better deal to attack 5 orcs than 4, but it’s not better to attack 6.

That still hasn’t answered your question about when to attack multiple targets and when to make one iterative attack. You basically just have to take the best possible expected number of hits from attacking multiple targets and compare it to the expected number for an iterative attack, which depends on what range D is in. For instance, if D is 1, then attacking multiple targets gets the best results when N=5, in which case the expected number of hits is (47*5 + 2*1*5 – 5*5^2)/40, which comes to 3. For an iterative attack, since 1 is between -1 and 9, the formula to use is 20/(9-D) which gives us 2.5. So the expected number of hits is higher when Aragorn attacks 5 orcs at once.


What happens if attacks against multiple targets can still spawn multiple attacks? It gets really complicated. For instance, if Aragorn attacks 3 orcs at a time with D=3 his probability of hitting is 0.9 but his probability of getting another attack is only 0.4, and his probability of hitting but not getting another attack is 0.5. If he attacks 3 orcs at a time, the probability of hitting 1 is (1/20) = 0.05; for 2, also 0.05; for 3, 0.5; for 4, 0.4*0.05 = 0.02; for 5, also 0.02; for 6, 0.4*0.5 = 0.2; for 7, 0.4*0.4*0.05 = 0.008; etc. There is a pattern, and you can eventually calculate the expected number of orcs hit (I make it 4.75), and even let D vary and write a formula for the number hit that depends on D, but it’s a lot of hassle.