fix mismatching signatures of spawn

This commit is contained in:
Chanumask
2023-10-27 17:46:13 +02:00
parent dd5737e3ff
commit 115a79e930
11 changed files with 38 additions and 42 deletions

View File

@ -1,9 +1,10 @@
from typing import Union, List, Tuple
from marl_factory_grid.environment.groups.collection import Collection
from marl_factory_grid.modules.batteries.entitites import Pod, Battery
class Batteries(Collection):
_entity = Battery
@property
@ -33,9 +34,14 @@ class Batteries(Collection):
batteries = [self._entity(initial_charge_level, agent) for _, agent in enumerate(agents)]
self.add_items(batteries)
# def spawn(self, coords_or_quantity: Union[int, List[Tuple[(int, int)]]], *entity_args): hat keine pos
# agents = entity_args[0]
# initial_charge_level = entity_args[1]
# batteries = [self._entity(initial_charge_level, agent) for _, agent in enumerate(agents)]
# self.add_items(batteries)
class ChargePods(Collection):
_entity = Pod
def __init__(self, *args, **kwargs):

View File

@ -49,7 +49,7 @@ class BatteryDecharge(Rule):
self.per_action_costs = per_action_costs
self.initial_charge = initial_charge
def on_init(self, state, lvl_map):
def on_init(self, state, lvl_map): # on reset?
assert len(state[c.AGENT]), "There are no agents, did you already spawn them?"
state[b.BATTERIES].spawn(state[c.AGENT], self.initial_charge)