Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def meanOverRange(numTrials, inputRange, step = 1):
- for i in arange(0, inputRange, step):
- print("{:.0f}".format(i*100) + "%: " +
- "{:.0f}".format(meanTrial(numTrials, i)) + " gems, " +
- "{:.2f}".format(meanTrial2(numTrials, i)) + " packs")
- def meanTrial(numTrials, inputVal):
- total = 0
- for _ in range(numTrials):
- total = total + MTGAReward(inputVal)
- return total/numTrials
- def meanTrial2(numTrials, inputVal):
- total = 0
- for _ in range(numTrials):
- total = total + MTGARewardPacks(inputVal)
- return total/numTrials
- def MTGAReward(winPercent):
- # Best of 3, 3 matches
- wins = 0
- matchWin = winPercent*winPercent + 2 * winPercent*winPercent * (1-winPercent)
- for _ in range(3):
- if(random.random() < matchWin):
- wins = wins + 1
- if(wins == 3):
- return 3000
- elif(wins == 2):
- return 1000
- else:
- return 0
- ## # Best of 1, go until 7 wins or 3 losses
- ##
- ## wins = 0
- ## losses = 0
- ##
- ## while(wins < 7 and losses < 3):
- ## if(random.random() < winPercent):
- ## wins = wins + 1
- ## else:
- ## losses = losses + 1
- ##
- ## if(wins == 7):
- ## return 2200
- ## elif(wins == 6):
- ## return 1800
- ## elif(wins == 5):
- ## return 1600
- ## elif(wins == 4):
- ## return 1400
- ## elif(wins == 3):
- ## return 1000
- ## elif(wins == 2):
- ## return 250
- ## elif(wins == 1):
- ## return 50
- ## else:
- ## return 0
- def MTGARewardPacks(winPercent):
- # Best of 3, 3 matches
- wins = 0
- matchWin = winPercent*winPercent + 2 * winPercent*winPercent * (1-winPercent)
- for _ in range(3):
- if(random.random() < matchWin):
- wins = wins + 1
- if(wins == 3):
- return 6
- elif(wins == 2):
- return 4
- else:
- return 1
- ## # Best of 1, go until 7 wins or 3 losses
- ##
- ## wins = 0
- ## losses = 0
- ##
- ## while(wins < 7 and losses < 3):
- ## if(random.random() < winPercent):
- ## wins = wins + 1
- ## else:
- ## losses = losses + 1
- ##
- ## if(wins == 7):
- ## return 6
- ## elif(wins == 6):
- ## return 5
- ## elif(wins == 5):
- ## return 4
- ## elif(wins == 4):
- ## return 3
- ## elif(wins == 3):
- ## return 2
- ## elif(wins == 2):
- ## return 2
- ## elif(wins == 1):
- ## return 1
- ## else:
- ## return 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement