fixed agent collision viz. bug
This commit is contained in:
@ -77,12 +77,17 @@ class Renderer:
|
|||||||
bp = self.blit_params(entity)
|
bp = self.blit_params(entity)
|
||||||
blits.append(bp)
|
blits.append(bp)
|
||||||
if 'agent' in entity.name and self.view_radius > 0:
|
if 'agent' in entity.name and self.view_radius > 0:
|
||||||
visibility_rect = bp['dest'].inflate((self.view_radius*2)*self.cell_size, (self.view_radius*2)*self.cell_size)
|
visibility_rect = bp['dest'].inflate(
|
||||||
|
(self.view_radius*2)*self.cell_size, (self.view_radius*2)*self.cell_size
|
||||||
|
)
|
||||||
shape_surf = pygame.Surface(visibility_rect.size, pygame.SRCALPHA)
|
shape_surf = pygame.Surface(visibility_rect.size, pygame.SRCALPHA)
|
||||||
pygame.draw.rect(shape_surf, self.AGENT_VIEW_COLOR, shape_surf.get_rect())
|
pygame.draw.rect(shape_surf, self.AGENT_VIEW_COLOR, shape_surf.get_rect())
|
||||||
shape_surf.set_alpha(64)
|
shape_surf.set_alpha(64)
|
||||||
blits.appendleft(dict(source=shape_surf, dest=visibility_rect))
|
blits.appendleft(dict(source=shape_surf, dest=visibility_rect))
|
||||||
agent_state_blits = self.blit_params(Entity(entity.state, (entity.pos[0]+0.11, entity.pos[1]), 0.48, 'scale'))
|
if entity.state != 'blank':
|
||||||
|
agent_state_blits = self.blit_params(
|
||||||
|
Entity(entity.state, (entity.pos[0]+0.11, entity.pos[1]), 0.48, 'scale')
|
||||||
|
)
|
||||||
blits.append(agent_state_blits)
|
blits.append(agent_state_blits)
|
||||||
|
|
||||||
for blit in blits:
|
for blit in blits:
|
||||||
|
@ -57,7 +57,7 @@ class SimpleFactory(BaseFactory):
|
|||||||
print('error')
|
print('error')
|
||||||
cols = ' '.join([self._state_slices[j] for j in agent.collisions])
|
cols = ' '.join([self._state_slices[j] for j in agent.collisions])
|
||||||
if 'agent' in cols:
|
if 'agent' in cols:
|
||||||
return 'agent_collision'
|
return 'agent_collision', 'blank'
|
||||||
elif not agent.action_valid or 'level' in cols or 'agent' in cols:
|
elif not agent.action_valid or 'level' in cols or 'agent' in cols:
|
||||||
return f'agent{agent.i + 1}', 'invalid'
|
return f'agent{agent.i + 1}', 'invalid'
|
||||||
elif self._is_clean_up_action(agent.action):
|
elif self._is_clean_up_action(agent.action):
|
||||||
|
Reference in New Issue
Block a user