From 0dfe01ad9e846bce9bfd4c28d71dcb5ad8fddcf4 Mon Sep 17 00:00:00 2001 From: zuoxingdong Date: Thu, 22 Mar 2018 18:15:38 +0100 Subject: [PATCH] update seeding --- gym_maze/envs/maze.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gym_maze/envs/maze.py b/gym_maze/envs/maze.py index 2f4e87a..12a87e4 100644 --- a/gym_maze/envs/maze.py +++ b/gym_maze/envs/maze.py @@ -21,6 +21,9 @@ def __init__(self, live_display=False, render_trace=False): """Initialize the maze. DType: list""" + # Random seed with internal gym seeding + self.seed() + # Maze: 0: free space, 1: wall self.maze_generator = maze_generator self.maze = np.array(self.maze_generator.get_maze()) @@ -98,6 +101,11 @@ def step(self, action): return self._get_obs(), reward, done, info + def seed(self, seed=None): + self.np_random, seed = seeding.np_random(seed) + + return [seed] + def reset(self): # Reset maze self.maze = np.array(self.maze_generator.get_maze())