mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-09-18 00:21:58 +02:00
22 lines
840 B
Python
22 lines
840 B
Python
from environment.rules import Rule
|
|
from environment import constants as c
|
|
from environment.utils.results import TickResult
|
|
from modules.doors import constants as d
|
|
|
|
|
|
class DoorAutoClose(Rule):
|
|
|
|
def __init__(self, close_frequency: int = 10):
|
|
super().__init__()
|
|
self.close_frequency = close_frequency
|
|
|
|
def tick_step(self, state):
|
|
if doors := state[d.DOORS]:
|
|
doors_tick_result = doors.tick_doors()
|
|
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')
|
|
return [TickResult(self.name, validity=c.VALID, value=0)]
|
|
state.print('There are no doors, but you loaded the corresponding Module')
|
|
return []
|