Advertisement
Guest User

Damage av calculation

a guest
Sep 18th, 2023
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. NUMBER_OF_STUBS = 10
  2. DEF_REG_CHANCE = 0.90
  3. SAMPLE_NUM = 10000
  4.  
  5. def main():
  6.     import matplotlib.pyplot as plt
  7.     import random as rn
  8.    
  9.     regDam = 20
  10.     critDam = 80
  11.     regChance = 0.90
  12.  
  13.     totalDam = 0
  14.     avList = []
  15.  
  16.     for stub in range(0, SAMPLE_NUM):
  17.         if (rn.random() <= regChance):
  18.             totalDam += regDam
  19.             regChance -= 0.03
  20.         else:
  21.             totalDam += critDam
  22.             regChance = DEF_REG_CHANCE
  23.        
  24.         avList.append(totalDam / (stub + 1))
  25.  
  26.        
  27.     plt.figure(figsize=(20, 10))
  28.     plt.text(1000, 32, f"Approximate damage is {avList[-1]}", color='black', fontsize=32)
  29.     plt.plot(avList)
  30.     plt.title("Average damage approximation")
  31.     plt.xlabel("Number of samples")
  32.     plt.ylabel("Average damage")
  33.  
  34.     plt.show()
  35.  
  36. if __name__ == "__main__":
  37.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement