mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-05-23 15:26:43 +02:00
added viz. of agent collision
This commit is contained in:
parent
c1f2ddf3cd
commit
30af16190e
@ -42,8 +42,13 @@ class GettingDirty(BaseFactory):
|
|||||||
dirt = [Entity('dirt', [x, y], min(0.15+self.state[DIRT_INDEX, x, y], 1.5), 'scale')
|
dirt = [Entity('dirt', [x, y], min(0.15+self.state[DIRT_INDEX, x, y], 1.5), 'scale')
|
||||||
for x, y in np.argwhere(self.state[DIRT_INDEX] > h.IS_FREE_CELL)]
|
for x, y in np.argwhere(self.state[DIRT_INDEX] > h.IS_FREE_CELL)]
|
||||||
walls = [Entity('wall', pos) for pos in np.argwhere(self.state[h.LEVEL_IDX] > h.IS_FREE_CELL)]
|
walls = [Entity('wall', pos) for pos in np.argwhere(self.state[h.LEVEL_IDX] > h.IS_FREE_CELL)]
|
||||||
asset_str = lambda agent: f'agent{agent.i+1}violation' if (not agent.action_valid or agent.collision_vector[h.LEVEL_IDX] > 0)\
|
|
||||||
else (f'agent{agent.i+1}valid' if self._is_clean_up_action(agent.action) else f'agent{agent.i+1}')
|
def asset_str(agent):
|
||||||
|
cols = ' '.join([self.slice_strings[j] for j in agent.collisions])
|
||||||
|
asset_str = f'agent{agent.i + 1}violation' if (not agent.action_valid or 'level' in cols or 'agent' in cols) \
|
||||||
|
else (f'agent{agent.i + 1}valid' if self._is_clean_up_action(agent.action) else f'agent{agent.i + 1}')
|
||||||
|
return asset_str
|
||||||
|
|
||||||
agents = {f'agent{i+1}': [Entity(asset_str(agent), agent.pos)]
|
agents = {f'agent{i+1}': [Entity(asset_str(agent), agent.pos)]
|
||||||
for i, agent in enumerate(self.agent_states)}
|
for i, agent in enumerate(self.agent_states)}
|
||||||
self.renderer.render(OrderedDict(dirt=dirt, wall=walls, **agents))
|
self.renderer.render(OrderedDict(dirt=dirt, wall=walls, **agents))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user