added vizualization for violations

This commit is contained in:
romue
2021-05-18 14:22:22 +02:00
parent 5a6a444af4
commit a6793e11ca
3 changed files with 17 additions and 6 deletions

View File

@ -41,10 +41,15 @@ class GettingDirty(BaseFactory):
dirt = [Entity('dirt', [x, y], min(1.1*self.state[DIRT_INDEX, x, y], 1), 'opacity')
for x, y in np.argwhere(self.state[DIRT_INDEX] > h.IS_FREE_CELL)]
walls = [Entity('dirt', pos) for pos in np.argwhere(self.state[h.LEVEL_IDX] > h.IS_FREE_CELL)]
agents = [Entity('agent1', pos) for pos in np.argwhere(self.state[h.AGENT_START_IDX] > h.IS_FREE_CELL)]
walls = [Entity('wall', pos) for pos in np.argwhere(self.state[h.LEVEL_IDX] > h.IS_FREE_CELL)]
self.renderer.render(OrderedDict(dirt=dirt, wall=walls, agent1=agents))
agents = {f'agent{i+1}': [Entity(f'agent{i+1}'
if (agent.action_valid and agent.collision_vector[h.LEVEL_IDX] <= 0) else f'agent{i+1}violation',
agent.pos)
]
for i, agent in enumerate(self.agent_states)}
print(agents)
self.renderer.render(OrderedDict(dirt=dirt, wall=walls, **agents))
def spawn_dirt(self) -> None:
free_for_dirt = self.free_cells(excluded_slices=DIRT_INDEX)