Gralamin
2009-12-18, 02:17 AM
So, I was approached with the question "If a Barbarian with a +6 Vorpal Falchion and Ancient Forebearers Rage attacked someone, what would their damage look like?"
As it turns out, the Expected Roll of a 1d4 weapon is 15. The Expected Roll of a 2d4 weapon is then 30.
Math Proof:
Possible rolls: 3, 7, 11, ... , 4n+3, ..., infinity.
Expected Value = 3 * p(3) + 7 * p(7) + 11 * p(7) + ... + (4n+3) * p(4n+3) + ... + infinity * p(infinity)
p(3) = 1/4 // Roll a 3
p(7) = 3/4 * 1/4 // roll a 1, 2, or 4 and roll a 3.
p(11) = 3/4 * 3 / 4 * 1/4 // roll a 1, 2, or 4 and 1, 2, or 4, and 3
etc.
Expected Value = sum_{n=0}^{infinity}(4n+3)(3/4)^n(1/4)
= (1/4)sum_{n=0}^{infinity}(4n+3)(3/4)^n
= (1/4){4*sum_{n=0}^{infinity}(n)(3/4)^n + 3*sum_{n=0}^{infinity}(3/4)^n}
This is a taylor series + a geometric series
= (1/4){4 * (3/4)/(1/16) + 3 * 1/(1/4)}
= (1/4){3 * 16 + 3 * 4} = 60/4 = 15
Therefore the expected value is 15.
However, the maths behind other rolls are not easy. So I wrote the following program:
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;
int VFDX(int x);
int randomInt(int, int);
int main()
{
unsigned int sum4 = 0;
unsigned int sum6 = 0;
unsigned int sum8 = 0;
unsigned int sum10 = 0;
unsigned int sum12 = 0;
double average;
srand((unsigned)time(0));
const int TRIALS = 100000000;
for (unsigned int i = 0; i < TRIALS; i++)
{
sum4 += VFDX(4);
sum6 += VFDX(6);
sum8 += VFDX(8);
sum10 += VFDX(10);
sum12 += VFDX(12);
}
average = (double) sum4 / (double) TRIALS;
cout << "VFD4 Average: " << average << endl;
average = (double) sum6 / (double) TRIALS;
cout << "VFD6 Average: " << average << endl;
average = (double) sum8 / (double) TRIALS;
cout << "VFD8 Average: " << average << endl;
average = (double) sum10 / (double) TRIALS;
cout << "VFD10 Average: " << average << endl;
average = (double) sum12 / (double) TRIALS;
cout << "VFD12 Average: " << average << endl;
system("PAUSE");
return 0;
}
int VFDX(int x)
{
int roll = randomInt(1, x);
if(roll == 1 || roll == 2 || roll == x)
return x+VFDX(x);
else
return roll;
}
int randomInt(int low, int high){
int random;
int range;
high += 1;
low -= 1;
range = (high - low) + 1;
do {
random = low + int(range * rand() / (RAND_MAX + 1.0));
} while (random >= high || random <= low);
return random;
}
Which gives the following results per die:
VFD4 = 14.9984
VFD6 = 9.99986
VFD8 = 9.79977
VFD10 = 10.2862
VFD12 = 10.9999
My MathFu is too weak to tell me the exact value of anything >D4 (I was getting 7.4444444 for D12), but I'm sure Yakk or someone could give exact values.
Edit: Full values found!
The Expected damage value for a weapon of Die Size X, where X >= 3
D = 1/X * (sum from 3 to X-1) + 3/X * (D + X)
XD = (X)(X-1)/2 - 1 - 2 + 3D + 3X
2(X-3) D = (X^2+5X-6) = (X+6)(X-1)
D = (X+6)(X-1)/(2X-6)
Using in Damage Calculations
The following are exact values:
{table=head]Die|Value
d4|15
d6|10
d8|9.8
d10|72/7
d12|11[/table]
In a given damage amount, add up all dice of the same type, and then multiply by the corresponding values. Then add all the dice together.
For example, if an attack deals 5d6+3d4+6d12 damage (For some reason), then it would deal 5*10+3*15+6*11 = 50+45+66 = 161 damage on average.
Hope this is useful to someone!
Edit:
Ancient Forebearers without Vorpal
E(d4) = 3*1/4 + 4 * 3 /4 = 3.75
E(d6) = 1/6 * (3 + 4 + 5 + 6 * 3) = 5
E(d8) = 1/8 * (3 + 4 + 5 + 6 + 7 + 8 * 3) = 6.125
E(d10) = 1/10 * (3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 * 3) = 7.2
E(d12) = 1/12 * (3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 * 3) = 8.25
The above are exact values.
As it turns out, the Expected Roll of a 1d4 weapon is 15. The Expected Roll of a 2d4 weapon is then 30.
Math Proof:
Possible rolls: 3, 7, 11, ... , 4n+3, ..., infinity.
Expected Value = 3 * p(3) + 7 * p(7) + 11 * p(7) + ... + (4n+3) * p(4n+3) + ... + infinity * p(infinity)
p(3) = 1/4 // Roll a 3
p(7) = 3/4 * 1/4 // roll a 1, 2, or 4 and roll a 3.
p(11) = 3/4 * 3 / 4 * 1/4 // roll a 1, 2, or 4 and 1, 2, or 4, and 3
etc.
Expected Value = sum_{n=0}^{infinity}(4n+3)(3/4)^n(1/4)
= (1/4)sum_{n=0}^{infinity}(4n+3)(3/4)^n
= (1/4){4*sum_{n=0}^{infinity}(n)(3/4)^n + 3*sum_{n=0}^{infinity}(3/4)^n}
This is a taylor series + a geometric series
= (1/4){4 * (3/4)/(1/16) + 3 * 1/(1/4)}
= (1/4){3 * 16 + 3 * 4} = 60/4 = 15
Therefore the expected value is 15.
However, the maths behind other rolls are not easy. So I wrote the following program:
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;
int VFDX(int x);
int randomInt(int, int);
int main()
{
unsigned int sum4 = 0;
unsigned int sum6 = 0;
unsigned int sum8 = 0;
unsigned int sum10 = 0;
unsigned int sum12 = 0;
double average;
srand((unsigned)time(0));
const int TRIALS = 100000000;
for (unsigned int i = 0; i < TRIALS; i++)
{
sum4 += VFDX(4);
sum6 += VFDX(6);
sum8 += VFDX(8);
sum10 += VFDX(10);
sum12 += VFDX(12);
}
average = (double) sum4 / (double) TRIALS;
cout << "VFD4 Average: " << average << endl;
average = (double) sum6 / (double) TRIALS;
cout << "VFD6 Average: " << average << endl;
average = (double) sum8 / (double) TRIALS;
cout << "VFD8 Average: " << average << endl;
average = (double) sum10 / (double) TRIALS;
cout << "VFD10 Average: " << average << endl;
average = (double) sum12 / (double) TRIALS;
cout << "VFD12 Average: " << average << endl;
system("PAUSE");
return 0;
}
int VFDX(int x)
{
int roll = randomInt(1, x);
if(roll == 1 || roll == 2 || roll == x)
return x+VFDX(x);
else
return roll;
}
int randomInt(int low, int high){
int random;
int range;
high += 1;
low -= 1;
range = (high - low) + 1;
do {
random = low + int(range * rand() / (RAND_MAX + 1.0));
} while (random >= high || random <= low);
return random;
}
Which gives the following results per die:
VFD4 = 14.9984
VFD6 = 9.99986
VFD8 = 9.79977
VFD10 = 10.2862
VFD12 = 10.9999
My MathFu is too weak to tell me the exact value of anything >D4 (I was getting 7.4444444 for D12), but I'm sure Yakk or someone could give exact values.
Edit: Full values found!
The Expected damage value for a weapon of Die Size X, where X >= 3
D = 1/X * (sum from 3 to X-1) + 3/X * (D + X)
XD = (X)(X-1)/2 - 1 - 2 + 3D + 3X
2(X-3) D = (X^2+5X-6) = (X+6)(X-1)
D = (X+6)(X-1)/(2X-6)
Using in Damage Calculations
The following are exact values:
{table=head]Die|Value
d4|15
d6|10
d8|9.8
d10|72/7
d12|11[/table]
In a given damage amount, add up all dice of the same type, and then multiply by the corresponding values. Then add all the dice together.
For example, if an attack deals 5d6+3d4+6d12 damage (For some reason), then it would deal 5*10+3*15+6*11 = 50+45+66 = 161 damage on average.
Hope this is useful to someone!
Edit:
Ancient Forebearers without Vorpal
E(d4) = 3*1/4 + 4 * 3 /4 = 3.75
E(d6) = 1/6 * (3 + 4 + 5 + 6 * 3) = 5
E(d8) = 1/8 * (3 + 4 + 5 + 6 + 7 + 8 * 3) = 6.125
E(d10) = 1/10 * (3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 * 3) = 7.2
E(d12) = 1/12 * (3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 * 3) = 8.25
The above are exact values.