Movement printing and Results, state, state reset.

This commit is contained in:
Steffen Illium
2023-11-16 17:08:08 +01:00
parent 7f1d99fe18
commit 6c27aa8eaf
11 changed files with 45 additions and 21 deletions
+10 -5
View File
@@ -51,13 +51,18 @@ class Move(Action, abc.ABC):
def do(self, entity, state):
new_pos = self._calc_new_pos(entity.pos)
if state.check_move_validity(entity, new_pos):
# noinspection PyUnresolvedReferences
move_really_was_valid = entity.move(new_pos, state)
return self.get_result(move_really_was_valid, entity)
else: # There is no place to go, propably collision
valid = entity.move(new_pos, state)
else:
# There is no place to go, propably collision
# This is currently handeld by the WatchCollisions rule, so that it can be switched on and off by conf.yml
# return ActionResult(entity=entity, identifier=self._identifier, validity=c.NOT_VALID, reward=r.COLLISION)
return self.get_result(c.NOT_VALID, entity)
valid = c.NOT_VALID
if valid:
state.print(f'{entity.name} just moved to {entity.pos}.')
else:
state.print(f'{entity.name} just tried to move to {new_pos} but either failed or hat a Collision.')
return self.get_result(valid, entity)
def _calc_new_pos(self, pos):
x_diff, y_diff = MOVEMAP[self._identifier]