Advertisement
Guest User

OPTC TM Simulation Script

a guest
Feb 20th, 2022
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.25 KB | None | 0 0
  1. import numpy
  2. import time
  3.  
  4. points = "Treasure Map Point Spot"
  5. gChest = "Golden Chest Spot"
  6. cChest = "Crystal Chest Spot"
  7. buff = "Buff Spot"
  8. bento = "Bento Spot"
  9. encounter = "Encounter Spot"
  10. empty = "Empty Spot"
  11. bird = "Bird Spot"
  12. rollUp = "Roll Increase Spot"
  13. rush = "Battle Rush Spot"
  14. start = "Starting Spot"
  15.  
  16. record = { points: 0, gChest: 0, cChest: 0, buff: 0, bento: 0, encounter: 0, empty: 0, bird: 0, rollUp: 0, rush: 0, start: 0 }
  17.  
  18. shortPath = [ start, bird, bird, bird, bird, bird, empty, empty, empty, empty, empty, empty, rollUp, empty, rollUp, empty, rollUp, empty, empty, empty, empty, empty, empty, rush ]
  19. bentoPath = [ start, bird, bird, bird, bird, bird, empty, empty, empty, empty, empty, empty, rollUp, empty, gChest, gChest, bento, buff, empty, encounter, points, buff, points, points, empty, empty, rush ]
  20. newBentoPath = [ start, bird, bird, bird, bird, bird, empty, empty, empty, empty, empty, rollUp, empty, empty, empty, empty, buff, buff, gChest, encounter, points, bento, buff, empty, rush ]
  21. secretPath = [ start, bird, bird, bird, bird, bird, buff, cChest, cChest, cChest, cChest, cChest, cChest, encounter, cChest, cChest, cChest, cChest, cChest, cChest, buff, empty, empty, buff, cChest, cChest, cChest, cChest, cChest, cChest, encounter, cChest, cChest, cChest, cChest, cChest, cChest, empty, rush ]
  22. mapTM = secretPath
  23.  
  24. stamina = 1000000000
  25. #stamina = 200000
  26. currentPos = 0
  27. rollBonus = 0
  28.  
  29. startingStamina = stamina
  30. staminaUsed = 0
  31.  
  32. #for x in range(len(mapTM)):
  33.     #print(x, mapTM[x])
  34.  
  35. def roll(bonus = 0):
  36.     global stamina
  37.     global staminaUsed
  38.     stamina -= 6
  39.     staminaUsed += 6
  40.     return(numpy.random.randint(1,5+1)+bonus)
  41.  
  42. def move(position, amount):
  43.     ahead = mapTM[position+1:position+amount+1]
  44.     if encounter in ahead:
  45.         return(position + ahead.index(encounter) + 1)
  46.     elif rush in ahead:
  47.         return(position + ahead.index(rush) + 1)
  48.     else:
  49.         return(position + amount)
  50.  
  51. def bentoBonus():
  52.     return([50, 75, 100][numpy.random.randint(0,3)])
  53.  
  54. def markRecord():
  55.     global record
  56.     record[mapTM[currentPos]] += 1
  57.  
  58. def runSimulation():
  59.     global stamina
  60.     global currentPos
  61.     global rollBonus
  62.     while (stamina > 6):
  63.         #print(stamina, currentPos, rollBonus)
  64.         markRecord()
  65.         if (currentPos == len(mapTM) - 1):
  66.             currentPos = 0 #reset back to start
  67.  
  68.         #Stamina and Roll modifiers
  69.         if (mapTM[currentPos] == rollUp):
  70.             rollBonus = 3
  71.         if (mapTM[currentPos] == buff):
  72.             rollBonus = 0
  73.         if (mapTM[currentPos] == bento):
  74.             stamina += bentoBonus()
  75.  
  76.         if (rollBonus > 0):
  77.             currentPos = move(currentPos, roll(1))
  78.             rollBonus -= 1
  79.         else:
  80.             currentPos = move(currentPos, roll(0))
  81.  
  82. print("Secret Map Chest Path Test. Starting Stamina: " + format(startingStamina, ","))
  83. print("-"*(len("Secret Map Chest Path Test. Starting Stamina: " + format(startingStamina, ","))))
  84. startTime = time.time()
  85. runSimulation()
  86. endTime = time.time()
  87. #print(record)
  88. print("Summary:")
  89. print("Full Maps Completed: " + format(record[rush], ",") + " Map(s)")
  90. print("Bento Boxes Obtained: " +format(record[bento], ",") + " Box(es)")
  91. print("Gold Chests Obtained: " +format(record[gChest], ",") + " Chest(s)")
  92. print("Crystal Chests Obtained: " +format(record[cChest], ",") + " Chest(s)")
  93. print("")
  94.  
  95. try:
  96.     print("Stamina to complete Full Map: " + str(round(staminaUsed/record[rush],3)) + " Stam/Map")
  97. except ZeroDivisionError:
  98.     print("Number of Full Maps is zero. Stam/Map not calculated")
  99. try:
  100.     print("Bento per Full Map: " + str(round(record[bento]/record[rush],3)) + " Bento/Map")
  101. except ZeroDivisionError:
  102.     print("Number of Full Maps is zero. Bento/Map not calculated")
  103. try:
  104.     print("Full Map per Bento: " + str(round(record[rush]/record[bento],3)) + " Map/Bento")
  105. except ZeroDivisionError:
  106.     print("Number of Bento Boxes is zero. Map/Bento not calculated")
  107. try:
  108.     print("Crystal Chests per Bento: " + str(round(record[cChest]/record[rush],3)) + " Chests/Map")
  109. except ZeroDivisionError:
  110.     print("Number of Crystal Chests is zero. Crystal Chests/Map not calculated")
  111.  
  112. print("")
  113. print("Simulation elapsed in: " + str(round(endTime-startTime,5)) + " seconds")
  114.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement