Started up 2025 with an interactive version

This commit is contained in:
Connor Johnstone
2025-03-19 23:18:36 -04:00
parent 3a03a9a2b9
commit 686706c1df
17 changed files with 2363 additions and 452 deletions

87
old/main.py Normal file
View File

@@ -0,0 +1,87 @@
import csv
from statistics import mean
rankings_file = "rankings.csv"
matchups_file = "matchups.csv"
# Some rounds modified to measure expectations better
r1_seeds = [[1, 28], [8, 9], [5, 12], [4, 16], [6, 11], [3, 18], [7, 10], [2, 24]]
r2_seeds = [[1, 10], [5, 4], [6, 3], [9, 2]]
r3_seeds = [[1, 4], [3, 2]]
r4_seeds = [[1, 4], [3, 2]]
r5_seeds = [[1, 4], [3, 2]]
r6_seeds = [[1, 2]]
systems = ["DOK", "INC", "LMC", "TPR"]
def pick_winners(matchups, seeds, multiplier):
j = 0
winners = []
out_matchups = []
for matchup in matchups:
if matchup != []:
expected_ranks = [multiplier * seed for seed in seeds[j % len(seeds)]]
matchup_rankings = [
rankings[teams.index(matchup[0])],
rankings[teams.index(matchup[1])],
]
for k in range(2):
if matchup_rankings[k] < 0.75 * expected_ranks[k]:
matchup_rankings[k] *= 0.5
elif matchup_rankings[k] < expected_ranks[k]:
matchup_rankings[k] *= 0.9
elif matchup_rankings[k] > 1.5 * expected_ranks[k]:
matchup_rankings[k] *= 2.5
elif matchup_rankings[k] > expected_ranks[k]:
matchup_rankings[k] *= 1.1
if matchup_rankings[0] >= matchup_rankings[1]:
winner = matchup[1]
else:
winner = matchup[0]
winners.append(winner)
j += 1
for i in range(0, len(winners), 2):
out_matchups.append([winners[i], winners[i + 1]])
print(winners)
return winners, out_matchups
def convert_float(string):
return 400 if (string.strip() == "") else float(string)
with open(rankings_file, newline="\n") as rankings_csv:
reader = csv.reader(rankings_csv, delimiter=",", quotechar='"')
teams = []
rankings = []
for team in reader:
if team[0][1:] == 'Team':
sys_indices = []
for system in systems:
sys_indices.append([sys.strip() for sys in team].index(system))
else:
rankings.append(
mean([convert_float(team[sys_index]) for sys_index in sys_indices])
)
teams.append(team[0].strip())
with open(matchups_file, newline="\n") as matchups_csv:
reader = csv.reader(matchups_csv, delimiter=",", quotechar='"')
r2_teams, r2_matchups = pick_winners(reader, r1_seeds, 4)
r3_teams, r3_matchups = pick_winners(r2_matchups, r2_seeds, 4)
r4_teams, r4_matchups = pick_winners(r3_matchups, r3_seeds, 4)
r5_teams, r5_matchups = pick_winners(r4_matchups, r4_seeds, 2)
r6_teams, r6_matchups = pick_winners(r5_matchups, r5_seeds, 1)
final_rankings = [
rankings[teams.index(r6_matchups[0][0])],
rankings[teams.index(r6_matchups[0][1])],
]
winner = (
r6_matchups[0][1]
if (final_rankings[0] >= final_rankings[1])
else r6_matchups[0][0]
)
print(winner)