Results resolved. Small ADjustments

This commit is contained in:
Steffen Illium
2023-11-16 15:29:07 +01:00
parent cb76972a5f
commit c3c434a97e
17 changed files with 236 additions and 93 deletions

View File

@ -12,15 +12,12 @@ from marl_factory_grid.utils import helpers as h
class MachineAction(Action):
def __init__(self):
super().__init__(m.MACHINE_ACTION)
super().__init__(m.MACHINE_ACTION, m.MAINTAIN_VALID, m.MAINTAIN_FAIL)
def do(self, entity, state) -> Union[None, ActionResult]:
if machine := h.get_first(state[m.MACHINES].by_pos(entity.pos)):
if valid := machine.maintain():
return ActionResult(entity=entity, identifier=self._identifier, validity=valid, reward=marl_factory_grid.modules.machines.constants.MAINTAIN_VALID)
else:
return ActionResult(entity=entity, identifier=self._identifier, validity=valid, reward=marl_factory_grid.modules.machines.constants.MAINTAIN_FAIL)
valid = machine.maintain()
return self.get_result(valid, entity)
else:
return ActionResult(entity=entity, identifier=self._identifier,
validity=c.NOT_VALID, reward=marl_factory_grid.modules.machines.constants.MAINTAIN_FAIL
)
return self.get_result(c.NOT_VALID, entity)