SHARE
TWEET

Untitled

a guest Nov 27th, 2018 149 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """
  2. Copyright 2018 ContentsMayBeHot
  3.  
  4. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  5.  
  6. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  7.  
  8. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  9. """
  10.  
  11. import random
  12.  
  13. tiers = ["bronze", "silver", "gold", "diamond"]
  14. pts_win = [20, 20, 20, 15]
  15. pts_loss = [10, 10, 10, 15]
  16. soft_floor_losses = 3
  17. soft_floor_derank_percent = 0.5
  18. trials = 10000
  19.  
  20. win_percent = 0.55
  21. start_tier = "bronze"
  22. start_subtier = 3
  23. start_pts = 0
  24.  
  25. def sim_season():
  26.   cur_tier = start_tier
  27.   cur_subtier = start_subtier
  28.   cur_pts = start_pts
  29.   games = 0
  30.   grace_losses = soft_floor_losses
  31.   deranks = 0
  32.  
  33.   while True:
  34.     games += 1
  35.     did_win = random.random() < win_percent
  36.     tier_idx = tiers.index(cur_tier)
  37.     #print '%s at %s %d @ %d pts' % ('win' if did_win else 'loss',
  38.     #                                cur_tier, cur_subtier, cur_pts)
  39.     if did_win:
  40.       # Reset derank counter
  41.       grace_losses = soft_floor_losses
  42.       # Add points and see if we rank up
  43.       cur_pts += pts_win[tier_idx]
  44.       if (cur_pts >= 100):
  45.         # rank up
  46.         cur_pts = 0
  47.         cur_subtier -= 1
  48.         # maybe go up a tier
  49.         if cur_subtier == 0:
  50.           if cur_tier == "diamond":
  51.             break
  52.           else:
  53.             cur_tier = tiers[tier_idx+1]
  54.             cur_subtier = 3
  55.     else:
  56.       if cur_pts != 0 or cur_subtier == 3:
  57.         cur_pts -= pts_loss[tier_idx]
  58.         if (cur_pts < 0):
  59.           cur_pts = 0
  60.       else:
  61.         # maybe de-rank
  62.         grace_losses -= 1
  63.         if grace_losses <= 0:
  64.           derank = random.random() < soft_floor_derank_percent
  65.           if derank:
  66.             deranks += 1
  67.             cur_subtier += 1
  68.             cur_pts = 100 - pts_loss[tier_idx]
  69.  
  70.  
  71.   return (games, deranks)
  72.  
  73. for percent in range(48, 66, 1):
  74.   games = 0.0
  75.   deranks = 0.0
  76.   win_percent = percent / 100.0
  77.   for i in range(0, trials):
  78.     (g, d) = sim_season()
  79.     games += g
  80.     deranks += d
  81.  
  82.   print '%2.2f%% games: %1.2f deranks: %1.2f' % (percent, games/trials, deranks/trials)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top