Small updates
This commit is contained in:
55
main.py
55
main.py
@@ -5,17 +5,12 @@ rankings_file = '/home/connor/documents/rankings.csv'
|
|||||||
matchups_file = '/home/connor/documents/matchups.csv'
|
matchups_file = '/home/connor/documents/matchups.csv'
|
||||||
# First round modified to measure expectations better
|
# First round modified to measure expectations better
|
||||||
r1_seeds = [[1,28], [8,9], [5, 12], [4,16], [6,11], [3,18], [7,10], [2,24]]
|
r1_seeds = [[1,28], [8,9], [5, 12], [4,16], [6,11], [3,18], [7,10], [2,24]]
|
||||||
r2_seeds = [[1,8], [5,4], [6,3], [7,2]]
|
r2_seeds = [[1,10], [5,4], [6,3], [9,2]]
|
||||||
r3_seeds = [[1,4], [3,2]]
|
r3_seeds = [[1,4], [3,2]]
|
||||||
r4_seeds = [[1,4], [3,2]]
|
r4_seeds = [[1,4], [3,2]]
|
||||||
r5_seeds = [[1,4], [3,2]]
|
r5_seeds = [[1,4], [3,2]]
|
||||||
r6_seeds = [[1,2]]
|
r6_seeds = [[1,2]]
|
||||||
systems = ['LEF', 'DOK', 'INC', 'LMC', 'TPR']
|
systems = ['LEF', 'DOK', 'INC', 'LMC', 'TPR']
|
||||||
r2_matchups = []
|
|
||||||
r3_matchups = []
|
|
||||||
r4_matchups = []
|
|
||||||
r5_matchups = []
|
|
||||||
r6_matchups = []
|
|
||||||
|
|
||||||
def pick_winners(matchups, seeds, multiplier):
|
def pick_winners(matchups, seeds, multiplier):
|
||||||
j = 0
|
j = 0
|
||||||
@@ -26,15 +21,14 @@ def pick_winners(matchups, seeds, multiplier):
|
|||||||
expected_ranks = [ multiplier*seed for seed in seeds[j%len(seeds)] ]
|
expected_ranks = [ multiplier*seed for seed in seeds[j%len(seeds)] ]
|
||||||
matchup_rankings = [rankings[teams.index(matchup[0])], rankings[teams.index(matchup[1])]]
|
matchup_rankings = [rankings[teams.index(matchup[0])], rankings[teams.index(matchup[1])]]
|
||||||
for k in range(2):
|
for k in range(2):
|
||||||
if expected_ranks[k] > 10:
|
if matchup_rankings[k] < 0.75*expected_ranks[k]:
|
||||||
if matchup_rankings[k] < 0.75*expected_ranks[k]:
|
matchup_rankings[k] *= 0.5
|
||||||
matchup_rankings[k] *= 0.6
|
elif matchup_rankings[k] < expected_ranks[k]:
|
||||||
elif matchup_rankings[k] < expected_ranks[k]:
|
matchup_rankings[k] *= 0.9
|
||||||
matchup_rankings[k] *= 0.9
|
elif matchup_rankings[k] > 1.5*expected_ranks[k]:
|
||||||
elif matchup_rankings[k] > 1.5*expected_ranks[k]:
|
matchup_rankings[k] *= 2.5
|
||||||
matchup_rankings[k] *= 2.0
|
elif matchup_rankings[k] > expected_ranks[k]:
|
||||||
elif matchup_rankings[k] > expected_ranks[k]:
|
matchup_rankings[k] *= 1.1
|
||||||
matchup_rankings[k] *= 1.1
|
|
||||||
if matchup_rankings[0] >= matchup_rankings[1]:
|
if matchup_rankings[0] >= matchup_rankings[1]:
|
||||||
winner = matchup[1]
|
winner = matchup[1]
|
||||||
else:
|
else:
|
||||||
@@ -43,30 +37,22 @@ def pick_winners(matchups, seeds, multiplier):
|
|||||||
j += 1
|
j += 1
|
||||||
for i in range(0,len(winners), 2):
|
for i in range(0,len(winners), 2):
|
||||||
out_matchups.append([ winners[i], winners[i+1] ])
|
out_matchups.append([ winners[i], winners[i+1] ])
|
||||||
|
print(winners)
|
||||||
return winners, out_matchups
|
return winners, out_matchups
|
||||||
|
|
||||||
def convert_float(string):
|
def convert_float(string): return 400 if (string.strip() == '') else float(string)
|
||||||
if string.strip() == '':
|
|
||||||
return 400
|
|
||||||
else:
|
|
||||||
return float(string)
|
|
||||||
|
|
||||||
|
|
||||||
with open(rankings_file, newline='\n') as rankings_csv:
|
with open(rankings_file, newline='\n') as rankings_csv:
|
||||||
reader = csv.reader(rankings_csv, delimiter=',', quotechar='"')
|
reader = csv.reader(rankings_csv, delimiter=',', quotechar='"')
|
||||||
i = 1
|
|
||||||
teams = []
|
teams = []
|
||||||
rankings = []
|
rankings = []
|
||||||
for team in reader:
|
for team in reader:
|
||||||
if i == 1:
|
if team[0] == "Team":
|
||||||
sys_entries = [ sys.strip() for sys in team ]
|
|
||||||
sys_indices = []
|
sys_indices = []
|
||||||
for system in systems:
|
for system in systems: sys_indices.append([ sys.strip() for sys in team ].index(system))
|
||||||
sys_indices.append(sys_entries.index(system))
|
else:
|
||||||
if i != 1:
|
|
||||||
rankings.append(mean([ convert_float(team[sys_index]) for sys_index in sys_indices ]))
|
rankings.append(mean([ convert_float(team[sys_index]) for sys_index in sys_indices ]))
|
||||||
teams.append(team[0].strip())
|
teams.append(team[0].strip())
|
||||||
i += 1
|
|
||||||
|
|
||||||
with open(matchups_file, newline='\n') as matchups_csv:
|
with open(matchups_file, newline='\n') as matchups_csv:
|
||||||
reader = csv.reader(matchups_csv, delimiter=',', quotechar='"')
|
reader = csv.reader(matchups_csv, delimiter=',', quotechar='"')
|
||||||
@@ -77,17 +63,8 @@ with open(rankings_file, newline='\n') as rankings_csv:
|
|||||||
r5_teams, r5_matchups = pick_winners(r4_matchups, r4_seeds, 2)
|
r5_teams, r5_matchups = pick_winners(r4_matchups, r4_seeds, 2)
|
||||||
r6_teams, r6_matchups = pick_winners(r5_matchups, r5_seeds, 1)
|
r6_teams, r6_matchups = pick_winners(r5_matchups, r5_seeds, 1)
|
||||||
|
|
||||||
print(r2_teams)
|
final_rankings = [rankings[teams.index(r6_matchups[0][0])], rankings[teams.index(r6_matchups[0][1])]]
|
||||||
print(r3_teams)
|
winner = r6_matchups[0][1] if (final_rankings[0] >= final_rankings[1]) else r6_matchups[0][0]
|
||||||
print(r4_teams)
|
|
||||||
print(r5_teams)
|
|
||||||
print(r6_teams)
|
|
||||||
|
|
||||||
final_matchup_rankings = [rankings[teams.index(r6_matchups[0][0])], rankings[teams.index(r6_matchups[0][1])]]
|
|
||||||
if final_matchup_rankings[0] >= final_matchup_rankings[1]:
|
|
||||||
winner = r6_matchups[0][1]
|
|
||||||
else:
|
|
||||||
winner = r6_matchups[0][0]
|
|
||||||
|
|
||||||
print(winner)
|
print(winner)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user