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

@@ -61,7 +61,7 @@ class Maintainer(Entity):
self._last.append(self._next.pop())
self._path = self.calculate_route(self._last[-1])
if door := self._door_is_close():
if door := self._door_is_close(state):
if door.is_closed:
# Translate the action_object to an integer to have the same output as any other model
action = do.ACTION_DOOR_USE
@@ -81,15 +81,18 @@ class Maintainer(Entity):
route = nx.shortest_path(self._floortile_graph, self.pos, entity.pos)
return route[1:]
def _door_is_close(self):
def _door_is_close(self, state):
state.print("Found a door that is close.")
try:
return next(y for x in self.tile.neighboring_floor for y in x.guests if do.DOOR in y.name)
# return next(y for x in self.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_move(self, state):
next_pos = self._path[0]
if len(state[c.FLOORS].by_pos(next_pos).guests_that_can_collide) > 0:
# if len(state[c.FLOORS].by_pos(next_pos).guests_that_can_collide) > 0:
if any(x for x in state.entities.pos_dict[next_pos] if x.var_can_collide) > 0:
action = c.NOOP
else:
next_pos = self._path.pop(0)

View File

@@ -21,5 +21,5 @@ class Maintainers(PositionMixin, EnvObjects):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def spawn(self, tiles: List[Floor], state: Gamestate):
self.add_items([self._entity(state, mc.MACHINES, MachineAction(), tile) for tile in tiles])
def spawn(self, position, state: Gamestate):
self.add_items([self._entity(state, mc.MACHINES, MachineAction(), pos) for pos in position])