This repository has been archived by the owner on Sep 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse.py
79 lines (63 loc) · 1.96 KB
/
parse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import athlete
import simulation
def sum(file: str) -> tuple[dict[str, int], dict[str, int]]:
points_sim: dict[str, int] = {}
points_exp: dict[str, int] = {}
with open(file) as f:
lines = f.read().split("\n")[:-1]
for l in lines:
name, sp, rp = l.split(", ")
if name in points_sim:
points_sim[name] += int(sp)
else:
points_sim[name] = int(sp)
if name in points_exp:
points_exp[name] += int(rp)
else:
points_exp[name] = int(rp)
points_real = {
k: v
for k, v in sorted(points_exp.items(), key=lambda item: item[1], reverse=True)
}
athletes = list(points_real.keys())
ranks = {}
for i in range(len(athletes)):
ranks[athletes[i]] = i + 1
points_sorted = {
k: v
for k, v in sorted(points_sim.items(), key=lambda item: item[1], reverse=True)
}
i = 1
sim_ranks = {}
for a in points_sorted:
sim_ranks[a] = i
i += 1
return ranks, sim_ranks
def read(file: str, file_sum: str) -> tuple[dict[str, int], dict[str, int]]:
trash, sim_ranks = sum(file_sum)
complete = {}
with open(file) as f:
lines = f.read().split("\n")[:-1]
for l in lines:
name, rank = l.split(", ")
complete[name] = int(rank)
return complete, sim_ranks
# ranks, ranks_sim = read("data_2.csv", "data.csv")
ranks, ranks_sim = read("stand.csv", "points.csv")
# ranks, ranks_sim = sum("data_S24_25.csv")
# ranks, ranks_sim, points = sum("points.csv")
# for a in ranks_sim:
# print(f"{ranks_sim[a]:02}: {a} ({points[a]})")
s = simulation.SlipstreamSim(0)
for name in ranks_sim:
if name not in ranks:
continue
at = athlete.Athlete(name, 0, {"jump_rank": "0", "rank": str(ranks[name])})
at.rank = ranks_sim[name]
s.done.append(at)
s.ended = True
s.num_athlete = len(s.done)
s.correctness()
s.compare_positions()