Skip to content
Snippets Groups Projects
Commit 313190c1 authored by hagrid67's avatar hagrid67
Browse files

got observation rendering working again in PILSVG

parent dde6d690
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,9 @@ class PILGL(GraphicsLayer):
""" convert a hex RGB string like 0091ea to 3-tuple of ints """
return tuple(int(sRGB[iRGB * 2:iRGB * 2 + 2], 16) for iRGB in [0, 1, 2])
def getAgentColor(self, iAgent):
return self.ltAgentColors[iAgent % self.nAgentColors]
def plot(self, gX, gY, color=None, linewidth=3, layer=0, opacity=255, **kwargs):
color = self.adaptColor(color)
if len(color) == 3:
......
......@@ -498,10 +498,11 @@ class RenderTool(object):
"""
rt = self.__class__
cmap = self.gl.get_cmap('hsv', lut=max(len(self.env.agents), len(self.env.agents_static) + 1))
# cmap = self.gl.get_cmap('hsv', lut=max(len(self.env.agents), len(self.env.agents_static) + 1))
for agent in agent_handles:
color = cmap(agent)
# color = cmap(agent)
color = self.gl.getAgentColor(agent)
for visited_cell in observation_dict[agent]:
cell_coord = array(visited_cell[:2])
cell_coord_trans = np.matmul(cell_coord, rt.grc2xy) + rt.xyHalf
......@@ -786,6 +787,9 @@ class RenderTool(object):
# cmap = self.gl.get_cmap('hsv', lut=max(len(self.env.agents), len(self.env.agents_static) + 1))
self.gl.setAgentAt(iAgent, *position, old_direction, direction) # ,color=cmap(iAgent))
if show_observations:
self.renderObs(range(env.get_num_agents()), env.dev_obs_dict)
if show:
self.gl.show()
for i in range(3):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment