From 85d65a2c78b01bf2ae7fd4914e823f47da7d41cd Mon Sep 17 00:00:00 2001 From: Steffen Illium Date: Wed, 25 Oct 2023 17:01:58 +0200 Subject: [PATCH] Small adjustment and a not was missing rules --- marl_factory_grid/environment/entity/entity.py | 2 +- marl_factory_grid/environment/groups/global_entities.py | 2 +- marl_factory_grid/modules/batteries/rules.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/marl_factory_grid/environment/entity/entity.py b/marl_factory_grid/environment/entity/entity.py index f24c86c..8cac2aa 100644 --- a/marl_factory_grid/environment/entity/entity.py +++ b/marl_factory_grid/environment/entity/entity.py @@ -70,7 +70,7 @@ class Entity(EnvObject, abc.ABC): try: self.bind_to(bind_to) except AttributeError: - print(f'Objects of {self.__class__.__name__} can not be bound to other entities.') + print(f'Objects of class "{self.__class__.__name__}" can not be bound to other entities.') exit() def summarize_state(self) -> dict: # tile=str(self.tile.name) diff --git a/marl_factory_grid/environment/groups/global_entities.py b/marl_factory_grid/environment/groups/global_entities.py index d403a41..0599acd 100644 --- a/marl_factory_grid/environment/groups/global_entities.py +++ b/marl_factory_grid/environment/groups/global_entities.py @@ -41,7 +41,7 @@ class Entities(Objects): @property def empty_positions(self): - empty_positions= [key for key in self.floorlist if self.pos_dict[key]] + empty_positions = [key for key in self.floorlist if not self.pos_dict[key]] shuffle(empty_positions) return empty_positions diff --git a/marl_factory_grid/modules/batteries/rules.py b/marl_factory_grid/modules/batteries/rules.py index d81dae6..3ed9cfa 100644 --- a/marl_factory_grid/modules/batteries/rules.py +++ b/marl_factory_grid/modules/batteries/rules.py @@ -14,6 +14,7 @@ class Btry(Rule): self.initial_charge = initial_charge def on_init(self, state, lvl_map): + assert len(state[c.AGENT]), "There are no agents, did you already spawn them?" state[b.BATTERIES].spawn(state[c.AGENT], self.initial_charge) def tick_pre_step(self, state) -> List[TickResult]: