Friday, 29 July 2016

probability - Propability of M-faced dice rolling a greater result than an N-faced dice ( M



Hello I have a game-mechanic which goes like this:




Two-sides are rolling numbers. The defender rolls between [1,Armor_Value] , attacker rolls between [1,Damage_Value].



If the attacker_roll> defender_roll the damage is equal to attacker_roll - defender_roll. If not, no damage is dealt. Given




  1. Armour Value of defender

  2. Damage Value of attacker




What is the average damage that the attacker deals?


Answer



[It is unfortunate that armor and attack both begin with "A" while damage and defender both begin with "D". I will use different letters to avoid this confusion.]



Let N1 and N2 be the damage and armor values respectively, and let X1 and X2 be the random variable representing the roll of the attacker and the defender respectively. You are interested in the random variable
Y:=max(X1X2,0).



The expected value is
E[Y]=N2x2=1N1x1=1max(x1x2,0)P(X1=1,X2=x2)=min(N1,N2)x2=1N1x1=x2(x1x2)1N1N2only consider x1 when it is x2=1N1N2min(N1,N2)x2=1N1x2z=0z=1N1N2min(N1,N2)x2=1(N1x2)(N1x2+1)2=1N1N2N11k=N1min(N1,N2)k(k+1)2


The last sum is the sum of triangular numbers. You can use the formula for the sum of the first n triangular numbers n(n+1)(n+2)/6 to help compute. For example, if N1N2, then N1min(N1,N2)=0, so the sum is the sum of the first N11 triangular numbers, so the expected value is 1N1N2(N11)N1(N1+1)6. If N1>N2 you will need to do an extra step to subtract out the first few triangular numbers.



It will probably be easier to write out a table of all the possible outcomes and notice the pattern. For instance, when N1=4 and N2=5,
12341012320012300014000050000


so the expected value is
143((1+2+3)+(1+2)+1)=112(6+3+1)=56

This is consistent with our above formula in the case N1N2: 1N1N2(N11)N1(N1+1)6=1123456=56.



No comments:

Post a Comment

real analysis - How to find limhrightarrow0fracsin(ha)h

How to find limh0sin(ha)h without lhopital rule? I know when I use lhopital I easy get $$ \lim_{h\rightarrow 0}...