Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- # Rolls we're tracking
- rollsUntilFound = {
- "Hecarim": [],
- "Sejuani": [],
- "Nautilus": [],
- "Thresh": [],
- "All": []
- }
- # The full simulation
- totalSimulations = 1000
- for i in range(0,totalSimulations):
- # Define the base champ pool
- champPool = {
- "Brand": 22,
- "Hecarim": 22,
- "Kennen": 22,
- "LeBlanc": 22,
- "Nautilus": 22,
- "Sejuani": 22,
- "Sett": 22,
- "Soraka": 22,
- "Syndra": 22,
- "Thresh": 22,
- "Trundle": 22,
- "Varus": 22,
- "Viktor": 22
- }
- # Define current champs purchased
- currentChampsBought = {
- "Hecarim": 0,
- "Sejuani": 0,
- "Nautilus": 0,
- "Thresh": 0
- }
- # Remove champs currently purchased from pool, and remove some number of other champs
- for champ in champPool:
- if (champ in currentChampsBought):
- # Remove the champs I'm currently holding from the total pool
- champPool[champ] -= currentChampsBought[champ]
- else:
- # Remove some number of other champs from the pool
- champPool[champ] -= 0
- # Calculate num champs remaining
- totalChampsRemaining = 0
- for champ in champPool:
- totalChampsRemaining += champPool[champ]
- # Do rolls until all are found
- numRolls = 0
- threeStars = 0
- while (currentChampsBought["Hecarim"] != 9 or
- currentChampsBought["Nautilus"] != 9 or
- currentChampsBought["Sejuani"] != 9 or
- currentChampsBought["Thresh"] != 9):
- numRolls += 1
- # Roll 5 times and then increment
- for i in range(0,5):
- rollChance = random.randint(1,100)
- if (rollChance > 40):
- continue # didn't roll 40% chance
- # Now roll from remaining champs
- champRoll = random.randint(1, totalChampsRemaining)
- # Find which champ was rolled based on "weighted champ pool"
- foundChamp = ""
- for champ in champPool:
- champRoll -= champPool[champ]
- if (champRoll <= 0):
- foundChamp = champ
- break
- if ((foundChamp in currentChampsBought) and (currentChampsBought[foundChamp] < 9)):
- currentChampsBought[foundChamp] += 1
- champPool[foundChamp] -= 1
- totalChampsRemaining -= 1
- if currentChampsBought[foundChamp] == 9:
- rollsUntilFound[foundChamp].append(numRolls)
- totalChampsRemaining -= champPool[foundChamp]
- del champPool[foundChamp]
- rollsUntilFound["All"].append(numRolls)
- print("Finished simulation")
- # print(rollsUntilFound)
- for champ in rollsUntilFound:
- avg = 0
- for rerolls in rollsUntilFound[champ]:
- avg += rerolls
- # Could calculate other things like standard deviation, percentile rolls, etc here
- avg = float(avg) / float(totalSimulations)
- print ("Avg to find " + champ + " = " + str(avg))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement