Last active
April 5, 2021 17:10
-
-
Save Noxville/1abad4739bab7c3ad69fc0459270f0a4 to your computer and use it in GitHub Desktop.
Simulation of the DPC 2020-2021
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def g(a, b): | |
_ = [a, b] | |
random.shuffle(_) | |
return _ | |
def apply_major(points, regions): | |
playoffs, groups, wc = [], [], [] | |
for region in regions: | |
playoffs.append(region[0]) | |
groups.append(region[1]) | |
if len(region) > 2: | |
wc.extend(region[2:]) | |
random.shuffle(wc) | |
groups.extend(wc[:2]) | |
random.shuffle(groups) | |
random.shuffle(playoffs) | |
upper, lower = playoffs + groups[:2], groups[2:6] | |
ub_1_1 = g(upper[0], upper[7]) | |
ub_1_2 = g(upper[3], upper[4]) | |
ub_1_3 = g(upper[1], upper[6]) | |
ub_1_4 = g(upper[2], upper[5]) | |
ub_2_1 = g(ub_1_1[0], ub_1_2[0]) | |
ub_2_2 = g(ub_1_3[0], ub_1_4[0]) | |
ub_fin = g(ub_2_1[0], ub_2_2[0]) | |
lb_1_1 = g(lower[0], ub_1_4[1]) | |
lb_1_2 = g(lower[1], ub_1_3[1]) | |
lb_1_3 = g(lower[2], ub_1_2[1]) | |
lb_1_4 = g(lower[3], ub_1_1[1]) | |
lb_2_1 = g(lb_1_1[0], lb_1_2[0]) | |
lb_2_2 = g(lb_1_3[0], lb_1_4[0]) | |
lb_3_1 = g(lb_2_1[0], ub_2_2[1]) | |
lb_3_2 = g(lb_2_2[0], ub_2_1[1]) | |
lb_4_1 = g(lb_3_1[0], lb_3_2[0]) | |
lb_fin = g(lb_4_1[0], ub_fin[1]) | |
gf = g(ub_fin[0], lb_fin[0]) | |
places = [gf[0], gf[1], lb_fin[1], lb_4_1[1], lb_3_1[1], lb_3_2[1], lb_2_1[1], lb_2_2[1]] | |
for idx, t in enumerate(places): | |
points[t] = points[t] + [500, 450, 400, 350, 300, 300, 200, 200][idx] | |
return points | |
def apply_league(pts, num_qual, teams): | |
random.shuffle(teams) | |
for idx, t in enumerate(teams): | |
pts[t] = pts[t] + [500, 300, 200, 100, 50, 0, 0, 0][idx] | |
return teams[:num_qual] | |
def sim(): | |
points = { | |
'IG': 1000, | |
'EG': 950, | |
'Secret': 850, | |
'VP': 700, | |
'Neon': 600, | |
'Thunder Predator': 600, | |
'beastcoast': 500, | |
'LGD': 500, | |
'Fnatic': 425, | |
'Vici': 400, | |
'Alliance': 300, | |
'Quincy Crew': 300, | |
'Aster': 300, | |
'NaVi': 255, | |
'Nigma': 200, | |
'Undying': 200, | |
'Gambit': 170, | |
'SG': 170, | |
'T1': 170, | |
'4Z': 100, | |
'Liquid': 100, | |
'NoPing': 85, | |
'Spirit': 85, | |
'TNC': 72.25, | |
'Elephant': 50, | |
'EXTREMUM': 50, | |
'OG': 42.5, | |
'BOOM': 42.5, | |
'SADBOYS': 30.70625, | |
'Unknown': 30.70625, | |
'Tundra': 0, | |
'Hellbears': 0, | |
'Brame': 0, | |
'EHOME': 0, | |
'SAG': 0, | |
'RNG': 0, | |
'Execration': 0, | |
'Lilgun': 0, | |
'Omega Esports': 0, | |
'Unique': 0, | |
'PuckChamp': 0, | |
'Winstrike': 0, | |
'BNY': 0, | |
'TooBase': 0, | |
'The Cut': 0, | |
'Infamous': 0, | |
'Infinity': 0, | |
'Hokori': 0 | |
} | |
return apply_major(points, [ | |
apply_league(points, 4, ['IG', 'LGD', 'Vici', 'Aster', 'Elephant', 'EHOME', 'SAG', 'RNG']), # China | |
apply_league(points, 4, ['Secret', 'Alliance', 'Nigma', 'Liquid', 'OG', 'Tundra', 'Hellbears', 'Brame']), # EU | |
apply_league(points, 3, ['VP', 'NaVi', 'Gambit', 'Spirit', 'EXTREMUM', 'Unique', 'PuckChamp', 'Winstrike']), # CIS | |
apply_league(points, 3, ['Neon', 'Fnatic', 'T1', 'TNC', 'BOOM', 'Execration', 'Lilgun', 'Omega Esports']), # SEA | |
apply_league(points, 2, ['Thunder Predator', 'beastcoast', 'SG', 'NoPing', 'Unknown', 'Infamous', 'Infinity', 'Hokori']), # SA | |
apply_league(points, 2, ['EG', 'Quincy Crew', 'Undying', '4Z', 'SADBOYS', 'BNY', 'TooBase', 'The Cut']), # NA | |
]) | |
N = 10**7 | |
tb = 0. | |
mean = 0 | |
qualified = {} | |
thresfreq = {} | |
for i in range(N): | |
p = sim() | |
std_points = sorted(p.items(), key=lambda x: -x[1]) | |
threshold = std_points[11][1] | |
qualified_teams = [t[0] for t in std_points if t[1] >= threshold] | |
for t in qualified_teams: | |
qualified[t] = 1 + qualified.get(t, 0) | |
thresfreq[threshold] = 1 + thresfreq.get(threshold, 0) | |
if len(qualified_teams) != 12: | |
tb += 1 | |
print("team,qualified") | |
for t, count in sorted(qualified.items(), key=lambda x: -x[1]): | |
print("{},{}".format(t, count)) | |
print() | |
print("threshold,count") | |
for thres, count in sorted(thresfreq.items(), key=lambda x: x[0]): | |
print("{},{}".format(thres, count)) | |
print() | |
print("tiebreakers: {}".format(tb)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment