takuseno / d4rl-atari

Datasets for data-driven deep reinforcement learning with Atari (wrapper for datasets released by Google)
MIT License
101 stars 14 forks source link

Seed not working for AtariEnv #4

Closed sebffischer closed 3 years ago

sebffischer commented 3 years ago

First of all: Thank you for writing this nice wrapper! :)

I wanted to use the AtariEnv for evaluation and I realized that the seed method is not working. I am not sure whether this is a bug or should be that way

from d4rl_atari.envs import AtariEnv
import numpy as np 

env0 = AtariEnv("Pong", stack=True)
env0.seed(0)

env1 = AtariEnv("Pong", stack=True)
env1.seed(0)

env0.reset()
env1.reset()

for i in range(10):
    a = env0.action_space.sample()
    s0, *_ = env0.step(a)
    s1, *_ = env1.step(a)

    np.equal(np.array(s0), np.array(s1)).all()

The following code works:

from d4rl_atari.envs import AtariEnv
import numpy as np 

env0 = AtariEnv("Pong", stack=True)
env0._env.seed(0)

env1 = AtariEnv("Pong", stack=True)
env1._env.seed(0)

env0.reset()
env1.reset()

for i in range(10):
    a = env0.action_space.sample()
    s0, *_ = env0.step(a)
    s1, *_ = env1.step(a)

    np.equal(np.array(s0), np.array(s1)).all()
takuseno commented 3 years ago

@sebffischer Thanks for reporting this issue! Let me check.

takuseno commented 3 years ago

I've solved this issue now at this commit https://github.com/takuseno/d4rl-atari/commit/8d1d3ff621d822a65adc2227441d7c220324f445 .