mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-12-20 05:56:07 +01:00
Merge branch 'main' into refactor_rename
# Conflicts: # marl_factory_grid/modules/clean_up/groups.py # marl_factory_grid/modules/clean_up/rules.py # marl_factory_grid/modules/destinations/rules.py
This commit is contained in:
@@ -20,6 +20,14 @@ class Agent(Entity):
|
||||
def var_can_move(self):
|
||||
return True
|
||||
|
||||
@property
|
||||
def var_is_paralyzed(self):
|
||||
return len(self._paralyzed)
|
||||
|
||||
@property
|
||||
def paralyze_reasons(self):
|
||||
return [x for x in self._paralyzed]
|
||||
|
||||
@property
|
||||
def var_is_blocking_pos(self):
|
||||
return False
|
||||
@@ -57,6 +65,7 @@ class Agent(Entity):
|
||||
|
||||
def __init__(self, actions: List[Action], observations: List[str], *args, **kwargs):
|
||||
super(Agent, self).__init__(*args, **kwargs)
|
||||
self._paralyzed = set()
|
||||
self.step_result = dict()
|
||||
self._actions = actions
|
||||
self._observations = observations
|
||||
@@ -75,6 +84,17 @@ class Agent(Entity):
|
||||
def set_state(self, action_result):
|
||||
self._state = action_result
|
||||
|
||||
def paralyze(self, reason):
|
||||
self._paralyzed.add(reason)
|
||||
return c.VALID
|
||||
|
||||
def de_paralyze(self, reason):
|
||||
try:
|
||||
self._paralyzed.remove(reason)
|
||||
return c.VALID
|
||||
except KeyError:
|
||||
return c.NOT_VALID
|
||||
|
||||
def render(self):
|
||||
i = next(idx for idx, x in enumerate(self._collection) if x.name == self.name)
|
||||
curr_state = self.state
|
||||
|
||||
@@ -99,7 +99,7 @@ class Entity(_Object, 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:
|
||||
|
||||
@@ -37,7 +37,7 @@ class Entities(_Objects):
|
||||
return[x for val in self.pos_dict[pos] for x in val if x.var_can_collide]
|
||||
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user