last day (16 days later) » 

11:38
4
A: Recursive combined probability for triggering a bonus attack?

MannerPotsExpected Damage Let \$p\$ be your chance to hit, \$n\$ be your number of regular attacks, \$d\$ be your average damage on a hit (including the extra \$1/20\$ damage from crits). Then the expected damage of an attack without disadvantage is \$pd\$. Then we can break it into cases based on which is...

Agree with NobodytheHobgoblin that the crit damage cannot be represented by a single number [d]. Although as MannerPots says, the difference will be quite small. That said, it'll be good if an exact answer, including the proper crit formula, is included, for proper comparison purposes with other calculators that do make use of proper crit formula. (also, in some magic weapons that have additional damage on crit, such as Dragon's Wrath, it may have bigger impact)
I have to double check my code, but these results do not reflect the simulations, I don't know if it is due to the fact that here crits are not taken into account.
@Jacco I think that the term you are searching for is "conditional probability".
@Jacco in your simulation, the only comparable thing is the chance to trigger bonus attack? I agree with the calculation here, though. For 1 attack, to hit +0, AC 13 (so p=0.4), your simulation says bonusAttackTriggerProbability is 0.2572, that can't be right. Both of your attack rolls need to be 13 or above to hit. The chance of that happening is 0.4*0.4 = 0.16, which is what the first cell in this table shows. In your code, you have a typo in "if (attackRoll === 1) {return 'mis';}" which causes the number of misses to be undercounted.
Fixing that typo makes the result the same as this table :)
My simulations differ from your theoretical result with a relative error of around 3%, maybe is a matter of numerical approximation. My theoretical computation differ from yours with a rel error 0.6%. Still checking thou.
@Eddymage are you comparing average damage? The average damage will be different, since here it doesn't take into account crit damage properly (if you modify the calculation here to include crit properly, the answer will be something that depends on N, the number of attacks). But probability to hit and probability to trigger bonus attack should be exact.
11:38
@justhalf no, I am comparing the expected number of successful attacks.
@Eddymage What's your simulation result (and for how many iterations) for p=0.4, 1 attack, number of successful attacks including the bonus attack? 0.2240 here should be exact.
@justhalf Simulations: 0.2344 (1 000 000 simulations, in Matlab), the (mine) theoretical result is 0.2268.
I ran 10mil simulations 3 times, the results were 0.2241, 0.2239, 0.2239. I suppose since your theoretical result is different, maybe we have different assumptions. The expected number of successful hits for 1 attack (p=0.4) is $$\underbrace{p^2}_{\text{p first attack hits, at dis}} + \underbrace{p^2}_{\text{p BA triggered}}\cdot \underbrace{p}_{\text{p BA hits}} = 0.2240 (\text{for }p=0.4)$$. What do you have for your theoretical calculation? @Eddymage
@justhalf I think that we are answering different questions: I am computing the expected number of successful attacks (=hits) when making 1 attack that may trigger a bonus attack, while you are computing the prob of getting exactly one attack (and I think that theoretical computation is wrong, at first sight).
The expected number of hits if you're doing 1 attack at dis is simply 1 x p^2, no? @Eddymage basically the first column in the "Chance of Triggering Bonus Attack" in this answer. The 0.2240 I referred to includes the expected number of hits from the additional BA as well.
11:40
@justhalf No, if you are considering also the bonus attack you have to consider also the bonus attack. I am working on presenting in my answer what I found in some readable and understandable way...
12:20
@MannerPots The formula as presented still does not take the increased damage output caused by critical hits into account.
In the 4th comment, you said: "That's a good point, yes. You'd only need to change the first d in the formula since the ones in the (n−i)pd term are attacks without disadvantage. And of course, for a normal crit chance, it would decrease your expected damage by less than 1/20th, so the overall effect is very small."
As far as I can see, a straight-up subsitution between d_normal and d_critical is not possible, since d_critical is itself depended on both the hit chance (which is dependend on disadvantage/non-disadvantage) and the critical range.
So, in hopes of getting those details added, I've added a bounty.
12:46
also, I've updated the script linked in the question
@Eddymage that's what the \$p^2\cdot p\$ is doing. It's the probability to trigger the BA and for that BA to hit.
13:40
@justhalf No, that's wrong: you don't have to account for the probability to trigger the BA, you already done it by considering the attack with disasv hit, and the BA isn't done with disadv
14:00
You need to. Consider the two only possible cases: you miss the main attack -> probability (1-p^2), number of hits is 0. You hit with your main attack -> probability p^2, number of hits is 1 + expected number of hits from BA. Your overall expected number of hits is (1-p^2) x 0 + p^2 x (1 + expected number of hits from BA). We agree thus far, I assume?
14:17
@Eddymage or if you want, we can also divide into 3 cases: (1) main miss, (2) main hit + BA miss, (3) main hit + BA hit. The probability of (1) is (1-p^2), probability of (2) is p^2 x (1-p), probability of (3) is p^2 x p. Expectation is (1-p^2)x0 + (p^2 x (1-p))x1 + (p^2 x p)x2 = p^2-p^3 + 2p^3 = p^2 + p^3 = p^2 (1+p), which is what I have.
you might want to split it in 3 cases:
- main attack miss
- main attack hit (normal)
- main attack critical hit
@Jacco that'll be needed when calculating expected damage, yes. Eddymage and I were discussing expected number of hits for now :)
(I am currently writing an answer which includes crits, bear with me)
14:42
@justhalf ok, thanks for the heads-up! I'm most interested in seeing your answer!
If possible, I would suggest keeping the bonusAttack (and bonusDamage) out of the formula to calculate the combinedHitProbability for the (main) attacks.
This makes it easier to, in the future, adapt the logic and, for example, change the damage die for the bonus attack.
15:13
Yep, I'm separating D (from dice) and d (from flat damage bonus)!
Full answer posted! But no table yet, need to code it to generate nice table like in MannerPots
@justhalf I think that we are saying the same thing, but in different ways... I am don with the theory, and I reached the same results. I will post updates
15:28
@Eddymage if we're saying the same thing, then we should both get 0.2240 for the expected number of hits (including hits from BA) when p=0.4 :)
:64674074Now I have the same results, in a different way than yours (I think, I still havo to read your answer). To be honest, I answered to the initial version of the question that asked a different thing.
@justhalf the simulation result are still not on fully agreeement,though
15:56
@Eddymage which ones are you comparing? (also I just fixed a typo on my final result)
16:10
And I put a table as well. For the expected number of hits, and for a 1d4+3 dagger.
@justhalf number of expected attacks
Probably you should describe your simulation details as well. My simulation matches MannerPots' and my calculations. Count a hit whenever main attack or BA attack hits, divided by the number of iterations (not divided by the number of total attacks! that'll just measure accuracy) (also, I assume you really mean "number of expected hits")
 
1 hour later…
17:18
@justhalf Yeah, expected hits. What do you mean by iterations? You mean simulation?
17:45
@justhalf Anyway, I simulate 1e6 rolls with X attacks, the 1st is done with disadv, once the 1st landed I switch to attack normally. I have then a matrix with 1e6 rows and X columns with 0s and 1s. For example, if the 495th rows read as [0,1,1] means that the 1st missed, the 2nd hit (with disadv) and the 3rd landed (with a normal d20).
then, I check whcih rows has at least one 1, meaning that at least the attack with disadv landed. Then for these ones I simulate the bonus attack, and add a further column, hence having a 1e6 times X+1 matrix
summing on the columns and taking the mean should give the estimated number of hits
 
5 hours later…
23:07
For X=1, p=0.4, you will have two columns, right, and the expected number of 1 in your first column should be 0.16 (p^2), and the expected number of 1 in your second column should be 0.064 (p^3). (1) do you agree with this assessment, and (2) is that what you see in your simulation?

  last day (16 days later) »