mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-12-11 18:10:38 +01:00
Comments, small bugfixes removed legacy elements
This commit is contained in:
@@ -14,37 +14,70 @@ class Agent(Entity):
|
||||
|
||||
@property
|
||||
def var_is_paralyzed(self):
|
||||
"""
|
||||
TODO
|
||||
|
||||
|
||||
:return:
|
||||
"""
|
||||
return len(self._paralyzed)
|
||||
|
||||
@property
|
||||
def paralyze_reasons(self):
|
||||
"""
|
||||
TODO
|
||||
|
||||
|
||||
:return:
|
||||
"""
|
||||
return [x for x in self._paralyzed]
|
||||
|
||||
@property
|
||||
def obs_tag(self):
|
||||
"""Internal Usage"""
|
||||
return self.name
|
||||
|
||||
@property
|
||||
def actions(self):
|
||||
"""
|
||||
TODO
|
||||
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self._actions
|
||||
|
||||
@property
|
||||
def observations(self):
|
||||
"""
|
||||
TODO
|
||||
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self._observations
|
||||
|
||||
def step_result(self):
|
||||
pass
|
||||
"""
|
||||
TODO
|
||||
FIXME THINK ITS LEGACY... Not Used any more
|
||||
|
||||
@property
|
||||
def collection(self):
|
||||
return self._collection
|
||||
|
||||
:return:
|
||||
"""
|
||||
pass
|
||||
|
||||
@property
|
||||
def var_is_blocking_pos(self):
|
||||
return self._is_blocking_pos
|
||||
|
||||
|
||||
def __init__(self, actions: List[Action], observations: List[str], *args, is_blocking_pos=False, **kwargs):
|
||||
"""
|
||||
TODO
|
||||
|
||||
|
||||
:return:
|
||||
"""
|
||||
super(Agent, self).__init__(*args, **kwargs)
|
||||
self._paralyzed = set()
|
||||
self.step_result = dict()
|
||||
@@ -54,26 +87,53 @@ class Agent(Entity):
|
||||
self._is_blocking_pos = is_blocking_pos
|
||||
|
||||
def summarize_state(self):
|
||||
"""
|
||||
TODO
|
||||
|
||||
|
||||
:return:
|
||||
"""
|
||||
state_dict = super().summarize_state()
|
||||
state_dict.update(valid=bool(self.state.validity), action=str(self.state.identifier))
|
||||
return state_dict
|
||||
|
||||
def set_state(self, action_result):
|
||||
self._status = action_result
|
||||
def set_state(self, state):
|
||||
"""
|
||||
TODO
|
||||
|
||||
|
||||
:return:
|
||||
"""
|
||||
self._status = state
|
||||
return c.VALID
|
||||
|
||||
|
||||
def paralyze(self, reason):
|
||||
"""
|
||||
TODO
|
||||
|
||||
|
||||
:return:
|
||||
"""
|
||||
self._paralyzed.add(reason)
|
||||
return c.VALID
|
||||
|
||||
def de_paralyze(self, reason):
|
||||
def de_paralyze(self, reason) -> bool:
|
||||
"""
|
||||
TODO
|
||||
|
||||
|
||||
:return:
|
||||
"""
|
||||
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)
|
||||
def render(self) -> RenderEntity:
|
||||
i = self.collection.idx_by_entity(self)
|
||||
assert i is not None
|
||||
curr_state = self.state
|
||||
if curr_state.identifier == c.COLLISION:
|
||||
render_state = renderer.STATE_COLLISION
|
||||
|
||||
Reference in New Issue
Block a user