Welcome to Librarium Online!
Join our community of 80,000+ members and take part in the number one resource for Warhammer and Warhammer 40K discussion!
Registering gives you full access to take part in discussions, upload pictures, contact other members and search everything!
I'm writing a program that displays a Marine equivalent (MEq) of a given unit's assault efficiency. The to-wound reroll calculation is very simple:
If RerollWounds Then
ToWound += (1 - ToWound) * ToWound
But what about to-hit rerolls? Unlike to-wound rerolls, you can reroll only a fixed amount of dice. How do I calculate this?
My current idea is to split the attacks in two:
A1 = Attacks - ToHitRerolls
A2 = ToHitRerolls
A1 is then processed as usual, but A2 is processed using to-hit reroll formula that is identical to the to-wound one above. Then both derived MEq values are added together.
Is this algorithm correct?
quick question, are you looking for percentages of hits, or probability?
the average squad of (x)10 marines firing bolters(S) at long range hit with 6.67 shots, but the probablity of them hitting with that many shots is not 100%
erroneous data was here, please ignore......check down the page....
Last edited by tarzen; November 2nd, 2005 at 09:10.
I was wrong, I was not calculating probabilities, but average damage. Thanks for correcting.
But anyway, if I have, say, 5 attacks that ignore saves and two to-hit rerolls (to-hit probabilty is, say, 5+, i.e. 0.33), how do I calculate average wound amount?
3*0.33*RTW + 2*(0.33+(1-0.33)*0.33))*RTW?
You can consider rerolls to be extra attacks, but you need to account for the chance not to get to use them.
For a single reroll that's somewhat trivial:
(number of attacks+number of rerolls)*chance to hit - (chance to hit all normal attacks, not to need rerolls)*chance to hit with the reroll
For more than one reroll things get more complicated, you need to calculate the chance to waste only one of the rerolls and account for that, only to need two rerolls and eventually even only to need three/four/five rerolls, depending on how many you need.
However, instead of doing that in the software i would recommend that you do it manually once and then use the results as constants in the program. Coming up with an algorithm for it would be prone to error.
You could also consider writing a small program which does nothing but to determine the expected to hit numbers for different combinations of to hit rolls, attack numbers and rerols statistically with a lare sample, take the results and use them to initialize a suitable (probably three dimensional ) array with them.
For one reroll the expected number of hits is this:
(number of attacks+number of rerolls)*chance to hit - (chance to hit)^(number of attacks)*chance to hit
or this (equivalent):
(number of attacks+number of rerolls)*chance to hit - (chance to hit)^(number of attacks+1)
For two rerolls:
(number of attacks+number of rerolls)*chance to hit - 2*((chance to hit)^(number of attacks+1)) - (chance to hit)^(number of attacks)*chance to hit*number of attacks
or this (equivalent):
(number of attacks+number of rerolls)*chance to hit - 2*((chance to hit)^(number of attacks+1)) - (chance to hit)^(number of attacks+1)*number of attacks
For more than two rerolls it gets more complicated. But there isn't much that can have more than two to hit rerolls. Dark Eldar with drugs, librarians with veil of time and tzeentchies with master crafted weapon, spiky bits and eye of tzeentch are the only ones that come to my mind right now.
Last edited by ArchonAstaroth; October 31st, 2005 at 18:51.
Exactly.Originally Posted by onodera
I'm not so sure about that...it neglects the chance not to get any rerolls because one doesn't use them.But anyway, if I have, say, 5 attacks that ignore saves and two to-hit rerolls (to-hit probabilty is, say, 5+, i.e. 0.33), how do I calculate average wound amount?
3*0.33*RTW + 2*(0.33+(1-0.33)*0.33))*RTW?
I've done the precise math for five attacks, two rerolls with 4+ to hit. The above formula comes up with a predicted three hits in average, but the accurate figure is 3.359375
That is correct, the above formula only allows rerolls if and only if the last two dice miss, it does not take into account if the first two miss and the last two hit. The rerolls are tied to the the last dice it like rolling 3 red and 2 black dice and saying I can reroll the black ones if they miss, where in reality you can reroll any 2 dice that miss. That formula shows returns low.Originally Posted by ArchonAstaroth
The correct formula (I don't have time to work it out right now as I'm at work), I expect to take more than a few lines of code to put together.
On the other hand there is an easy way to approximate the answer. NOTE this will be the WRONG answer, but it will be CLOSE:
Ask yourself how many times you expect to MISS without rerolls. Compare this number to the number of rerolls you have.
IF the # of rerolls is less than expected misses, then calculate the rerolls simply as additional attacks.
IF the # of rerolls is greater than the expected misses then calculate all to hit rolls as if they had rerolls available.
Greatest inaccuracy will occur when the two numbers are closest. and remember this is only an Approximation, not the Answer.
oh 2 more things:
1)The the approximation always errors in the direction of to high and in my test at max inaccuracy it was ~4% off usually much better though.
2)I've worked out the algorithim in my head but I'm going to check in on paper before I post it to make sure I didn't mess up. Tell me does your programming language have a decent math library? can it do factoral ie: !'s I was wrong before it is one equasion, but it does have factoral's and a simple summation. . . just wondering if you know how to work with those.
Last edited by JORMAGI; November 2nd, 2005 at 05:10.
I sent him a factorial function.
yeah, my other formula was off a bit...try this one...
hits equal shots taken minus misses. misses=x(6-bs)/6
for rerolls, we calculate misses misses and further subtract that.
for wounds, we have to kinda get tricky since GW didn't make it too easy for us
Strength=Toughness-4 OR greater can't be wounded.
Strength=Toughness-3 wounds on 6.
Strength=Toughness-2 wounds on 6
Strength=Toughness-1 wounds on 5
Strength=Toughness wounds on 4
Strength=Toughness+1 wounds on 3
Strength=Toughness+2 wounds on 2
Strength=Toughness+3 wounds on 2
Strength=Toughness+4 wounds on 2
Strength=Toughness+5 wounds on 2
Strength=Toughness+6 wounds on 2
Strength=Toughness+7 wounds on 2
so, wounds equal hits (H) or hits with rerolls of all misses(HWR) times (7- roll needed to wound)/6
but to elegantly figure out the roll needed to wound mathematically we need a cute formula...
saves made (SM)
If SV<AP then (7-SV)/6 is chance to save, so dead=W-W(SM)
still not elegant, but working on it...
Last edited by tarzen; November 2nd, 2005 at 09:26.
Once upon a time I programmed (in asp) a shooting calculator which calculates both probability distribution, (arithmetic) average and standard deviation.
Send me a PM with your emailadress and I will send you the code (20K). It will work if your computer has Internet Information Server innstalled (basically you need a profesional or server version of windows, XP home edition won't do).
All the algorithms are worked out in this calculator.