Last active
February 23, 2020 21:14
-
-
Save JulianNorton/0a1bf20fc43248e55be9e4c02ed547ad to your computer and use it in GitHub Desktop.
Calculating loot distribution for a given player base
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
from random import * | |
# lock the results for reproducibility | |
seed(1) | |
# Staff of shadow flame is estimated to be between 7-8% | |
drop_rate = .075 | |
# Total players who are competing | |
pool_size = 3 | |
# How many runs before the pool size gets all their drops | |
# 52 would be a year, once a week | |
runs = 52 | |
## How accurate the calcuation is | |
simulations = 100000 | |
def reset_pool_to_original(n): | |
return list(range(n)) | |
def simulate_drop(pool): | |
if len(pool) is not 0 and random() < drop_rate: | |
pool.remove(choice(pool)) | |
return pool | |
def epochs(simultations): | |
success_count, failure_count = 0, 0 | |
for i in range(simulations): | |
if i%1000 == 0: | |
print(i) | |
pool = reset_pool_to_original(pool_size) | |
# print('========================') | |
# print('\n', 'begin epoch', i) | |
for j in range(runs): | |
# print('current_pool', pool) | |
simulate_drop(pool) | |
# print('ending_pool', pool, '\n') | |
if len(pool) == 0: | |
success_count = success_count + 1 | |
# print('success count', success_count, 'simulation count', simulations) | |
print(success_count/simulations) | |
epochs(simulations) | |
# 55% with four people | |
# 76% with three people |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment