Last active
October 8, 2015 10:16
-
-
Save haraldh/50acc92867b12b2b266b 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 random | |
import math | |
item_min = 57 | |
item_max = 225 | |
num_simulation = 100000 | |
cost = 60000 | |
def draw(sm): | |
global s, item_min, item_max | |
t = random.randrange(item_min, item_max) | |
if t > s[0]: | |
sm = sm - s[0] + t | |
s[0] = t | |
s.sort() | |
return sm | |
def count(): | |
global s, item_min, item_max | |
n = 0 | |
for i in range(0,10): | |
s[i] = random.randrange(item_min, item_max) | |
# For an existing item, comment this out | |
# and fill in your values | |
# s = [ 47, 46, 36, 48, 45, | |
# 28, 43, 44, 40, 39 ] | |
s.sort() | |
sm = sum(s) | |
while sm < s95: | |
sm = draw(sm) | |
n+=1 | |
n95 = n | |
while sm < s99: | |
sm = draw(sm) | |
n+=1 | |
return n95, n | |
s95 = int(math.ceil(item_max * 9.5)) | |
s99 = int(math.ceil(item_max * 9.9)) | |
item_max+=1 | |
c95=[] | |
c99=[] | |
s=[ 0,0,0,0,0,0,0,0,0,0 ] | |
for k in xrange(0, num_simulation): | |
(n95, n99) = count() | |
c95.append(n95) | |
c99.append(n99) | |
c95.sort() | |
c99.sort() | |
item_max-=1 | |
print "%d simulation runs for item range %d-%d - Cost %d" % (num_simulation, item_min, item_max, cost) | |
print "25%% Chance of 95%% with %d reinforcements: %d gold" % (c95[num_simulation/4], c95[num_simulation/4]*cost) | |
print "50%% Chance of 95%% with %d reinforcements: %d gold" % (c95[num_simulation/2], c95[num_simulation/2]*cost) | |
print "75%% Chance of 95%% with %d reinforcements: %d gold" % (c95[num_simulation*3/4], c95[num_simulation*3/4]*cost) | |
print "90%% Chance of 95%% with %d reinforcements: %d gold" % (c95[num_simulation*9/10], c95[num_simulation*9/10]*cost) | |
print "25%% Chance of 99%% with %d reinforcements: %d gold" % (c99[num_simulation/4], c99[num_simulation/4]*cost) | |
print "50%% Chance of 99%% with %d reinforcements: %d gold" % (c99[num_simulation/2], c99[num_simulation/2]*cost) | |
print "75%% Chance of 99%% with %d reinforcements: %d gold" % (c99[num_simulation*3/4], c99[num_simulation*3/4]*cost) | |
print "90%% Chance of 99%% with %d reinforcements: %d gold" % (c99[num_simulation*9/10], c99[num_simulation*9/10]*cost) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment