mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-11-02 21:47:25 +01:00
Comments, small bugfixes removed legacy elements
This commit is contained in:
@@ -12,10 +12,6 @@ class Batteries(Collection):
|
||||
var_has_position = False
|
||||
var_can_be_bound = True
|
||||
|
||||
@property
|
||||
def obs_tag(self):
|
||||
return self.__class__.__name__
|
||||
|
||||
def __init__(self, size, initial_charge_level: float=1.0, *args, **kwargs):
|
||||
super(Batteries, self).__init__(size, *args, **kwargs)
|
||||
self.initial_charge_level = initial_charge_level
|
||||
|
||||
@@ -50,7 +50,6 @@ class Door(Entity):
|
||||
def is_open(self):
|
||||
return self._state == d.STATE_OPEN
|
||||
|
||||
|
||||
@property
|
||||
def time_to_close(self):
|
||||
return self._time_to_close
|
||||
|
||||
@@ -18,6 +18,7 @@ class Doors(Collection):
|
||||
def tick_doors(self, state):
|
||||
results = list()
|
||||
for door in self:
|
||||
assert isinstance(door, Door)
|
||||
tick_result = door.tick(state)
|
||||
if tick_result is not None:
|
||||
results.append(tick_result)
|
||||
@@ -26,4 +27,5 @@ class Doors(Collection):
|
||||
|
||||
def reset(self):
|
||||
for door in self:
|
||||
assert isinstance(door, Door)
|
||||
door.reset()
|
||||
|
||||
@@ -56,6 +56,9 @@ class Inventory(IsBoundMixin, Collection):
|
||||
self._collection = None
|
||||
self.bind(agent)
|
||||
|
||||
def __repr__(self):
|
||||
return f'{self.__class__.__name__}#{self._bound_entity.name}({dict(self._data)})'
|
||||
|
||||
def summarize_states(self, **kwargs):
|
||||
attr_dict = {key: val for key, val in self.__dict__.items() if not key.startswith('_') and key != 'data'}
|
||||
attr_dict.update(dict(items=[val.summarize_state(**kwargs) for key, val in self.items()]))
|
||||
@@ -100,12 +103,6 @@ class Inventories(Objects):
|
||||
def trigger_spawn(self, state, *args, **kwargs) -> [Result]:
|
||||
return self.spawn(state[c.AGENT], *args, **kwargs)
|
||||
|
||||
def idx_by_entity(self, entity):
|
||||
try:
|
||||
return next((idx for idx, inv in enumerate(self) if inv.belongs_to_entity(entity)))
|
||||
except StopIteration:
|
||||
return None
|
||||
|
||||
def by_entity(self, entity):
|
||||
try:
|
||||
return next((inv for inv in self if inv.belongs_to_entity(entity)))
|
||||
|
||||
@@ -47,7 +47,7 @@ class AgentSingleZonePlacement(Rule):
|
||||
class IndividualDestinationZonePlacement(Rule):
|
||||
|
||||
def __init__(self):
|
||||
raise NotImplementedError("This is rpetty new, and needs to be debugged, after the zones")
|
||||
raise NotImplementedError("This is pretty new, and needs to be debugged, after the zones")
|
||||
super().__init__()
|
||||
|
||||
def on_reset(self, state):
|
||||
|
||||
Reference in New Issue
Block a user