I tried setting the seed by using
random.seed(1995)
But I do not get the same results. I looks like every game environment initializes its own unique seed. If this is the case how would I go about generating the same results every time ? In this case im trying to do this for LunarLander-v2
Edit : I also just tried
observation = env.reset()
env.seed(1995)
It is still giving different results. even after setting the seed after every reset()
The code in question is located here : https://github.com/DollarAkshay/Python-Programs/blob/master/Artificial%20Intelligence/OpenAI_LunarLander_v2.py
env.seed() will seed the environment randomness. If your agent also uses randomness, you will need to seed that separately (i.e. using random.seed()) to get repeatable results
ex://
>>> import gym
>>> env = gym.make('LunarLander-v2')
[2016-12-21 10:38:47,791] Making new env: LunarLander-v2
>>> env.seed(0)
[0L]
>>> env.reset()
array([ -5.91564178e-04, 9.42304904e-01, -5.99357188e-02,
1.12770955e-01, 6.92289264e-04, 1.35763153e-02,
0.00000000e+00, 0.00000000e+00])
>>> env.step(0)
(array([-0.00118332, 0.94361125, -0.05985444, 0.08708715, 0.00136317,
0.01341959, 0. , 0. ]), 2.0058447786388598, False, {})
>>> env.seed(0)
[0L]
>>> env.reset()
array([ -5.91564178e-04, 9.42304904e-01, -5.99357188e-02,
1.12770955e-01, 6.92289264e-04, 1.35763153e-02,
0.00000000e+00, 0.00000000e+00])
>>> env.step(0)
(array([-0.00118332, 0.94361125, -0.05985444, 0.08708715, 0.00136317,
0.01341959, 0. , 0. ]), 2.0058447786388598, False, {})
Most helpful comment
env.seed()will seed the environment randomness. If your agent also uses randomness, you will need to seed that separately (i.e. using random.seed()) to get repeatable resultsex://