Advertisement
Aenimus

Friar Simulator.py

Jun 17th, 2019
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. import random
  2. import math
  3. import statistics
  4.  
  5. # Run the code online here: https://repl.it/languages/python3
  6.  
  7. # CHANGE THESE
  8. numberOfStenchJellies = 0
  9. bonusNC = 25
  10.  
  11. nativeNC = 10
  12. actualNC = nativeNC + bonusNC
  13. instances = 10000
  14. results = []
  15. jellyResults = []
  16.  
  17. for i in range(instances):
  18. zones = 0
  19. totalTurnsSpent = 0
  20. totalJellyTurnsSpent = 0
  21. stenchJellies = numberOfStenchJellies
  22. while zones < 3:
  23. totalNCs = 0
  24. turnsSpent = 0
  25. jellyTurnsSpent = 0
  26. jelliesUsed = False
  27. while totalNCs < 3:
  28. if not jelliesUsed:
  29. if stenchJellies > (2 - totalNCs) * (3 - zones):
  30. jelliesToUse = 3 - totalNCs
  31. stenchJellies -= jelliesToUse
  32. jellyTurnsSpent += jelliesToUse
  33. jelliesUsed = True
  34. else:
  35. jellyTurnsSpent += 1
  36. if (random.randrange(0,100) < actualNC) or (math.floor(turnsSpent/5) > totalNCs):
  37. totalNCs += 1
  38. turnsSpent += 1
  39. zones += 1
  40. totalTurnsSpent += turnsSpent
  41. totalJellyTurnsSpent += jellyTurnsSpent
  42. results.append(totalTurnsSpent)
  43. jellyResults.append(totalJellyTurnsSpent)
  44. if numberOfStenchJellies == 0:
  45. 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 {}."
  46. .format(instances, bonusNC, statistics.mean(results), statistics.harmonic_mean(results), statistics.median(results), statistics.pstdev(results)))
  47. else:
  48. 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 {}."
  49. .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