-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderer.py
More file actions
63 lines (41 loc) · 1.44 KB
/
renderer.py
File metadata and controls
63 lines (41 loc) · 1.44 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 numpy as np
import matplotlib
import pickle
from rover_domain_core_gym import RoverDomainGym
import matplotlib.pyplot as plt
imageIndex=0
nagents=5
sim = RoverDomainGym(nagents,100)
def render(data,hist):
global imageIndex
imageIndex+=1
scale=.5
plt.clf()
plt.xlim(-data["World Width"]*scale,data["World Width"]*(1.0+scale))
plt.ylim(-data["World Length"]*scale,data["World Length"]*(1.0+scale))
if 1:
markers=["o","*","s","p"]
ntypes=4
xpoints=[[] for i in range(ntypes)]
ypoints=[[] for i in range(ntypes)]
for i in range(len(data["Poi Positions"])):
xpoints[i%ntypes].append(data["Poi Positions"][i,0])
ypoints[i%ntypes].append(data["Poi Positions"][i,1])
for i in range(ntypes):
plt.scatter(xpoints[i],ypoints[i],label=str(i),s=150,marker=markers[i])
plt.legend(["Type "+i for i in ["A","B","C","D"]])
else:
print("Single")
points=[[]for i in range(nagents)]
plt.scatter(hist[0,:,0],hist[0,:,1],s=20)
for i in range(50):
for j in range(nagents):
points[j].append(hist[i][j])
for i in range(nagents):
x,y=np.array(points[i]).T
plt.plot(x,y)
#plt.savefig("ims/test"+str(imageIndex)+".png")
plt.show()
with open("data5.pkl" , 'rb') as f:
states,history,nets=pickle.load(f)
render(sim.data,history)