mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2026-07-15 23:31:52 +02:00
moved aftermath collision check to action
This commit is contained in:
@@ -52,6 +52,11 @@ class Move(Action, abc.ABC):
|
||||
new_pos = self._calc_new_pos(entity.pos)
|
||||
if state.check_move_validity(entity, new_pos):
|
||||
valid = entity.move(new_pos, state)
|
||||
# Aftermath Collision Check
|
||||
if len([x for x in state.entities.by_pos(entity.pos) if x.var_can_collide]) > 1:
|
||||
# The entity did move, but there was something to collide with...
|
||||
# Is then reported as a non-valid move, which did work.
|
||||
valid = False
|
||||
|
||||
else:
|
||||
# There is no place to go, propably collision
|
||||
|
||||
Reference in New Issue
Block a user