Advertisement
Guest User

TFT Rolldown Odds

a guest
Jun 7th, 2021
749
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. import random
  2.  
  3. # Rolls we're tracking
  4. rollsUntilFound = {
  5. "Hecarim": [],
  6. "Sejuani": [],
  7. "Nautilus": [],
  8. "Thresh": [],
  9. "All": []
  10. }
  11.  
  12. # The full simulation
  13. totalSimulations = 1000
  14. for i in range(0,totalSimulations):
  15. # Define the base champ pool
  16. champPool = {
  17. "Brand": 22,
  18. "Hecarim": 22,
  19. "Kennen": 22,
  20. "LeBlanc": 22,
  21. "Nautilus": 22,
  22. "Sejuani": 22,
  23. "Sett": 22,
  24. "Soraka": 22,
  25. "Syndra": 22,
  26. "Thresh": 22,
  27. "Trundle": 22,
  28. "Varus": 22,
  29. "Viktor": 22
  30. }
  31.  
  32. # Define current champs purchased
  33. currentChampsBought = {
  34. "Hecarim": 0,
  35. "Sejuani": 0,
  36. "Nautilus": 0,
  37. "Thresh": 0
  38. }
  39.  
  40. # Remove champs currently purchased from pool, and remove some number of other champs
  41. for champ in champPool:
  42. if (champ in currentChampsBought):
  43. # Remove the champs I'm currently holding from the total pool
  44. champPool[champ] -= currentChampsBought[champ]
  45. else:
  46. # Remove some number of other champs from the pool
  47. champPool[champ] -= 0
  48.  
  49. # Calculate num champs remaining
  50. totalChampsRemaining = 0
  51. for champ in champPool:
  52. totalChampsRemaining += champPool[champ]
  53.  
  54. # Do rolls until all are found
  55. numRolls = 0
  56. threeStars = 0
  57. while (currentChampsBought["Hecarim"] != 9 or
  58. currentChampsBought["Nautilus"] != 9 or
  59. currentChampsBought["Sejuani"] != 9 or
  60. currentChampsBought["Thresh"] != 9):
  61.  
  62. numRolls += 1
  63.  
  64. # Roll 5 times and then increment
  65. for i in range(0,5):
  66. rollChance = random.randint(1,100)
  67. if (rollChance > 40):
  68. continue # didn't roll 40% chance
  69.  
  70. # Now roll from remaining champs
  71. champRoll = random.randint(1, totalChampsRemaining)
  72.  
  73. # Find which champ was rolled based on "weighted champ pool"
  74. foundChamp = ""
  75. for champ in champPool:
  76. champRoll -= champPool[champ]
  77.  
  78. if (champRoll <= 0):
  79. foundChamp = champ
  80. break
  81.  
  82. if ((foundChamp in currentChampsBought) and (currentChampsBought[foundChamp] < 9)):
  83. currentChampsBought[foundChamp] += 1
  84. champPool[foundChamp] -= 1
  85. totalChampsRemaining -= 1
  86.  
  87. if currentChampsBought[foundChamp] == 9:
  88. rollsUntilFound[foundChamp].append(numRolls)
  89. totalChampsRemaining -= champPool[foundChamp]
  90. del champPool[foundChamp]
  91.  
  92. rollsUntilFound["All"].append(numRolls)
  93.  
  94. print("Finished simulation")
  95. # print(rollsUntilFound)
  96.  
  97. for champ in rollsUntilFound:
  98. avg = 0
  99. for rerolls in rollsUntilFound[champ]:
  100. avg += rerolls
  101. # Could calculate other things like standard deviation, percentile rolls, etc here
  102. avg = float(avg) / float(totalSimulations)
  103. print ("Avg to find " + champ + " = " + str(avg))
  104.  
  105.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement