mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-09-15 23:37:14 +02:00
WIP: removing tiles
This commit is contained in:
@@ -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):
|
||||
print("doorclose")
|
||||
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.FLOOR].by_pos(next_pos).guests_that_can_collide) > 0:
|
||||
# if len(state[c.FLOOR].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)
|
||||
|
@@ -23,5 +23,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])
|
||||
|
Reference in New Issue
Block a user