-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
63 lines (50 loc) · 1.11 KB
/
plot.py
File metadata and controls
63 lines (50 loc) · 1.11 KB
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
import json
import numpy as np
import matplotlib.pyplot as plt
# load json
with open("battle_stats.json", "r") as f:
data = json.load(f)
industry = []
offensive = []
defensive = []
reward = []
for entry in data:
# compute reward
r = entry["Battle_Score"] - 0.3 * entry["Battle_STD"]
reward.append(r)
# compute center of coordinates
industry.append(np.mean(entry["Industry"]))
offensive.append(np.mean(entry["Offensive_Pos"]))
defensive.append(np.mean(entry["Defensive_Pos"]))
fig = plt.figure(figsize=(9,7))
ax = fig.add_subplot(111, projection='3d')
# scatter points
sc = ax.scatter(
industry,
offensive,
defensive,
c=reward,
s=120,
cmap="viridis"
)
# optimizer path
ax.plot(
industry,
offensive,
defensive,
linewidth=2
)
# iteration labels
for i in range(len(industry)):
ax.text(
industry[i],
offensive[i],
defensive[i],
str(i+1)
)
ax.set_xlabel("Industry")
ax.set_ylabel("Offensive Position")
ax.set_zlabel("Defensive Position")
plt.colorbar(sc, label="Reward")
plt.title("3D Optimization Path")
plt.show()