I get this problem when I play computer game. When I see my knight is attacking the monster, I think what is the expectation value of fighting time. My knight is much more powerful than the monster, so my knight always win but what is the expectation value of fighting time.
So, I simulate the situation:
- Monster has Hp = 10000
- My knight deal damage vary from 400 to 600 (500+-100) uniform distribution.
- Each time that my knight attack has 5% chance to miss(no damage).
- Each time that my knight hit monster has 10% chance to deal 1000 critical damage(critical damage is constant).
- My knight attack speed is 1 time per second
What is the expectation value of fighting time ?
I calculate this by using DpS or damage per second.
mean(DpS) = 95%x((500x90%)+(1000x10%)) = 0.95*(0.9*500+0.1*1000) = 522.5
mean(Number of Hit) = 10000/522.5 = 19.138756
mean(fighting time) = (19.138756-1)/1 = 18.138756 second
I also use program to make sure that I am correct. I use online python.
https://www.onlinegdb.com/online_python_compiler
from random import randint;
n=100000;
H=0;
Hp=10000;
for x in range(1, n):
x=0;
h=0;
while Hp > x:
temp=randint(1,100);
if temp > 5:
temp=randint(1,100);
if temp > 10:
x=x+randint(400, 600);
else:
x=x+1000;
h=h+1;
H=H+h;
print('h_ave =',H/n)
The program yield mean(Number of Hit) = 19.69778 which has some different from my calculation. I don't know why. I should be nearly same because I simulate 100000 time.
Please help me or tell me what is incorrect.