Switch to a global PRNG for action/observation spaces (#144)

cf 58e6aa95e5 (commitcomment-17669277)
This commit is contained in:
Greg Brockman
2016-05-30 18:07:59 -07:00
parent 5bb2337585
commit 8a535ca6f2
32 changed files with 198 additions and 179 deletions

View File

@@ -54,15 +54,14 @@ class DoomBasicEnv(doom_env.DoomEnv):
self.viewer = None
self.game.init()
self.game.new_episode()
# 3 allowed actions [0, 9, 10] (must match .cfg file)
self.action_space = spaces.HighLow(np.matrix([[0, 1, 0]] * 3))
self.observation_space = spaces.Box(low=0, high=255, shape=(self.screen_height, self.screen_width, 3))
self._seed()
def _seed(self, seed=None):
np_random, seed1 = seeding.np_random(seed)
# Derive a random seed.
seed2 = seeding.hash_seed(seed1 + 1) % 2**32
self.game.set_seed(seed2)
# 3 allowed actions [0, 9, 10] (must match .cfg file)
self.action_space = spaces.HighLow(np.matrix([[0, 1, 0]] * 3), np_random=np_random)
self.observation_space = spaces.Box(low=0, high=255, shape=(self.screen_height, self.screen_width, 3), np_random=np_random)
return [seed1, seed2]
seed = seeding.hash_seed(seed) % 2**32
self.game.set_seed(seed)
return [seed]