Guest User

Un'goro packs code

a guest
Apr 14th, 2017
23,899
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import numpy as np
  3.  
  4. #Un'goro Numbers
  5. numcom=49
  6. numrare=36
  7. numepic=27
  8. numlegend=23
  9.  
  10.  
  11. class Count:
  12.     def __init__(self):
  13.         self.common=0
  14.         self.rare=0
  15.         self.epic=0
  16.         self.legend=0
  17.         self.goldcom=0
  18.         self.goldrare=0
  19.         self.goldepic=0
  20.         self.goldleg=0
  21.         self.packs=0
  22.         self.dust=0
  23.    
  24.     def Progress(self):
  25.         comneed=(2*numcom-self.common)*40
  26.         rarneed=(2*numrare-self.rare)*100
  27.         epicneed=(2*numepic-self.epic)*400
  28.         legneed=(numlegend-self.legend)*1600
  29.         dustneed=comneed+rarneed+epicneed+legneed
  30.         diff=self.dust-dustneed
  31.         if diff < 0:
  32.             return 1
  33.         elif diff >=0:
  34.             return 0
  35.    
  36.     def PackInc(self):
  37.         self.packs+=1
  38.    
  39.     def Common(self):
  40.         if np.random.rand() > self.common/numcom/2:
  41.             self.common+=1
  42.         else:
  43.             self.dust+=5
  44.    
  45.     def Rare(self):
  46.         if np.random.rand() > self.rare/numrare/2:
  47.             self.rare+=1
  48.         else:
  49.             self.dust+=20
  50.    
  51.     def Epic(self):
  52.         if np.random.rand() > self.epic/numepic/2:
  53.             self.epic+=1
  54.         else:
  55.             self.dust+=100
  56.    
  57.     def Legend(self):
  58.         if np.random.rand() > self.legend/numlegend:
  59.             self.legend+=1
  60.         else:
  61.             self.dust+=400
  62.    
  63.     def Gcommon(self):
  64.         self.dust+=50
  65.    
  66.     def Grare(self):
  67.         self.dust+=100
  68.    
  69.     def Gepic(self):
  70.         self.dust+=400
  71.    
  72.     def Glegend(self):
  73.         self.dust+=1600
  74.  
  75. def GenCard(stats):
  76.     card=np.random.rand()
  77.     if card < .701362:
  78.         stats.Common()
  79.     elif card-.701362 < .209809:
  80.         stats.Rare()
  81.     elif card-.911172 < .043960:
  82.         stats.Epic()
  83.     elif card-.955132 < .011262:
  84.         stats.Legend()
  85.     elif card-.966394 < .014714:
  86.         stats.Gcommon()
  87.     elif card-.981108 < .015441:
  88.         stats.Grare()
  89.     elif card-.996549 < .002361:
  90.         stats.Gepic()
  91.     elif card-.998910 < .001090:
  92.         stats.Glegend()
  93.  
  94. def OpenPack(stats):
  95.     stats.PackInc()
  96.     for i in range(5):
  97.         GenCard(stats)
  98.  
  99. def WriteResults(numpacks):
  100.     with open("Results.txt","a") as file:
  101.         file.write("{}\n".format(numpacks))
  102.  
  103. def Trial():
  104.     stats=Count()
  105.     while stats.Progress():
  106.         OpenPack(stats)
  107.     WriteResults(stats.packs)
  108.  
  109. def RunSim(n):
  110.     with open("Results.txt","w") as file:
  111.         file.write("")
  112.     for i in range(n):
  113.         Trial()
  114.     print("Complete")
  115.  
  116. RunSim(100)
RAW Paste Data