User Tools

Site Tools


modding:guide:intro_dice_stats

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
modding:guide:intro_dice_stats [2012/04/08 19:07] – created rpcmodding:guide:intro_dice_stats [2014/12/27 04:40] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +===== Introduction to Dice Stats =====
  
 +considering a **aDb+c** dice throw
 +
 +  * min damage: **a+c**
 +  * max damage: **ab+c**
 +  * average between max damage and min damage: **(ab+a+2c)/2**
 +
 +now, we want to calculate 2 arrays, the first is the array with the list of all possible throw in order: lets call this a1
 +it start at **a+c** and finishes at **ab+c**
 +so
 +<code>
 +a+c, a+c+1, ..., ab+c-1, ab+c
 +</code>
 +how long is this array ? **ab-a+1**
 +
 +now let's consider a second array (a2), as long as the first, and fill it with the corresponding values of the probability of the throw.
 +We discovered that we can calculate the values of the probability from the diagonals of the Pascal's triangle.
 +the values are exactly the values of the diagonal number a, up to the value b
 +The additional values, up to the half of the array lenght or half of the array leght +1 (if the array is odd) are calculated as : number of the pascal's triangle-(number of the 1st pascal triangle at the same diagonal*a), number of the pascal's triagle-(number of 2nd pascal triangle at the same diagonal*a)
 +
 +moreover the sum of all the numbers of **a2 = b^a**
 +
 +
 +
 +
 +Example, step by step:
 +lets take 3d5 (aDb)
 +lenght of the array is: ab-a+1=13
 +a1=3,4,5,6,7,8,9,10,11,12,13,14,15
 +
 +the a (so the third) pascal's triangle diagonal is: 1,3,6,10,15,21,28,36,....
 +so let's put the numbers of the diagonal up to b in the a2
 +a2=1,3,6,10,15,x,y,x,15,10,6,3,1
 +x will be 21-(a*1)=18
 +where 1 is the first number of the same diagonal
 +y will be 28-(a*3)=19
 +where 3 is the second number of the same diagonal
 +as a check of our calculations: 1+3+6+10+15+18+19+18+15+10+6+3+1=125
 +and 125 = 5^3 (b^a)
 +
 +
 +
 +
 +Resolved dices thows, as full examples:
 +<code>
 +2d6+1
 +3,4,5,6,7,8,9,10,11,12,13
 +1,2,3,4,5,6,5,4,3,2,1
 +
 +
 +3d6+1
 +4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
 +1,3,6,10,15,21,25,27,27,25,21,15,10,6,3,1
 +
 +4d3
 +4,5,6,7,8,9,10,11,12
 +1,4,10,16,19,16,10,4,1
 +
 +3d3
 +3,4,5,6,7,8,9
 +1,3,6,7,6,3,1
 +
 +3d4
 +3,4,5,6,7,8,9,10,11,12
 +1,3,6,10,12,12,10,6,3,1
 +
 +5d4
 +5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
 +1,5,15,35,65,101,135,155,155,135,101,65,35,15,5,1
 +</code>
 +
 +Resources:
 +an interactive pascal's triangle
 +http://mathforum.org/dr.cgi/pascal.cgi?rows=20
 +
 +to get the diagonal
 +
 +all negative terms are 0
 +
 +the 0 term is always 1
 +
 +the nth term is the ∏ from i=1 to n of (a + i - 1)/i
 +
 +<code>
 +number of the pascal's triangle-(number of the 1st pascal triangle at the same diagonal*a),
 +number of the pascal's triangle-(number of 2nd pascal triangle at the same diagonal*a)
 +</code>
 +Just to clarify this you can have more than two extra numbers they just follow the same pattern.
 +
 +lets do some pseudo code to fill out a2 Very Happy
 +
 +lets define N(x,y) as the y term on the x diagonal
 +lets define the current terms index as t
 +lets define the array length as l
 +<code>
 +for every t up to and including l/2 - 1 + l%2
 +{
 +   the t term is N(a,t)-(a*N(a,t-b))
 +   the l - t - 1 term is the same as the t term
 +}
 +</code>
 +how does that look (might be an off by one error but that is the basic look)
 +
 +There's an excellent online dice roll probability calculator at http://topps.diku.dk/torbenm/troll.msp 
 +It has tons of features and will graph the results for you.
 +
 +===== Round off error =====
 +
 +Simple statistics unfortunately don't tell the whole story. Because Transcendence uses integer math lower damage weapons can lose a great deal to roundoff error while higher damage weapons lose proportionally less.  
 +
 +Take for example the basic 1d4 laser cannon and 3d4 turbolaser cannon.  
 +
 +Let's assume basic armor. Armor that has no defined resistances still has resistances and vulnerabilities derived from its level. (see [[modding/shield_and_level_damage_adjustment_curves1.01|shield and level damage adjustment curves1.01]])  
 +
 +The laser resistance by level is in the hpBonus terminology used in most places in the game data
 +^ Level | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
 +^ Armor Laser Resistance | +0 | +25 | +67 | +150 | +300 | +614 | +1150 | +2400 | +4900 | *** |
 +
 +The formula in question is 100 / (100 + hpBonus) = percentile_resistance = 1 - damage_adjustment.  Remembering that percent is literally per hundred and to get a real ratio you simply move the decimal two places more significant.  
 +
 +First let's look at the laser colimnator.  It adds +75% damage.
 +
 +The laser is easy.  Just 1d4.
 +^ possible rolls | 1 | 2 | 3 | 4 | average |
 +^ laser | 1 | 2 | 3 | 4 | 2.5 |
 +^ colimnated laser | 1 | 3 | 5 | 7 | 4 |
 +
 +As you can see it only actually gains +60%.  
 +
 +The turbolaser is more troublesome with multiple dice.  
 +
 +^ possible rolls | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | average |
 +^ probability | 1/64 | 3/64 | 3/32 | 5/32 | 3/16 | 3/16 | 5/32 | 3/32 | 3/64 | 1/64 | - |
 +^ turbolaser | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 7.5 |
 +^ colimnated turbolaser | 5 | 7 | 8 | 10 | 12 | 14 | 15 | 17 | 19 | 21 | 12.75 |
 +
 +Now we're getting +70%.  
 +
 +Of course doing that in a table is cumbersome.  Unfortunately you cannot algebraicly simplify a series that contains the floor function.  Machine assistance is suggested.  
 +
 +Because I don't have anything like that set up right now I'm only going to do one example.  Well, two but since level 1 armor takes full rated damage from lasers that one's trivial.  
 +
 +^ possible rolls | 1 | 2 | 3 | 4 | average |
 +^ laser raw damage | 1 | 2 | 3 | 4 | 2.5 |
 +^ against light titanium | 1 | 2 | 3 | 4 | 2.5 |
 +^ against light plasteel | 0 | 1 | 1 | 2 | 1 |
 +
 +Rather than doing 60% as much damage against level 3 armor as against level 1 the laser is doing 40%, a 50% drop in effectiveness due to roundoff.
 +
 +^ possible rolls | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | average |
 +^ probability | 1/64 | 3/64 | 3/32 | 5/32 | 3/16 | 3/16 | 5/32 | 3/32 | 3/64 | 1/64 | - |
 +^ turbolaser raw damage | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 7.5 |
 +^ against light titanium | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 7.5 |
 +^ against light plasteel | 1 | 2 | 3 | 3 | 4 | 4 | 5 | 6 | 6 | 7 | 4.09375 |
 +
 +Roundoff still hurts dropping the damage from 60% to just under 55%, but that's about a 9% reduction in effectiveness, much better than the 50% drop the laser suffers from theoretical against the same armor.  
 +
 +Further examples will wait until I've made a script to do the math.