Merge branch 'remove-tiles'

# Conflicts:
#	marl_factory_grid/environment/actions.py
#	marl_factory_grid/environment/entity/entity.py
#	marl_factory_grid/environment/factory.py
#	marl_factory_grid/modules/batteries/rules.py
#	marl_factory_grid/modules/clean_up/groups.py
#	marl_factory_grid/modules/destinations/entitites.py
#	marl_factory_grid/modules/destinations/groups.py
#	marl_factory_grid/modules/destinations/rules.py
#	marl_factory_grid/modules/items/rules.py
#	marl_factory_grid/modules/maintenance/entities.py
#	marl_factory_grid/utils/config_parser.py
#	marl_factory_grid/utils/level_parser.py
#	marl_factory_grid/utils/states.py
This commit is contained in:
Steffen Illium
2023-10-17 14:03:59 +02:00
40 changed files with 285 additions and 273 deletions

View File

@ -54,9 +54,10 @@ class TSPBaseAgent(ABC):
nodes=nodes, cycle=True, method=tsp.greedy_tsp)
return route
def _door_is_close(self):
def _door_is_close(self, state):
try:
return next(y for x in self.state.tile.neighboring_floor for y in x.guests if do.DOOR in y.name)
# return next(y for x in self.state.tile.neighboring_floor for y in x.guests if do.DOOR in y.name)
return next(y for x in state.entities.neighboring_positions(self.state.pos) for y in state.entities.pos_dict[x] if do.DOOR in y.name)
except StopIteration:
return None

View File

@ -14,7 +14,7 @@ class TSPDirtAgent(TSPBaseAgent):
if self._env.state[di.DIRT].by_pos(self.state.pos) is not None:
# Translate the action_object to an integer to have the same output as any other model
action = di.CLEAN_UP
elif door := self._door_is_close():
elif door := self._door_is_close(self._env):
action = self._use_door_or_move(door, di.DIRT)
else:
action = self._predict_move(di.DIRT)

View File

@ -24,7 +24,7 @@ class TSPItemAgent(TSPBaseAgent):
elif self._env.state[i.DROP_OFF].by_pos(self.state.pos) is not None:
# Translate the action_object to an integer to have the same output as any other model
action = i.ITEM_ACTION
elif door := self._door_is_close():
elif door := self._door_is_close(self._env):
action = self._use_door_or_move(door, i.DROP_OFF if self.mode == MODE_BRING else i.ITEM)
else:
action = self._choose()

View File

@ -11,15 +11,16 @@ class TSPTargetAgent(TSPBaseAgent):
def __init__(self, *args, **kwargs):
super(TSPTargetAgent, self).__init__(*args, **kwargs)
def _handle_doors(self):
def _handle_doors(self, state):
try:
return next(y for x in self.state.tile.neighboring_floor for y in x.guests if do.DOOR in y.name)
# return next(y for x in self.state.tile.neighboring_floor for y in x.guests if do.DOOR in y.name)
return next(y for x in state.entities.neighboring_positions(self.state.pos) for y in state.entities.pos_dict[x] if do.DOOR in y.name)
except StopIteration:
return None
def predict(self, *_, **__):
if door := self._door_is_close():
if door := self._door_is_close(self._env):
action = self._use_door_or_move(door, d.DESTINATION)
else:
action = self._predict_move(d.DESTINATION)