mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-07-05 17:11:35 +02:00
Fixed Battery Charge
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user