Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. from random import uniform
  2.  
  3. def simSeason(winppt, winpgp, gps, pts, byes, trials):
  4. level = {0: 0, 1:0, 2:0, 3:0}
  5. for i in range(trials):
  6. level[proPoints(winppt, winpgp, gps, pts, byes, trials)] += 1
  7. print("A player who goes to %d PTs (%f winrate) and %d GPs (%f win rate and %d byes):" % (pts, winppt, gps, winpgp, byes))
  8. print("%f chance of getting plat, %f chance of getting gold, %f chance of getting silver" %
  9. (level[3]/trials, level[2]/trials, level[1]/trials))
  10. print("%f chance of getting at least gold" % ((level[3]+level[2])/trials))
  11.  
  12.  
  13.  
  14.  
  15. def proPoints(winppt, winpgp, gps, pts, byes, trials):
  16. PTPoints = 0
  17. GPPoints = []
  18. for pt in range(pts):
  19. PTPoints += simPT(winppt)
  20. for gp in range(gps):
  21. GPPoints.append(simGP(winpgp, byes))
  22. GPPoints.sort(reverse=True)
  23. total = PTPoints + sum(GPPoints[:5])
  24. if total < 20:
  25. return 0
  26. elif total < 35:
  27. return 1
  28. elif total < 48:
  29. return 2
  30. else:
  31. return 3
  32.  
  33. def playmatch(winp):
  34. result = uniform(0, 1)
  35. return result <= winp
  36.  
  37. def simPT(winp):
  38. matchpoints = 0
  39. propoints = 0
  40. for roundnum in range(16):
  41. if (roundnum < 8) or (roundnum >= 8 and matchpoints >= 12):
  42. if playmatch(winp):
  43. matchpoints += 3
  44. if matchpoints >= 39:
  45. if playmatch(winp):
  46. if playmatch(winp):
  47. if playmatch(winp):
  48. propoints += 30
  49. else:
  50. propoints += 26
  51. else:
  52. propoints += 22
  53. else:
  54. propoints += 18
  55. elif matchpoints == 36:
  56. propoints += 15
  57. elif matchpoints == 33:
  58. propoints += 10
  59. elif matchpoints == 30:
  60. propoints += 6
  61. else:
  62. propoints += 3
  63. return propoints
  64.  
  65. def simGP(winp, byes):
  66. matchpoints = 0
  67. propoints = 0
  68. for roundnum in range(15-byes):
  69. if (roundnum < 9-byes) or (roundnum >= 9-byes and matchpoints >= 21-byes*3):
  70. if playmatch(winp):
  71. matchpoints += 3
  72. if matchpoints >= 39-3*byes:
  73. if playmatch(winp):
  74. if playmatch(winp):
  75. if playmatch(winp):
  76. propoints += 8
  77. else:
  78. propoints += 6
  79. else:
  80. propoints += 5
  81. else:
  82. propoints += 4
  83. elif matchpoints == 36-byes*3:
  84. propoints += 3
  85. elif matchpoints == 33-byes*3:
  86. propoints += 1
  87. return propoints
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement