diff --git a/flatland/envs/rail_env.py b/flatland/envs/rail_env.py index 2c5f4be2947e3a3948ebc57614271da133d9bbee..bf438a565bc177b347e5f0d696f2c62fcccde098 100644 --- a/flatland/envs/rail_env.py +++ b/flatland/envs/rail_env.py @@ -119,8 +119,7 @@ class RailEnv(Environment): obs_builder_object: ObservationBuilder = TreeObsForRailEnv(max_depth=2), max_episode_steps=None, stochastic_data=None, - remove_agents_at_target=False, - random_seed=None + remove_agents_at_target=False ): """ Environment init. @@ -154,9 +153,6 @@ class RailEnv(Environment): remove_agents_at_target : bool If remove_agents_at_target is set to true then the agents will be removed by placing to RailEnv.DEPOT_POSITION when the agent has reach it's target position. - random_seed : int or None - if None, then its ignored, else the random generators are seeded with this number to ensure - that stochastic operations are replicable across multiple operations """ super().__init__() @@ -192,9 +188,6 @@ class RailEnv(Environment): self.action_space = [1] self._seed() - self.random_seed = random_seed - if self.random_seed: - self._seed(seed=random_seed) # Stochastic train malfunctioning parameters if stochastic_data is not None: @@ -255,11 +248,13 @@ class RailEnv(Environment): """ self.agents = EnvAgent.list_from_static(self.agents_static) - def reset(self, regen_rail=True, replace_agents=True, activate_agents=False): + def reset(self, regen_rail=True, replace_agents=True, activate_agents=False, random_seed=None): """ if regen_rail then regenerate the rails. if replace_agents then regenerate the agents static. Relies on the rail_generator returning agent_static lists (pos, dir, target) """ + if random_seed: + self._seed(random_seed) # TODO https://gitlab.aicrowd.com/flatland/flatland/issues/172 # can we not put 'self.rail_generator(..)' into 'if regen_rail or self.rail is None' condition? diff --git a/requirements_dev.txt b/requirements_dev.txt index e02da21600b9cf0574457e915c69474afe0eff35..b71ad94971c59c7a2ef18f038f9c498330a92b1a 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -20,3 +20,4 @@ six>=1.12.0 timeout-decorator>=0.4.1 attrs ushlex +gym==0.14.0