action_saver.py 414 Bytes
Newer Older
1
from flatland.envs.rail_env_action import RailEnvActions
Dipam Chakraborty's avatar
Dipam Chakraborty committed
2
3
4
5
6
7
8

class ActionSaver:
	def __init__(self):
		self.saved_action = None
	
	@property
	def is_action_saved(self):
9
		return self.saved_action is not None
Dipam Chakraborty's avatar
Dipam Chakraborty committed
10
11
12
13
14
15
16
17

	def save_action_if_allowed(self, action):
		if not self.is_action_saved and RailEnvActions.is_moving_action(action):
			self.saved_action = action

	def clear_saved_action(self):
		self.saved_action = None