In an online game I've came across, there's a formula for chance of a player being turned into a vampire/werewolf after initial exposure to a bite. With massive data collecting, I've sorted out the process behind the infection, but I'm wondering if somebody can take my research and move it to the next step and help me sort out some percentages/ averages on it.
First point of interest, 3 stats/variables which we use: RESIST, FAIL, INFECTION
RESIST is a player's will or constitution, which governs their chance to resist the infection spreading daily. It goes from 0 to 20+ (only over 20 in odd/unique situations such as when modified by gear/divine blessings).
FAIL is the number of failures to resist.
INFECTION is the amount the disease has taken hold over a player. At 100%, you're infected and become a vampire/werewolf.
Process for infection is fairly straightforward:
Each day, a D20 is rolled, which gives a random value of 1 to 20. On the case a 20 is rolled, a second D20 is rolled and added to that number, OPEN ENDED... Roll 20, 20, 20, 16, you get a total of 76... Each 20 adds another roll for DISEASE.
If the DISEASE roll > (RESIST - FAIL) then FAIL increases by one, and INFECTION increases by DISEASE - (RESIST - FAIL).
So, to give a real-world example: Resist = 10. Fail = 0. Infection = 0.
Day 1: Disease roll = 7. Resist is 10. No change.
Day 2: Disease roll = 16. Resist = 10. Failure! Fail = Fail + 1 (for a total of 1). Infection = 6%
Day 3: Disease roll = 10. Resist = 10. Fail = 1. ANOTHER FAILURE! Fail is now 2, infection is now 7%
And so on, until infection = 100% or player finds a cure...
*************************************************
Now, here's my statistic/probability/average problem: Is there a formula to calculate average time needed to get to 100% infection??
How many days, on average, would it take a person with a 10 (average) RESIST to become a full fledged werewolf/vampire? For a sickly person with a 5 RESIST?? Or a hero with a 18 RESIST??
I can plug the values into a set of FOR...NEXT loops and store results in an array of 10,000,000 infected at each level, and then use that to get an Average Time of Conversion, but can anyone come up with a formula to generate the answer so that given RESIST 10, they can instantly say, Average Time of Conversion = 18 days (or whatever)...
*************************************************
And, if anyone wants to compile and run a program to get actual data for this, here's a sample written in BASIC (native QB64 BASIC, able to be compiled in most BASIC dialects with minimal changes needed, and an easy enough pseudo-code in case anyone wants to translate to C, Java, Python, or whatever programming language they prefer).
Results which the above program generates are averages based on batches of 100,000 people being infected at each RESIST level, and for convenience's sake, I'm including the results below:
Note: Not included in this data set, but there's always a chance of someone becoming 100% infected in a single day's time, since the system uses an open roll with a 20.
Roll 20 (a 1 in 20 chance)... total is 20
Roll 20 (a 1 in 400 chance to get two 20s in a row)... total is 40
Roll 20 (a 1 in 8000 chance to get three 20s in a row)... total is 60
Roll 20 (a 1 in 160,000 chance to get four 20s in a row)... total is 80
Roll 20 (a 1 in 3,200,000 chance to get five 20s in a row)... total is 100
Infect a few billion people, and the infection total for one of them is going to be 200+... Any time we have ROLL - RESIST > 100, we're going to see a single day infection. It's not going to happen often, as the chance decreases the higher the RESIST is, but it's a lot like playing the lottery: ANY day could be the day where I win, as long as I keep playing...
And, also note that there's always a chance of somebody NEVER getting infected -- just roll below the RESIST each day, in perpetuation...
BUT, both of these are such rare occurrences (both a single day and infinite infection time), they'll eventually become moot outliers on our total AVERAGE...
*************************************************
And, at the end of the day, the final question (for me at least) remains: Can anyone come up with a simple formula to generate the AVERAGE using all the data provided? Running a set of a few million through the computer gives a very good estimation, but is there a formula for coming up with the actual value for the average at each range??
First point of interest, 3 stats/variables which we use: RESIST, FAIL, INFECTION
RESIST is a player's will or constitution, which governs their chance to resist the infection spreading daily. It goes from 0 to 20+ (only over 20 in odd/unique situations such as when modified by gear/divine blessings).
FAIL is the number of failures to resist.
INFECTION is the amount the disease has taken hold over a player. At 100%, you're infected and become a vampire/werewolf.
Process for infection is fairly straightforward:
Each day, a D20 is rolled, which gives a random value of 1 to 20. On the case a 20 is rolled, a second D20 is rolled and added to that number, OPEN ENDED... Roll 20, 20, 20, 16, you get a total of 76... Each 20 adds another roll for DISEASE.
If the DISEASE roll > (RESIST - FAIL) then FAIL increases by one, and INFECTION increases by DISEASE - (RESIST - FAIL).
So, to give a real-world example: Resist = 10. Fail = 0. Infection = 0.
Day 1: Disease roll = 7. Resist is 10. No change.
Day 2: Disease roll = 16. Resist = 10. Failure! Fail = Fail + 1 (for a total of 1). Infection = 6%
Day 3: Disease roll = 10. Resist = 10. Fail = 1. ANOTHER FAILURE! Fail is now 2, infection is now 7%
And so on, until infection = 100% or player finds a cure...
*************************************************
Now, here's my statistic/probability/average problem: Is there a formula to calculate average time needed to get to 100% infection??
How many days, on average, would it take a person with a 10 (average) RESIST to become a full fledged werewolf/vampire? For a sickly person with a 5 RESIST?? Or a hero with a 18 RESIST??
I can plug the values into a set of FOR...NEXT loops and store results in an array of 10,000,000 infected at each level, and then use that to get an Average Time of Conversion, but can anyone come up with a formula to generate the answer so that given RESIST 10, they can instantly say, Average Time of Conversion = 18 days (or whatever)...
*************************************************
And, if anyone wants to compile and run a program to get actual data for this, here's a sample written in BASIC (native QB64 BASIC, able to be compiled in most BASIC dialects with minimal changes needed, and an easy enough pseudo-code in case anyone wants to translate to C, Java, Python, or whatever programming language they prefer).
Code:
CONST Limit = 100000 'Number of people to get infected
CONST DIT = 0 '-1 to Display Individual Times, 0 to just print final results
DIM InfectionTime(0 TO Limit) AS INTEGER 'An array to store the amount of time required for infection to complete.
SCREEN _NEWIMAGE(800, 600, 32)
_SCREENMOVE _MIDDLE
RANDOMIZE TIMER
PRINT "Resist", "Average", "Min", "Max"
FOR Resist = 0 TO 30 'To calculate the changes for a whole range of subjects
ERASE InfectionTime 'Clear the array to store times for each batch being tested
FOR i = 1 TO Limit
infection = 0: fail = 0: Day = 0
DO UNTIL infection >= 100
InfectionTime(i) = InfectionTime(i) + 1 'Count day's progress for each person
Disease = 0
DO
r = INT(RND * 20) + 1 'Get a number from 1 to 20
Disease = Disease + r
LOOP UNTIL r <> 20 'incremement the total, until we quit rolling 20
IF Disease > Resist - fail THEN
infection = infection + Disease - (Resist - fail)
fail = fail + 1
END IF
LOOP
NEXT
TotalTime = 0
MinTime = InfectionTime(1)
MaxTime = InfectionTime(1)
FOR i = 1 TO Limit
IF DIT THEN PRINT "Time to Infection for Patient #"; i; ": "; InfectionTime(i)
TotalTime = TotalTime + InfectionTime(i)
IF InfectionTime(i) <= MinTime THEN MinTime = InfectionTime(i)
IF InfectionTime(i) >= MaxTime THEN MaxTime = InfectionTime(i)
NEXT
PRINT Resist, TotalTime / Limit, MinTime, MaxTime
NEXT
Results which the above program generates are averages based on batches of 100,000 people being infected at each RESIST level, and for convenience's sake, I'm including the results below:
Code:
Resist Average Min Max
0 7.62 2 12
1 8.05 2 13
2 8.56 2 16
3 9.13 2 16
4 9.81 2 18
5 10.55 3 22
6 11.40 2 23
7 12.37 3 25
8 13.48 2 29
9 14.73 3 32
10 16.19 3 37
11 17.85 3 41
12 19.81 2 48
13 22.12 5 55
14 24.92 5 59
15 28.39 2 91
16 32.79 7 86
17 38.77 3 107
18 47.76 9 164
19 66.14 9 299
20 84.05 8 297
21 102.95 8 387
22 122.58 12 446
23 142.87 16 519
24 164.26 4 542
25 186.56 5 547
26 209.39 3 600
27 233.74 22 705
28 259.92 17 759
29 288.08 34 874
30 319.07 40 847
Note: Not included in this data set, but there's always a chance of someone becoming 100% infected in a single day's time, since the system uses an open roll with a 20.
Roll 20 (a 1 in 20 chance)... total is 20
Roll 20 (a 1 in 400 chance to get two 20s in a row)... total is 40
Roll 20 (a 1 in 8000 chance to get three 20s in a row)... total is 60
Roll 20 (a 1 in 160,000 chance to get four 20s in a row)... total is 80
Roll 20 (a 1 in 3,200,000 chance to get five 20s in a row)... total is 100
Infect a few billion people, and the infection total for one of them is going to be 200+... Any time we have ROLL - RESIST > 100, we're going to see a single day infection. It's not going to happen often, as the chance decreases the higher the RESIST is, but it's a lot like playing the lottery: ANY day could be the day where I win, as long as I keep playing...
And, also note that there's always a chance of somebody NEVER getting infected -- just roll below the RESIST each day, in perpetuation...
BUT, both of these are such rare occurrences (both a single day and infinite infection time), they'll eventually become moot outliers on our total AVERAGE...
*************************************************
And, at the end of the day, the final question (for me at least) remains: Can anyone come up with a simple formula to generate the AVERAGE using all the data provided? Running a set of a few million through the computer gives a very good estimation, but is there a formula for coming up with the actual value for the average at each range??