mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-11-15 14:53:51 +01:00
WIP: removing tiles
This commit is contained in:
@@ -81,11 +81,11 @@ class Door(Entity):
|
||||
self._open()
|
||||
return c.VALID
|
||||
|
||||
def tick(self):
|
||||
if self.is_open and len(self.tile) == 1 and self.time_to_close:
|
||||
def tick(self, state):
|
||||
if self.is_open and len(state.entities.pos_dict[self.pos]) == 2 and self.time_to_close:
|
||||
self.time_to_close -= 1
|
||||
return c.NOT_VALID
|
||||
elif self.is_open and not self.time_to_close and len(self.tile) == 1:
|
||||
elif self.is_open and not self.time_to_close and len(state.entities.pos_dict[self.pos]) == 2:
|
||||
self.use()
|
||||
return c.VALID
|
||||
else:
|
||||
|
||||
@@ -14,9 +14,9 @@ class Doors(PositionMixin, EnvObjects):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Doors, self).__init__(*args, can_collide=True, **kwargs)
|
||||
|
||||
def tick_doors(self):
|
||||
def tick_doors(self, state):
|
||||
result_dict = dict()
|
||||
for door in self:
|
||||
did_tick = door.tick()
|
||||
did_tick = door.tick(state)
|
||||
result_dict.update({door.name: did_tick})
|
||||
return result_dict
|
||||
|
||||
@@ -12,7 +12,7 @@ class DoorAutoClose(Rule):
|
||||
|
||||
def tick_step(self, state):
|
||||
if doors := state[d.DOORS]:
|
||||
doors_tick_result = doors.tick_doors()
|
||||
doors_tick_result = doors.tick_doors(state)
|
||||
doors_that_ticked = [key for key, val in doors_tick_result.items() if val]
|
||||
state.print(f'{doors_that_ticked} were auto-closed'
|
||||
if doors_that_ticked else 'No Doors were auto-closed')
|
||||
|
||||
Reference in New Issue
Block a user