lugnut92

ECAC Season Simulator

Feb 9th, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 25.97 KB | None | 0 0
  1. import random
  2. import time
  3. import csv
  4.  
  5. start = time.clock()
  6.  
  7. def teamtonumber(teamname):
  8.     if teamname == 'RP':
  9.         number = 0
  10.     elif teamname == 'Un':
  11.         number = 1
  12.     elif teamname == 'Br':
  13.         number = 2
  14.     elif teamname == 'Ya':
  15.         number = 3
  16.     elif teamname == 'Ck':
  17.         number = 4
  18.     elif teamname == 'SL':
  19.         number = 5
  20.     elif teamname == 'Cg':
  21.         number = 6
  22.     elif teamname == 'Cr':
  23.         number = 7
  24.     elif teamname == 'Ha':
  25.         number = 8
  26.     elif teamname == 'Da':
  27.         number = 9
  28.     elif teamname == 'Pr':
  29.         number = 10
  30.     elif teamname == 'Qu':
  31.         number = 11
  32.     elif teamname == 'Rensselaer':
  33.         number = 0
  34.     elif teamname == 'Union':
  35.         number = 1
  36.     elif teamname == 'Brown':
  37.         number = 2
  38.     elif teamname == 'Yale':
  39.         number = 3
  40.     elif teamname == 'Clarkson':
  41.         number = 4
  42.     elif teamname == 'St. Lawrence':
  43.         number = 5
  44.     elif teamname == 'Colgate':
  45.         number = 6
  46.     elif teamname == 'Cornell':
  47.         number = 7
  48.     elif teamname == 'Harvard':
  49.         number = 8
  50.     elif teamname == 'Dartmouth':
  51.         number = 9
  52.     elif teamname == 'Princeton':
  53.         number = 10
  54.     elif teamname == 'Quinnipiac':
  55.         number = 11
  56.     return number
  57.  
  58.  
  59. def game(krach_a, krach_b):
  60.     win_a = krach_a / (krach_a + krach_b)
  61.     sim = random.random()
  62.     reg = random.random()
  63.     if reg <= 0.1345:
  64.         result = 3
  65.     elif sim <= win_a:
  66.         result = 1
  67.     else:
  68.         result = 2
  69.     return result
  70.  
  71. def playoffs(rank_a, rank_b):
  72.     if rank_a < rank_b:
  73.         if rank_a < 4:
  74.             result = 0
  75.         elif rank_a == 4:
  76.             if rank_b == 11:
  77.                 result = 1
  78.             else:
  79.                 result = 0
  80.         elif rank_a == 5:
  81.             if rank_b == 10:
  82.                 result = 1
  83.             else:
  84.                 result = 0
  85.         elif rank_a == 6:
  86.             if rank_b == 9:
  87.                 result = 1
  88.             else:
  89.                 result = 0
  90.         elif rank_a == 7:
  91.             if rank_b == 8:
  92.                 result = 1
  93.             else:
  94.                 result = 0
  95.         else:
  96.             result = 0
  97.     else:
  98.         result = 0
  99.     return result
  100.  
  101. def threewaytie(one,two,three):
  102.     if one > two:
  103.         if one > three:
  104.             if two > three: #case 1
  105.                 result = 1
  106.             elif three > two: #case 2
  107.                 result = 2
  108.             else: #case 10
  109.                 result = 10
  110.         elif one < three: #case 5
  111.             result = 5
  112.         else: #case 8
  113.             result = 8
  114.     elif two > one:
  115.         if two > three:
  116.             if one > three: #case 3
  117.                 result = 3
  118.             elif three > one: #case 4
  119.                 result = 4
  120.             else: #case 11
  121.                 result = 11
  122.         elif two < three: #case 6
  123.             result = 6
  124.         else: #case 9
  125.             result = 9
  126.     elif one == two:
  127.         if one > three: #case 7
  128.             result = 7
  129.         elif three > one: #case 12
  130.             result = 12
  131.         else:
  132.             result = 13
  133.     return result
  134.  
  135. teams = ['RP',
  136.          'Un',
  137.          'Br',
  138.          'Ya',
  139.          'Ck',
  140.          'SL',
  141.          'Cg',
  142.          'Cr',
  143.          'Ha',
  144.          'Da',
  145.          'Pr',
  146.          'Qu']
  147.  
  148. f = open('filename.txt', 'r')
  149. brKRACH = float(f.readline())
  150. ckKRACH = float(f.readline())
  151. cgKRACH = float(f.readline())
  152. crKRACH = float(f.readline())
  153. daKRACH = float(f.readline())
  154. haKRACH = float(f.readline())
  155. prKRACH = float(f.readline())
  156. quKRACH = float(f.readline())
  157. rpKRACH = float(f.readline())
  158. slKRACH = float(f.readline())
  159. unKRACH = float(f.readline())
  160. yaKRACH = float(f.readline())
  161.  
  162. ECAC_KRACH = [rpKRACH,
  163.               unKRACH,
  164.               brKRACH,
  165.               yaKRACH,
  166.               ckKRACH,
  167.               slKRACH,
  168.               cgKRACH,
  169.               crKRACH,
  170.               haKRACH,
  171.               daKRACH,
  172.               prKRACH,
  173.               quKRACH]
  174.  
  175. print(round(ECAC_KRACH[1],2),'\n',
  176.       round(ECAC_KRACH[6],2),'\n',
  177.       round(ECAC_KRACH[11],2),'\n',
  178.       round(ECAC_KRACH[7],2),'\n',
  179.       round(ECAC_KRACH[4],2),'\n',
  180.       round(ECAC_KRACH[3],2),'\n',
  181.       round(ECAC_KRACH[0],2),'\n',
  182.       round(ECAC_KRACH[5],2),'\n',
  183.       round(ECAC_KRACH[2],2),'\n',
  184.       round(ECAC_KRACH[9],2),'\n',
  185.       round(ECAC_KRACH[8],2),'\n',
  186.       round(ECAC_KRACH[10],2),'\n')
  187.  
  188. ranks = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  189.          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  190.          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  191.          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  192.          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  193.          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  194.          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  195.          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  196.          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  197.          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  198.          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  199.          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
  200.  
  201. playoff = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  202.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  203.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  204.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  205.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  206.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  207.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  208.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  209.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  210.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  211.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  212.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
  213.  
  214. points_listi = [[0, 'RP'],
  215.                 [0, 'Un'],
  216.                 [0, 'Br'],
  217.                 [0, 'Ya'],
  218.                 [0, 'Ck'],
  219.                 [0, 'SL'],
  220.                 [0, 'Cg'],
  221.                 [0, 'Cr'],
  222.                 [0, 'Ha'],
  223.                 [0, 'Da'],
  224.                 [0, 'Pr'],
  225.                 [0, 'Qu']]
  226.                
  227.          # RP,Un,Br,Ya,Ck,SL,Cg,Cr,Ha,Da,Pr,Qu
  228. h2hptsi = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #RP
  229.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Un
  230.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Br
  231.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Ya
  232.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Ck
  233.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #SL
  234.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Cg
  235.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Cr
  236.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Ha
  237.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Da
  238.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Pr
  239.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] #Qu
  240.          
  241.         # RP,Un,Br,Ya,Ck,SL,Cg,Cr,Ha,Da,Pr,Qu
  242. gamesi = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #RP
  243.           [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Un
  244.           [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Br
  245.           [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], #Ya
  246.           [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], #Ck
  247.           [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], #SL
  248.           [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], #Cg
  249.           [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], #Cr
  250.           [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], #Ha
  251.           [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], #Da
  252.           [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], #Pr
  253.           [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]] #Qu
  254.          
  255. winsi = [0, #RP
  256.          0, #Un
  257.          0, #Br
  258.          0, #Ya
  259.          0, #Ck
  260.          0, #SL
  261.          0, #Cg
  262.          0, #Cr
  263.          0, #Ha
  264.          0, #Da
  265.          0, #Pr
  266.          0] #Qu
  267.  
  268. points_list = [[0, 'RP'],
  269.                [0, 'Un'],
  270.                [0, 'Br'],
  271.                [0, 'Ya'],
  272.                [0, 'Ck'],
  273.                [0, 'SL'],
  274.                [0, 'Cg'],
  275.                [0, 'Cr'],
  276.                [0, 'Ha'],
  277.                [0, 'Da'],
  278.                [0, 'Pr'],
  279.                [0, 'Qu']]
  280.  
  281. # RP,Un,Br,Ya,Ck,SL,Cg,Cr,Ha,Da,Pr,Qu
  282. h2hpts = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #RP
  283.           [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Un
  284.           [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Br
  285.           [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Ya
  286.           [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Ck
  287.           [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #SL
  288.           [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Cg
  289.           [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Cr
  290.           [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Ha
  291.           [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Da
  292.           [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Pr
  293.           [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] #Qu
  294.  
  295. # RP,Un,Br,Ya,Ck,SL,Cg,Cr,Ha,Da,Pr,Qu
  296. games = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #RP
  297.          [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Un
  298.          [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], #Br
  299.          [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], #Ya
  300.          [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], #Ck
  301.          [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], #SL
  302.          [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], #Cg
  303.          [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], #Cr
  304.          [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], #Ha
  305.          [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], #Da
  306.          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], #Pr
  307.          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]] #Qu
  308.  
  309. wins = [0, #RP
  310.         0, #Un
  311.         0, #Br
  312.         0, #Ya
  313.         0, #Ck
  314.         0, #SL
  315.         0, #Cg
  316.         0, #Cr
  317.         0, #Ha
  318.         0, #Da
  319.         0, #Pr
  320.         0] #Qu
  321.  
  322. points_avg = [0,
  323.               0,
  324.               0,
  325.               0,
  326.               0,
  327.               0,
  328.               0,
  329.               0,
  330.               0,
  331.               0,
  332.               0,
  333.               0]
  334.  
  335. points_array = [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  336.                 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  337.                 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  338.                 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  339.                 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  340.                 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  341.                 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  342.                 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  343.                 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  344.                 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  345.                 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  346.                 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]
  347.                
  348.  
  349. left = 132
  350.  
  351. with open('filename.csv', newline='') as results:
  352.     game_result = csv.reader(results, delimiter=',')
  353.     for row in game_result:
  354.         if row[7] == 'ec':
  355.             left = left - 1
  356.             away = teamtonumber(row[1])
  357.             home = teamtonumber(row[4])
  358.             if row[5] > row[2]:
  359.                 winsi[home] = winsi[home] + 1
  360.                 h2hptsi[home][away] = h2hptsi[home][away] + 2
  361.                 points_listi[home][0] = points_listi[home][0] + 2
  362.                 gamesi[home][away] = gamesi[home][away] + 1
  363.             elif row[2] > row[5]:
  364.                 winsi[away] = winsi[away] + 1
  365.                 h2hptsi[away][home] = h2hptsi[away][home] + 2
  366.                 points_listi[away][0] = points_listi[away][0] + 2
  367.                 gamesi[home][away] = gamesi[home][away] + 1
  368.             elif row[2] == row[5]:
  369.                 if row[6] == 'ot':
  370.                     h2hptsi[home][away] = h2hptsi[home][away] + 1
  371.                     h2hptsi[away][home] = h2hptsi[away][home] + 1
  372.                     points_listi[home][0] = points_listi[home][0] + 1
  373.                     points_listi[away][0] = points_listi[away][0] + 1
  374.                     gamesi[home][away] = gamesi[home][away] + 1
  375.                 else:
  376.                     yep = 0
  377.             else:
  378.                 yep = 0
  379.         else:
  380.             yep = 0
  381.  
  382. print(left, 'games remaining.', '\n')
  383.  
  384. #count = input('How many seasons?')
  385. count = 1000000
  386. just = len(str(count))
  387.  
  388. for iteration in range(count):
  389.     #initialize standings
  390.     for row in range(12):
  391.         points_list[row][0] = points_listi[row][0]
  392.         points_list[row][1] = points_listi[row][1]
  393.         wins[row] = winsi[row]
  394.         for col in range(12):
  395.             h2hpts[row][col] = h2hptsi[row][col]
  396.             games[row][col] = gamesi[row][col]
  397.     #play the games
  398.     for team in range(12):
  399.         for op in range(12):
  400.             if games[team][op] == 0:
  401.                 res = game(ECAC_KRACH[team], ECAC_KRACH[op])
  402.                 if res == 1:
  403.                     points_list[team][0] = points_list[team][0] + 2
  404.                     h2hpts[team][op] = h2hpts[team][op] + 2
  405.                     wins[team] = wins[team] + 1
  406.                 elif res == 2:
  407.                     points_list[op][0] = points_list[op][0] + 2
  408.                     h2hpts[op][team] = h2hpts[op][team] + 2
  409.                     wins[op] + 1
  410.                 else:
  411.                     points_list[team][0] = points_list[team][0] + 1
  412.                     points_list[op][0] = points_list[op][0] + 1
  413.                     h2hpts[team][op] = h2hpts[team][op] + 1
  414.                     h2hpts[op][team] = h2hpts[op][team] + 1
  415.             else:
  416.                 yep = 0
  417.  
  418.     for row in range(12):
  419.         points_avg[row] = points_avg[row] + points_list[row][0]
  420.         points_array[row][points_list[row][0]] += 1
  421.  
  422.     #SORT
  423.     points_list.sort()
  424.     points_list.reverse()
  425.     rank_list = {}
  426.  
  427.     #TIE-BREAKING
  428.     for two in range (2):
  429.         for rank in range(11):
  430.             tied = 0
  431.             if points_list[rank][0] == points_list[rank + 1][0]:
  432.                 tied = 1
  433.                 if rank == 10:
  434.                     yep = 0
  435.                 elif points_list[rank][0] == points_list [rank + 2][0]:
  436.                     tied = 0
  437.                     team_1 = teamtonumber(points_list[rank][1])
  438.                     team_2 = teamtonumber(points_list[rank + 1][1])
  439.                     team_3 = teamtonumber(points_list[rank + 2][1])
  440.                     t1pts = h2hpts[team_1][team_2] + h2hpts[team_1][team_3]
  441.                     t2pts = h2hpts[team_2][team_1] + h2hpts[team_2][team_3]
  442.                     t3pts = h2hpts[team_3][team_1] + h2hpts[team_3][team_2]
  443.                     tie = threewaytie(t1pts,t2pts,t3pts)
  444.                     if tie == 13:
  445.                         tie = threewaytie(wins[team_1],wins[team_2],wins[team_3])
  446.                     else:
  447.                         yep = 0
  448.  
  449.                     if tie == 1:
  450.                         points_list[rank][0] = points_list[rank][0] + 0.2
  451.                         points_list[rank + 1][0] = points_list[rank + 1][0] + 0.1
  452.                     elif tie == 2:
  453.                         points_list[rank][0] = points_list[rank][0] + 0.2
  454.                         points_list[rank + 2][0] = points_list[rank + 2][0] + 0.1
  455.                     elif tie == 3:
  456.                         points_list[rank + 1][0] = points_list[rank + 1][0] + 0.2
  457.                         points_list[rank][0] = points_list[rank][0] + 0.1
  458.                     elif tie == 4:
  459.                         points_list[rank + 1][0] = points_list[rank + 1][0] + 0.2
  460.                         points_list[rank + 2][0] = points_list[rank + 2][0] + 0.1
  461.                     elif tie == 5:
  462.                         points_list[rank + 2][0] = points_list[rank + 2][0] + 0.2
  463.                         points_list[rank][0] = points_list[rank][0] + 0.1
  464.                     elif tie == 6:
  465.                         points_list[rank + 2][0] = points_list[rank + 2][0] + 0.2
  466.                         points_list[rank + 1][0] = points_list[rank + 1][0] + 0.1
  467.                     elif tie == 7:
  468.                         points_list[rank][0] = points_list[rank][0] - 0.1
  469.                     elif tie == 8:
  470.                         points_list[rank + 1][0] = points_list[rank + 1][0] - 0.1
  471.                     elif tie == 9:
  472.                         points_list[rank + 2][0] = points_list[rank + 2][0] - 0.1
  473.                     elif tie == 10:
  474.                         points_list[rank][0] = points_list[rank][0] + 0.2
  475.                     elif tie == 11:
  476.                         points_list[rank + 1][0] = points_list[rank + 1][0] + 0.2
  477.                     elif tie == 12:
  478.                         points_list[rank + 2][0] = points_list[rank + 2][0] + 0.2
  479.                     else:
  480.                         points_list[rank][0] = points_list[rank][0] + 0.1*random.random()
  481.                         points_list[rank + 1][0] = points_list[rank + 1][0] + 0.1*random.random()
  482.                         points_list[rank + 2][0] = points_list[rank + 2][0] + 0.1*random.random()
  483.                     points_list.sort()
  484.                     points_list.reverse()
  485.                 else:
  486.                     yep = 0
  487.                
  488.                 if tied == 1:
  489.                     tied = 0
  490.                     team_1 = teamtonumber(points_list[rank][1])
  491.                     team_2 = teamtonumber(points_list[rank + 1][1])
  492.                     if h2hpts[team_1][team_2] > h2hpts[team_2][team_1]:
  493.                         points_list[rank][0] = points_list[rank][0] + 0.1
  494.                     elif h2hpts[team_1][team_2] < h2hpts[team_2][team_1]:
  495.                         points_list[rank + 1][0] = points_list[rank + 1][0] + 0.1
  496.                     else:
  497.                         if wins[team_1] > wins[team_2]:
  498.                             points_list[rank][0] = points_list[rank][0] + 0.1
  499.                         elif wins[team_1] < wins[team_2]:
  500.                             points_list[rank + 1][0] = points_list[rank + 1][0] + 0.1
  501.                         else:
  502.                             points_list[rank][0] = points_list[rank][0] + 0.01*random.random()
  503.                             points_list[rank + 1][0] = points_list[rank + 1][0] + 0.01*random.random()
  504.                
  505.                     points_list.sort()
  506.                     points_list.reverse()
  507.                 else:
  508.                     yep = 0
  509.  
  510.     for i in range(12):
  511.         rank_list[points_list[i][1]] = i
  512.  
  513.     teamnumber = 0
  514.     for team in teams:
  515.         oppnumber = 0
  516.         for opp in teams:
  517.             po = playoffs(rank_list[team],rank_list[opp])
  518.             if po == 1:
  519.                 playoff[teamnumber][oppnumber] = playoff[teamnumber][oppnumber] + po
  520.             else:
  521.                 boop = 0
  522.             oppnumber = oppnumber + 1
  523.         teamnumber = teamnumber + 1
  524.  
  525.     rp_rank = rank_list['RP']
  526.     ranks[0][rp_rank] = ranks[0][rp_rank] + 1
  527.  
  528.     un_rank = rank_list['Un']
  529.     ranks[1][un_rank] = ranks[1][un_rank] + 1
  530.  
  531.     br_rank = rank_list['Br']
  532.     ranks[2][br_rank] = ranks[2][br_rank] + 1
  533.  
  534.     ya_rank = rank_list['Ya']
  535.     ranks[3][ya_rank] = ranks[3][ya_rank] + 1
  536.  
  537.     ck_rank = rank_list['Ck']
  538.     ranks[4][ck_rank] = ranks[4][ck_rank] + 1
  539.  
  540.     sl_rank = rank_list['SL']
  541.     ranks[5][sl_rank] = ranks[5][sl_rank] + 1
  542.  
  543.     cg_rank = rank_list['Cg']
  544.     ranks[6][cg_rank] = ranks[6][cg_rank] + 1
  545.  
  546.     cr_rank = rank_list['Cr']
  547.     ranks[7][cr_rank] = ranks[7][cr_rank] + 1
  548.  
  549.     ha_rank = rank_list['Ha']
  550.     ranks[8][ha_rank] = ranks[8][ha_rank] + 1
  551.  
  552.     da_rank = rank_list['Da']
  553.     ranks[9][da_rank] = ranks[9][da_rank] + 1
  554.  
  555.     pr_rank = rank_list['Pr']
  556.     ranks[10][pr_rank] = ranks[10][pr_rank] + 1
  557.  
  558.     qu_rank = rank_list['Qu']
  559.     ranks[11][qu_rank] = ranks[11][qu_rank] + 1
  560.  
  561.     if iteration%1000 == 0:
  562.         print(iteration)
  563.  
  564. rankpct = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  565.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  566.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  567.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  568.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  569.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  570.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  571.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  572.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  573.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  574.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  575.            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
  576.  
  577. avgrank = [0,
  578.            0,
  579.            0,
  580.            0,
  581.            0,
  582.            0,
  583.            0,
  584.            0,
  585.            0,
  586.            0,
  587.            0,
  588.            0]
  589.  
  590. bye = [0,
  591.        0,
  592.        0,
  593.        0,
  594.        0,
  595.        0,
  596.        0,
  597.        0,
  598.        0,
  599.        0,
  600.        0,
  601.        0]
  602.  
  603. for row in range(12):
  604.     for col in range(12):
  605.         if ranks[row][col] != 0:
  606.             rankpct[row][col] = round((ranks[row][col] * 100)/count,1)
  607.         else:
  608.             rankpct[row][col] = 0
  609.         avgrank[row] = avgrank[row] + (ranks[row][col]*col)
  610.         if playoff[row][col] != 0:
  611.             playoff[row][col] = round((playoff[row][col] * 100)/count,1)
  612.         else:
  613.             playoff[row][col] = 0
  614.     avgrank[row] = round(avgrank[row]/count + 1,2)
  615.     points_avg[row] = round(points_avg[row]/count, 2)
  616.  
  617. for row in range(12):
  618.     for col in range(4):
  619.         bye[row] = bye[row] + rankpct[row][col]
  620.     for col in range(45):
  621.         if points_array[row][col] != 0:
  622.             points_array[row][col] = round((points_array[row][col] * 100)/count,1)
  623.         else:
  624.             points_array[row][col] = 0
  625.     bye[row] = round(bye[row],1)
  626.  
  627. end = time.clock()
  628. print(end-start, 's')
  629.  
  630. print('Ranks')
  631. for row in range(12):
  632.     print(teams[row],
  633.           '|',
  634.           str(round(ECAC_KRACH[row],1)).rjust(6),
  635.           '|',
  636.           str(ranks[row][0]).rjust(just),
  637.           str(ranks[row][1]).rjust(just),
  638.           str(ranks[row][2]).rjust(just),
  639.           str(ranks[row][3]).rjust(just),
  640.           str(ranks[row][4]).rjust(just),
  641.           str(ranks[row][5]).rjust(just),
  642.           str(ranks[row][6]).rjust(just),
  643.           str(ranks[row][7]).rjust(just),
  644.           str(ranks[row][8]).rjust(just),
  645.           str(ranks[row][9]).rjust(just),
  646.           str(ranks[row][10]).rjust(just),
  647.           str(ranks[row][11]).rjust(just))
  648.  
  649. print()
  650.  
  651. print('Rank Percentages')
  652. for row in range(12):
  653.     print(teams[row],
  654.           '|',
  655.           str(round(ECAC_KRACH[row],1)).rjust(6),
  656.           '|',
  657.           str(rankpct[row][0]).rjust(5),
  658.           str(rankpct[row][1]).rjust(5),
  659.           str(rankpct[row][2]).rjust(5),
  660.           str(rankpct[row][3]).rjust(5),
  661.           str(rankpct[row][4]).rjust(5),
  662.           str(rankpct[row][5]).rjust(5),
  663.           str(rankpct[row][6]).rjust(5),
  664.           str(rankpct[row][7]).rjust(5),
  665.           str(rankpct[row][8]).rjust(5),
  666.           str(rankpct[row][9]).rjust(5),
  667.           str(rankpct[row][10]).rjust(5),
  668.           str(rankpct[row][11]).rjust(5),
  669.           '|',
  670.           str(avgrank[row]).rjust(5),
  671.           '|',
  672.           str(points_avg[row]).rjust(5))
  673.  
  674. print()
  675.  
  676. just -= 1
  677.  
  678. print('Points')
  679. for row in range(12):
  680.     print(teams[row],
  681.           '|',
  682.           str(round(ECAC_KRACH[row],1)).rjust(6),
  683.           '|',
  684. #          str(points_array[row][0]).rjust(5),
  685. #          str(points_array[row][1]).rjust(5),
  686. #          str(points_array[row][2]).rjust(5),
  687.           str(points_array[row][3]).rjust(5),
  688.           str(points_array[row][4]).rjust(5),
  689.           str(points_array[row][5]).rjust(5),
  690.           str(points_array[row][6]).rjust(5),
  691.           str(points_array[row][7]).rjust(5),
  692.           str(points_array[row][8]).rjust(5),
  693.           str(points_array[row][9]).rjust(5),
  694.           str(points_array[row][10]).rjust(5),
  695.           str(points_array[row][11]).rjust(5),
  696.           str(points_array[row][12]).rjust(5),
  697.           str(points_array[row][13]).rjust(5),
  698.           str(points_array[row][14]).rjust(5),
  699.           str(points_array[row][15]).rjust(5),
  700.           str(points_array[row][16]).rjust(5),
  701.           str(points_array[row][17]).rjust(5),
  702.           str(points_array[row][18]).rjust(5),
  703.           str(points_array[row][19]).rjust(5),
  704.           str(points_array[row][20]).rjust(5),
  705.           str(points_array[row][21]).rjust(5),
  706.           str(points_array[row][22]).rjust(5),
  707.           str(points_array[row][23]).rjust(5),
  708.           str(points_array[row][24]).rjust(5),
  709.           str(points_array[row][25]).rjust(5),
  710.           str(points_array[row][26]).rjust(5),
  711.           str(points_array[row][27]).rjust(5),
  712.           str(points_array[row][28]).rjust(5),
  713.           str(points_array[row][29]).rjust(5),
  714.           str(points_array[row][30]).rjust(5),
  715.           str(points_array[row][31]).rjust(5),
  716.           str(points_array[row][32]).rjust(5),
  717.           str(points_array[row][33]).rjust(5),
  718.           str(points_array[row][34]).rjust(5),
  719.           str(points_array[row][35]).rjust(5),
  720.           str(points_array[row][36]).rjust(5),
  721.           str(points_array[row][37]).rjust(5),
  722.           str(points_array[row][38]).rjust(5),
  723.           str(points_array[row][39]).rjust(5),
  724. #          str(points_array[row][40]).rjust(5),
  725. #          str(points_array[row][41]).rjust(5),
  726. #          str(points_array[row][42]).rjust(5),
  727. #          str(points_array[row][43]).rjust(5),
  728. #          str(points_array[row][44]).rjust(5),
  729.           '|',
  730.           str(points_avg[row]).rjust(5))
  731.  
  732. print()
  733.  
  734. print('Playoffs')
  735. print('   |    RP    Un    Br    Ya    Ck    SL    Cg    Cr    Ha    Da    Pr    Qu |   BYE')
  736. for row in range(12):
  737.     print(teams[row],
  738.           '|',
  739.           str(playoff[row][0]).rjust(5),
  740.           str(playoff[row][1]).rjust(5),
  741.           str(playoff[row][2]).rjust(5),
  742.           str(playoff[row][3]).rjust(5),
  743.           str(playoff[row][4]).rjust(5),
  744.           str(playoff[row][5]).rjust(5),
  745.           str(playoff[row][6]).rjust(5),
  746.           str(playoff[row][7]).rjust(5),
  747.           str(playoff[row][8]).rjust(5),
  748.           str(playoff[row][9]).rjust(5),
  749.           str(playoff[row][10]).rjust(5),
  750.           str(playoff[row][11]).rjust(5),
  751.           '|',
  752.           str(bye[row]).rjust(5))
Advertisement
Add Comment
Please, Sign In to add comment