Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import math
- import statistics
- # Run the code online here: https://repl.it/languages/python3
- # CHANGE THESE
- numberOfStenchJellies = 0
- bonusNC = 25
- nativeNC = 10
- actualNC = nativeNC + bonusNC
- instances = 10000
- results = []
- jellyResults = []
- for i in range(instances):
- zones = 0
- totalTurnsSpent = 0
- totalJellyTurnsSpent = 0
- stenchJellies = numberOfStenchJellies
- while zones < 3:
- totalNCs = 0
- turnsSpent = 0
- jellyTurnsSpent = 0
- jelliesUsed = False
- while totalNCs < 3:
- if not jelliesUsed:
- if stenchJellies > (2 - totalNCs) * (3 - zones):
- jelliesToUse = 3 - totalNCs
- stenchJellies -= jelliesToUse
- jellyTurnsSpent += jelliesToUse
- jelliesUsed = True
- else:
- jellyTurnsSpent += 1
- if (random.randrange(0,100) < actualNC) or (math.floor(turnsSpent/5) > totalNCs):
- totalNCs += 1
- turnsSpent += 1
- zones += 1
- totalTurnsSpent += turnsSpent
- totalJellyTurnsSpent += jellyTurnsSpent
- results.append(totalTurnsSpent)
- jellyResults.append(totalJellyTurnsSpent)
- if numberOfStenchJellies == 0:
- print("In {} instances at {}% bonus +NC with no stench jellies, it required an average of {} turns to complete the friars quest, with a harmonic mean of {}, a median of {} and a deviation of {}."
- .format(instances, bonusNC, statistics.mean(results), statistics.harmonic_mean(results), statistics.median(results), statistics.pstdev(results)))
- else:
- print("In {} instances at {}% bonus +NC and {} optimally-used stench jellies, it required an average of {} turns to complete the friars quest, and each stench jelly saved an average of {} turns. The harmonic mean was {}, the median was {} and the deviation was {}."
- .format(instances, bonusNC, numberOfStenchJellies, statistics.mean(jellyResults), ((sum(results) - sum(jellyResults))/instances)/numberOfStenchJellies, statistics.harmonic_mean(jellyResults), statistics.median(jellyResults), statistics.pstdev(jellyResults)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement