Created
July 7, 2019 21:52
-
-
Save leoxs22/49aebcf0a452f3cc3ff64778e95c16c3 to your computer and use it in GitHub Desktop.
Archero simulation of chests
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 numpy as np | |
import scipy.stats as stats | |
import matplotlib.pyplot as plt | |
number_of_different_items = 16 | |
price_of_golden_chest = 60 | |
price_of_obsidian_chest = 300 | |
golden_probabilities = {0.8: 1, 0.2:3} | |
obsidian_probabilities = {0.5:3, 0.44:9, 0.06:27} | |
number_of_runs = 10000 | |
#Simulating golden | |
expended_list = [] | |
for i in range(number_of_runs): | |
items = dict.fromkeys(range(number_of_different_items),0) | |
expended = 0 | |
while(all([x < 27 for x in items.values()])): | |
expended += price_of_golden_chest | |
item = random.randrange(0,number_of_different_items) | |
quality = random.random() | |
if(quality > 0.8): | |
items[item] += 3 | |
else: | |
items[item] += 1 | |
expended_list.append(expended) | |
print(f"Median of expended to get an item: {np.percentile(expended_list, 50)}") | |
print(f"90% of the time you will get it for less than: {np.percentile(expended_list, 90)}") | |
print(f"10% of the time you will get it for less than: {np.percentile(expended_list, 10)}") | |
h = expended_list | |
h.sort() | |
hmean = np.mean(h) | |
hstd = np.std(h) | |
pdf = stats.norm.pdf(h, hmean, hstd) | |
plt.plot(h, pdf) | |
#Simulating obsidian | |
expended_list = [] | |
for i in range(number_of_runs): | |
items = dict.fromkeys(range(number_of_different_items),0) | |
expended = 0 | |
while(all([x < 27 for x in items.values()])): | |
expended += price_of_obsidian_chest | |
item = random.randrange(0,number_of_different_items) | |
quality = random.random() | |
if(quality <= 0.5): | |
items[item] += 3 | |
elif(quality <= 0.94): | |
items[item] += 9 | |
else: | |
items[item] += 27 | |
expended_list.append(expended) | |
print(f"Median of expended to get an item: {np.percentile(expended_list, 50)}") | |
print(f"90% of the time you will get it for less than: {np.percentile(expended_list, 90)}") | |
print(f"10% of the time you will get it for less than: {np.percentile(expended_list, 10)}") | |
h = expended_list | |
h.sort() | |
hmean = np.mean(h) | |
hstd = np.std(h) | |
pdf = stats.norm.pdf(h, hmean, hstd) | |
plt.plot(h, pdf) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment