-
Notifications
You must be signed in to change notification settings - Fork 0
/
treasure_acquisition.py
149 lines (123 loc) · 4.58 KB
/
treasure_acquisition.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
from PIL import Image
import numpy as np
from collections import Counter
import seaborn as sns
import matplotlib.pyplot as plt
import statistics
import sbbtracker_datasci.utils.load_data as l
from collections import defaultdict
from matplotlib.colors import LogNorm
import matplotlib
import matplotlib.image as image
from sbbbattlesim.treasures import registry as treasure_registry
from sbbbattlesim.characters import registry as character_registry
from sbbbattlesim.spells import registry as spell_registry
l.load_data()
mmftp = l.GLOBAL_DATA.mythic_games[l.GLOBAL_DATA.latest_patch]
treasures_by_turn = defaultdict(Counter)
placements = [1,2]
color_palettes = {
'sbb-sequential-multihue': {
'colors': ['#f7fcf0', '#e0f3db', '#ccebc5', '#a8ddb5', '#7bccc4', '#4eb3d3', '#2b8cbe', '#0868ac', '#084081'],
'intervals': [0, 0.10, 0.20, 0.32, 0.44, 0.59, 0.73, 0.88, 1.00]
}
}
missing_units = set()
missing_spells = set()
im = Image.open('icon.png')
rsize= im.resize((np.array(im.size)/10).astype(int))
rsizeArr = np.asarray(rsize)
def NonLinCdict(steps, hexcol_array):
cdict = {'red': (), 'green': (), 'blue': ()}
for s, hexcol in zip(steps, hexcol_array):
rgb =matplotlib.colors.hex2color(hexcol)
cdict['red'] = cdict['red'] + ((s, rgb[0], rgb[0]),)
cdict['green'] = cdict['green'] + ((s, rgb[1], rgb[1]),)
cdict['blue'] = cdict['blue'] + ((s, rgb[2], rgb[2]),)
return cdict
cpallete = color_palettes['sbb-sequential-multihue']
colors = NonLinCdict(cpallete['intervals'], cpallete['colors'])
cmap = matplotlib.colors.LinearSegmentedColormap('sbbtracker-sequential-cmap', colors)
for _m in mmftp:
m = l.GLOBAL_DATA.all_data[l.GLOBAL_DATA.latest_patch][_m]
if m['placement'] not in placements:
continue
pid = m['player-id']
for c in sorted(m['combat-info'], key=lambda x : x['round']):
all_treasures = set()
if not c['combat']:
continue
ci = c['combat'][pid]
r = c['round']
if r > 20:
continue
treasures = ci['treasures']
for t in treasures:
if t != 'SBB_TREASURE_RUSTYDAGGERS': #t in all_treasures:
continue
else:
all_treasures.add(t)
sbbst = treasure_registry[t]
if t == 'SBB_TREASURE_EYESOFARES':
sbbst._level = 3
treasures_by_turn[r][sbbst._level] += 1
for _c in ci['characters']:
sssss = character_registry[_c['id']]
if sssss._level == 0:
missing_units.add(_c['id'])
for _s in ci['spells']:
sssss = spell_registry[_s]
try:
if sssss._level == 0:
missing_spells.add(_s)
except AttributeError:
missing_spells.add(_s)
print(missing_units, missing_spells)
ylabel = 'lol'
maxlen = 20
maxval = 7
minval = 0
ymin = 0
heatmap = list()
heatmap_not_normalized = list()
for _ in range(0, 8):
ls = list()
ls_not_normalized = list()
for _ in range(0, 20):
ls.append(0)
ls_not_normalized.append(0)
heatmap.append(ls)
heatmap_not_normalized.append(ls_not_normalized)
for e, turn in enumerate(sorted(treasures_by_turn)):
tbtt = treasures_by_turn[turn]
for lvl in tbtt:
heatmap[lvl-ymin][e] = tbtt[lvl] / sum(tbtt.values())
heatmap_not_normalized[lvl-ymin][e] = tbtt[lvl]
npdata = np.array(heatmap)
npdata_not_normalized = np.array(heatmap_not_normalized)
placements = [str(i) for i in placements]
fig = plt.figure(1)
sns.heatmap(npdata, norm=LogNorm(), cmap=cmap)
figwidth = fig.get_figwidth()
figheight = fig.get_figheight()
plt.ylim(0, maxval+1-ymin)
plt.xlim(1)
numticks = int((maxval-ymin+1)/8)
ticks = list(range(ymin, maxval+1, numticks))
locations = list(range(0, maxval-ymin+1, numticks))
plt.yticks(locations, ticks, rotation=0)
plt.ylabel(ylabel)
plt.xlabel('Turn Number')
plt.title(f'{ylabel} vs Turn, Normalized by Turn\nPlacements: {", ".join(placements)}')
fig.figimage(rsizeArr, figwidth, figheight, zorder=100)
plt.savefig(f'/Users/ilyasaricanli/pngs/treasures-by-level-and-turn-normalized_{"-".join(placements)}.png')
fig = plt.figure(0)
sns.heatmap(npdata_not_normalized, norm=LogNorm(), cmap=cmap)
plt.ylim(0, maxval+1-ymin)
plt.xlim(1)
plt.yticks(locations, ticks, rotation=0)
plt.xlabel('Turn Number')
plt.ylabel(ylabel)
fig.figimage(rsizeArr, figwidth, figheight, zorder=100)
plt.title(f'{ylabel} vs Turn Number, raw\nPlacements: {", ".join(placements)}')
plt.savefig(f'/Users/ilyasaricanli/pngs/treasures-by-level-and-turn-raw_{"-".join(placements)}.png')