-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_stats_graphs.py
173 lines (146 loc) · 6.37 KB
/
create_stats_graphs.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import json
import sys
import matplotlib.pyplot as plt
import numpy as np
scores = {"Armata": 18272735, "CierneZeny": 14531703, "Elerpe": 49653498, "My": 73409290, "RuzovyTank": 72147765,
"TankiOffline": 10413988, "atsooi": 24090822, "budapest": 58303514, "dvaja_strateny": 6228749,
"gersiagi": 38600860, "janci": 18638474, "kockumamdoma": 10657633, "kocurika": 39631106,
"kokorokjo": 45972195, "krtko": 54489531, "misqo": 6522622, "okno": 26379425, "pecenezemiaky": 7505508,
"poharvdzbane": 36697889, "robotrt": 37642763, "severnakambodza": 4241078, "stefan.exe": 49302704,
"tanky.io": 32964212, "tiger": 17068077, "zrovnamebudapest": 61788775}
colors = ['b', 'g', 'r', 'c', 'm', 'y', 'k', '#000000', '#f7db8d', '#f78de7', '#4a013f', '#a0ff8f', '#71b9f0',
'#f07171', '#ff8945', '#bdbdbd', '#ff0000', '#f6ff00', '#2e1100', '#00002e', '#578f77', '#1f4233']
tanks = {12: "AsymetricTripleTank", 4: "DoubleDoubleTank", 2: "EverywhereTank", 7: "GuidedBulletTank",
11: "InvisibleBulletTank", 8: "MachineGunTank", 10: "PeacefulTank", 3: "VariableDoubleTank",
6: "WideBulletTank", 1: "TwinTank", 5: "SniperTank", 9: "AsymetricTank", 0: "BasicTank"}
stats = json.load(open(sys.argv[1], "r"))
players = list(stats.keys())
# Time by tank
time_by_tank = {}
for i in [0, 1, 5, 9, 2, 3, 4, 6, 7, 8, 10, 11, 12]:
time_by_tank[tanks[i]] = [stats[player]["time_by_tank"][str(i)] for player in players]
# print(time_by_tank)
left = np.zeros(len(players))
fig, ax = plt.subplots()
for boolean, weight_count in time_by_tank.items():
p = ax.barh(players, weight_count, 0.75, label=boolean, left=left)
left += weight_count
box = ax.get_position()
ax.set_position([box.x0, box.y0 + box.height * 0.05,
box.width, box.height * 1.0])
ax.set_title("Time by tank")
ax.legend(loc="lower center", bbox_to_anchor=(0.5, -0.15), ncol=7, )
# plt.show()
# pie chart
cols = 4
fig, ax = plt.subplots(nrows=3, ncols=cols)
skipped = 0
for i, player in enumerate(players):
sizes = [stats[player]["time_in_cooldown"], stats[player]["time_not_in_cooldown"]]
labels = ["In cooldown", "Not in cooldown"]
to_remove = []
for j in range(len(sizes)):
if sizes[j] == 0:
to_remove.append(j)
for j in reversed(to_remove):
sizes.pop(j)
labels.pop(j)
if len(sizes) <= 1:
skipped += 1
continue
ax[(i - skipped) // cols][(i - skipped) % cols].set_title(player)
ax[(i - skipped) // cols][(i - skipped) % cols].pie(sizes, labels=labels, autopct='%1.2f%%', startangle=45)
fig.suptitle("Time in reload")
fig.tight_layout()
# plt.show()
categories = ["range", "speed", "bullet_speed", "bullet_ttl", "bullet_damage", "health_max", "health_regeneration",
"body_damage", "reload_speed"]
categories = [*categories, categories[0]]
label_loc = np.linspace(start=0, stop=2 * np.pi, num=len(categories))
plt.figure(figsize=(8, 8))
ax = plt.subplot(polar=True)
for i, player in enumerate(players):
vals = list(stats[player]["stats"].values())
vals = vals + [vals[0]]
vals = np.sqrt(vals)
plt.plot(label_loc, vals, label=player)
ax.set_ylim(0, 1250)
plt.title('√(stat)', size=20)
lines, labels = plt.thetagrids(np.degrees(label_loc), labels=categories)
plt.legend(loc="center left", bbox_to_anchor=(-0.5, 0.5), ncol=1, )
# plt.show()
plt.figure(figsize=(8, 8))
ax = plt.subplot(polar=True)
current_players = sorted(players, key=lambda x: scores[x])[:5]
for i, player in enumerate(current_players):
vals = list(stats[player]["stats"].values())
vals = vals + [vals[0]]
vals = np.sqrt(vals)
plt.plot(label_loc, vals, label=player)
ax.set_ylim(0, 1250)
plt.title('√(stat) posledných 5', size=20)
lines, labels = plt.thetagrids(np.degrees(label_loc), labels=categories)
plt.legend(loc="center left", bbox_to_anchor=(-0.5, 0.5), ncol=1, )
# plt.show()
plt.figure(figsize=(8, 8))
ax = plt.subplot(polar=True)
current_players = sorted(players, key=lambda x: scores[x])[-5:]
for i, player in enumerate(current_players):
vals = list(stats[player]["stats"].values())
vals = vals + [vals[0]]
vals = np.sqrt(vals)
plt.plot(label_loc, vals, label=player)
ax.set_ylim(0, 1250)
plt.title('√(stat) prvých 5', size=20)
lines, labels = plt.thetagrids(np.degrees(label_loc), labels=categories)
plt.legend(loc="center left", bbox_to_anchor=(-0.5, 0.5), ncol=1, )
# plt.show()
# score by reason
score_by_reason = {"0": "BodyDamagePlayer", "1": "BulletDamagePlayer", "2": "BodyDamageEntity",
"3": "BulletDamageEntity", "4": "KillPlayer", "5": "KillEntity"}
cols = 5
fig, ax = plt.subplots(nrows=5, ncols=cols)
patches = []
for i, player in enumerate(players):
sizes = []
labels = []
for label, val in stats[player]["score_by_reason"].items():
sizes.append(val)
labels.append(score_by_reason[label])
to_remove = []
for j in range(len(sizes)):
if sizes[j] == 0:
to_remove.append(j)
for j in reversed(to_remove):
sizes.pop(j)
labels.pop(j)
if len(sizes) <= 1:
skipped += 1
continue
ax[(i - skipped) // cols][(i - skipped) % cols].set_title(player)
patches, texts, autotexts = ax[(i - skipped) // cols][(i - skipped) % cols].pie(sizes,
autopct=lambda pct: (
'%1.2f%%' % pct) if pct > 0 else '',
startangle=45,
pctdistance=1.25, )
fig.legend(patches, labels, ncol=6, loc="lower center")
fig.suptitle("Score by reason")
plt.tight_layout(pad=0, w_pad=0, h_pad=0)
fig.subplots_adjust(bottom=0.05)
# time_of_responses
fig, ax = plt.subplots()
sizes = []
labels = []
for player in players:
sizes.append(stats[player]["time_of_responses"])
labels.append(player)
ax.set_title("Time of responses")
ax.pie(sizes, labels=labels,
autopct=lambda pct: ('%1.2f%%' % pct) if pct > 0 else '',
startangle=45,
pctdistance=1.15,
labeldistance=1.27)
# fig.legend(patches, labels, ncol=6, loc="lower center")
for player in players:
print(10000*scores[player]/stats[player]["time_of_responses"], player, sep='\t', flush=True, end='\n')
plt.show()