Fixed Battery Charge

This commit is contained in:
Steffen Illium
2023-11-16 17:16:22 +01:00
parent 6c27aa8eaf
commit 67a3f3f342
3 changed files with 7 additions and 7 deletions

View File

@ -1,4 +1,5 @@
from marl_factory_grid.environment import constants as c
from marl_factory_grid.environment.entity.agent import Agent
from marl_factory_grid.environment.entity.entity import Entity
from marl_factory_grid.environment.entity.object import Object
from marl_factory_grid.modules.batteries import constants as b
@ -62,11 +63,11 @@ class ChargePod(Entity):
self.charge_rate = charge_rate
self.multi_charge = multi_charge
def charge_battery(self, battery: Battery):
if battery.charge_level == 1.0:
def charge_battery(self, entity, state):
battery = state[b.BATTERIES].by_entity(entity)
if battery.charge_level >= 1.0:
return c.NOT_VALID
if sum(1 for key, val in self.state.entities.pos_dict[self.pos] for guest in val if
'agent' in guest.name.lower()) > 1:
if len([x for x in state[c.AGENT].by_pos(entity.pos)]) > 1:
return c.NOT_VALID
valid = battery.do_charge_action(self.charge_rate)
return valid