Verified Collision Checks and Rendering

This commit is contained in:
Steffen Illium
2023-11-23 11:43:04 +01:00
parent 142bbb2c0c
commit 2f29ef703c
6 changed files with 14 additions and 6 deletions

View File

@@ -135,8 +135,10 @@ class Agent(Entity):
i = self.collection.idx_by_entity(self)
assert i is not None
curr_state = self.state
name = c.AGENT
if curr_state.identifier == c.COLLISION:
render_state = renderer.STATE_COLLISION
name = renderer.STATE_COLLISION
render_state=None
elif curr_state.validity:
if curr_state.identifier == c.NOOP:
render_state = renderer.STATE_IDLE
@@ -147,4 +149,4 @@ class Agent(Entity):
else:
render_state = renderer.STATE_INVALID
return RenderEntity(c.AGENT, self.pos, 1, 'none', render_state, i + 1, real_name=self.name)
return RenderEntity(name, self.pos, 1, 'none', render_state, i + 1, real_name=self.name)

View File

@@ -27,6 +27,10 @@ class Agents(Collection):
def var_has_position(self):
return True
@property
def var_can_collide(self):
return True
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

View File

@@ -198,14 +198,14 @@ class WatchCollisions(Rule):
def tick_post_step(self, state) -> List[TickResult]:
self.curr_done = False
pos_with_collisions = state.get_collision_positions()
results = list()
for agent in state[c.AGENT]:
a_s = agent.state
if h.is_move(a_s.identifier) and a_s.action_introduced_collision:
results.append(TickResult(entity=agent, identifier=c.COLLISION,
reward=self.reward, validity=c.VALID))
for pos in pos_with_collisions:
for pos in state.get_collision_positions():
guests = [x for x in state.entities.pos_dict[pos] if x.var_can_collide]
if len(guests) >= 2:
for i, guest in enumerate(guests):