Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import uniform
- def simSeason(winppt, winpgp, gps, pts, byes, trials):
- level = {0: 0, 1:0, 2:0, 3:0}
- for i in range(trials):
- level[proPoints(winppt, winpgp, gps, pts, byes, trials)] += 1
- print("A player who goes to %d PTs (%f winrate) and %d GPs (%f win rate and %d byes):" % (pts, winppt, gps, winpgp, byes))
- print("%f chance of getting plat, %f chance of getting gold, %f chance of getting silver" %
- (level[3]/trials, level[2]/trials, level[1]/trials))
- print("%f chance of getting at least gold" % ((level[3]+level[2])/trials))
- def proPoints(winppt, winpgp, gps, pts, byes, trials):
- PTPoints = 0
- GPPoints = []
- for pt in range(pts):
- PTPoints += simPT(winppt)
- for gp in range(gps):
- GPPoints.append(simGP(winpgp, byes))
- GPPoints.sort(reverse=True)
- total = PTPoints + sum(GPPoints[:5])
- if total < 20:
- return 0
- elif total < 35:
- return 1
- elif total < 48:
- return 2
- else:
- return 3
- def playmatch(winp):
- result = uniform(0, 1)
- return result <= winp
- def simPT(winp):
- matchpoints = 0
- propoints = 0
- for roundnum in range(16):
- if (roundnum < 8) or (roundnum >= 8 and matchpoints >= 12):
- if playmatch(winp):
- matchpoints += 3
- if matchpoints >= 39:
- if playmatch(winp):
- if playmatch(winp):
- if playmatch(winp):
- propoints += 30
- else:
- propoints += 26
- else:
- propoints += 22
- else:
- propoints += 18
- elif matchpoints == 36:
- propoints += 15
- elif matchpoints == 33:
- propoints += 10
- elif matchpoints == 30:
- propoints += 6
- else:
- propoints += 3
- return propoints
- def simGP(winp, byes):
- matchpoints = 0
- propoints = 0
- for roundnum in range(15-byes):
- if (roundnum < 9-byes) or (roundnum >= 9-byes and matchpoints >= 21-byes*3):
- if playmatch(winp):
- matchpoints += 3
- if matchpoints >= 39-3*byes:
- if playmatch(winp):
- if playmatch(winp):
- if playmatch(winp):
- propoints += 8
- else:
- propoints += 6
- else:
- propoints += 5
- else:
- propoints += 4
- elif matchpoints == 36-byes*3:
- propoints += 3
- elif matchpoints == 33-byes*3:
- propoints += 1
- return propoints
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement