I cleaned up the code in order to enhance the readability. It is also a good way to find failures, normally.
I just found one thing: I do average-x instead of x-average. As it is in brackets with a square on the outside, it doesn't matter. No failure here.
The rest, well... stayed as is. The results don't change as well - I calculated several times today.
'Sets the LP of the good to 100 to measure the real potential of each attacking monster.
'Then, the LP of each participant get reset to full befor the next fight is started.
'Otherwise, the measurement will always be cut as soon as the good one is dead; thus,
'producing wrong results.
HerosDamage = True
HerosDamageStdDev = True
AverageCompleteFightDamageStdDev = 0
ReDim singleCompleteFightDamage(amount)
Dim SumForStdDev As Double
TheGood.LP = 100
AverageCompleteFightDamage = 0
threeStrikes = 0
'simulate "amount" fights
For i = 0 To amount
'setup
TheGood.CurLP = TheGood.LP
TheBad.CurLP = TheBad.LP
'fight
FightOneMonster
'note results
SumCompleteFightDamage = SumCompleteFightDamage + (TheGood.LP - TheGood.CurLP)
CountCompleteFightDamage = CountCompleteFightDamage + 1
singleCompleteFightDamage(i) = TheGood.LP - TheGood.CurLP
If singleCompleteFightDamage(i) >= 100 Then
threeStrikes = threeStrikes + 1
If threeStrikes > 3 Then Exit For
End If
'Serve windows; prevent white screen
If (i Mod 1000) = 0 Then
DoEvents
End If
Next i
'See if we have a valid simulation
If threeStrikes > 3 Then
AverageCompleteFightDamage = 100
AverageCompleteFightDamageStdDev = 0
Exit Sub
End If
'Standard deviation gets calculated by:
'Square root of (
'Sum of (
'(average - current value)^2
')
'Divided by amount - 1
')
'First step: Calculate average
AverageCompleteFightDamage = SumCompleteFightDamage / CountCompleteFightDamage
'Second Step: Calculate sum of squares of distance between average and current value
SumForStdDev = 0
For i = 1 To amount
SumForStdDev = SumForStdDev + (AverageCompleteFightDamage - singleCompleteFightDamage(i)) ^ 2
Next i
'Third step: Divide by N-1 (Bessel corrected amount). Result: Variance
SumForStdDev = SumForStdDev / (amount - 1)
'Fourth step: SQRT of Variance to get useable result.
AverageCompleteFightDamageStdDev = Sqr(SumForStdDev)
End Sub
What is surprising me, is that you don't have a good formula for Number of attacks per Monster. In fact, this was exactly what was killing me on my first try to directly calculate the MSC. Now, with no Formula, but with the same results for MSC, our both ways of calculating prove to be correct for the MSC.
As I stated earlier: I find the Standard Deviation quite big. I found a good explanation in the meanwhile - A Goblin normally dies without doing damage, but if not, he has 2 Attack Dice which can damage a Hero quite easily; thus, the deviation in the results from the "normal" are quite high. Ok for me!
I loaded my Monster table into Spotfire in order to have some advanced analysis methods at hand. I found that there is a bunch of Monsters available who are quite reliable. The problem about them is that their strength is Fimir or more. An Ogre proves to be quite a good monster in terms of reliability. And everything else with 3+ Defense dice and 3+ Body Points.
Viewed from this angle, my result again looks quite logical to me.
Now, i didn't find a failure in my procedure and the results appear to fit with my picture of the reality.
I must confess, i couldn't find the formula in your Sheet on the first glance. I maybe take a look at it later, when i have more time.
Maybe you could take a look at my code snippet, too? In fact, it's the only relevant part and the complete Standard Deviation Formula is inside this Part of the code.
The other parts are caring only about in/output. Ah well, and about the Fight between Heros and Monsters... but through the MSC and several other measurements, this part has already been proven.






































