Description and better naming scheme for the Battery-Module

plus: Agent are not able to move, when discharged.
This commit is contained in:
Steffen Illium
2023-10-26 17:40:43 +02:00
parent ce4108380f
commit ac557232a1
7 changed files with 144 additions and 29 deletions

View File

@@ -1,16 +1,17 @@
from typing import Union
import marl_factory_grid.modules.batteries.constants
from marl_factory_grid.environment.actions import Action
from marl_factory_grid.utils.results import ActionResult
from marl_factory_grid.modules.batteries import constants as b, rewards as r
from marl_factory_grid.modules.batteries import constants as b
from marl_factory_grid.environment import constants as c
class BtryCharge(Action):
def __init__(self):
super().__init__(b.CHARGE)
super().__init__(b.ACTION_CHARGE)
def do(self, entity, state) -> Union[None, ActionResult]:
if charge_pod := state[b.CHARGE_PODS].by_pos(entity.pos):
@@ -23,4 +24,4 @@ class BtryCharge(Action):
valid = c.NOT_VALID
state.print(f'{entity.name} failed to charged batteries at {entity.pos}.')
return ActionResult(entity=entity, identifier=self._identifier, validity=valid,
reward=r.CHARGE_VALID if valid else r.CHARGE_FAIL)
reward=marl_factory_grid.modules.batteries.constants.REWARD_CHARGE_VALID if valid else marl_factory_grid.modules.batteries.constants.Reward_CHARGE_FAIL)