Last active
April 16, 2017 11:53
-
-
Save idiotandrobot/61600e72cba12f7122f0f3cb6cf4b1da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
#Un'goro Numbers | |
numcom=49 | |
numrare=36 | |
numepic=27 | |
numlegend=23 | |
class Count: | |
def __init__(self): | |
self.common=0 | |
self.rare=0 | |
self.epic=0 | |
self.legend=0 | |
self.goldcom=0 | |
self.goldrare=0 | |
self.goldepic=0 | |
self.goldleg=0 | |
self.packs=0 | |
self.dust=0 | |
def Progress(self): | |
comneed=(2*numcom-self.common)*40 | |
rarneed=(2*numrare-self.rare)*100 | |
epicneed=(2*numepic-self.epic)*400 | |
legneed=(numlegend-self.legend)*1600 | |
dustneed=comneed+rarneed+epicneed+legneed | |
diff=self.dust-dustneed | |
if diff < 0: | |
return 1 | |
elif diff >=0: | |
return 0 | |
def PackInc(self): | |
self.packs+=1 | |
def Common(self): | |
if np.random.rand() > self.common/numcom/2: | |
self.common+=1 | |
else: | |
self.dust+=5 | |
def Rare(self): | |
if np.random.rand() > self.rare/numrare/2: | |
self.rare+=1 | |
else: | |
self.dust+=20 | |
def Epic(self): | |
if np.random.rand() > self.epic/numepic/2: | |
self.epic+=1 | |
else: | |
self.dust+=100 | |
def Legend(self): | |
if np.random.rand() > self.legend/numlegend: | |
self.legend+=1 | |
else: | |
self.dust+=400 | |
def Gcommon(self): | |
self.dust+=50 | |
def Grare(self): | |
self.dust+=100 | |
def Gepic(self): | |
self.dust+=400 | |
def Glegend(self): | |
self.dust+=1600 | |
def GenCard(stats): | |
card=np.random.rand() | |
if card < .701362: | |
stats.Common() | |
elif card-.701362 < .209809: | |
stats.Rare() | |
elif card-.911172 < .043960: | |
stats.Epic() | |
elif card-.955132 < .011262: | |
stats.Legend() | |
elif card-.966394 < .014714: | |
stats.Gcommon() | |
elif card-.981108 < .015441: | |
stats.Grare() | |
elif card-.996549 < .002361: | |
stats.Gepic() | |
elif card-.998910 < .001090: | |
stats.Glegend() | |
def OpenPack(stats): | |
stats.PackInc() | |
for i in range(5): | |
GenCard(stats) | |
def WriteResults(numpacks): | |
with open("Results.txt","a") as file: | |
file.write("{}\n".format(numpacks)) | |
def Trial(): | |
stats=Count() | |
while stats.Progress(): | |
OpenPack(stats) | |
WriteResults(stats.packs) | |
def RunSim(n): | |
with open("Results.txt","w") as file: | |
file.write("") | |
for i in range(n): | |
Trial() | |
print("Complete") | |
RunSim(100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment