Closed YuhangSong closed 5 years ago
Contrary to what the ability to set a "random seed" seems to imply, Atari does not provide an API to get randomness from the hardware. Rather the vast majority of games obtain their random seed from the user's early actions.
Another way for the game to seed their randomness is to take advantage of the fact that the initial RAM and register state up starting up the Atari 2600 is (somewhat) random. This seems to be used by games like Solaris. As far as I can tell, the initial random state of the RAM and registers is the primary effect of the random_seed attribute in the ALE. This means that the randomness is already entirely contained in the RAM and registers as soon as you are able to call clone_state
, and clone_state
does clone the RAM and register.
Note that Stella (the underlying emulator) does have a random number generator and that its state is included when calling clone_full_state
and not included when calling clone_state
... The only problem is that by the time you can call clone_state
it is nearly impossible that the rng will be called again in a way that meaningfully impacts the games.
If you search for randGenerator in the Stella codebase (https://github.com/stella-emu/stella/search?p=1&q=randgenerator&unscoped_q=randgenerator), you'll find that almost all of its uses are to initialize the RAM and registers and all uses outside of that seem highly unlikely to actually be called.
Thanks a lot. It's been very helpful!
I have been testing the stochasticity of the Atari games. And found that both "clone_state()" and "clone_full_state()" for Atari games actually includes pseudorandomness. However, the codes in Gym says:
Please note that we cannot call seed
seed()
after callingrestore_state()
, becauseseed()
will callloadROM()
after reset the seed, which meansrestore_state()
will be overwrite byloadROM()
. Theseed()
method is pasted in the following:I have also tried calling
self.ale.setInt(b'random_seed', seed2)
directly after callingrestore_state()
to change the seed of the ale object, but the pseudorandomness remains (I still get deterministic results).Thus, it seems that the seed of an Atari environment is fixed after the ROM is loaded, and cannot be modified between two
reset()
s. And the comments forclone_state
is wrong?I am pasting my code for testing the stochasticity of the Atari games in the following, please feel free to run the code and have a try to reset the seed after calling
restore_state()
.Many thanks!