You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To dump(clone) or load(restore) underlying game state, one can use the following methods:
e_state = env.unwrapped.clone_state() # returns a 1-D vector
env.unwrapped.restore_state(e_state)
The clone_state() and restore_state() functions are actually from gym (see atari_env.py). However it is simply calling ALE's cloneState() and decodeState().
The issue is: after restoring game state, screens and RAM entries are NOT updated. To my best of knowledge they are ONLY updated after reset() and step(). As a result, we only end up getting last frame/RAM information before reset.
Demonstration
e=make_atari('SeaquestNoFrameskip-v4')
# Initialize: e.reset()
foriinrange(100):
s, _, _, _=e.step(0) # stay, no-opplt.imshow(s)
plt.show()
e_state=e.unwrapped.clone_state()
print("Saved state (the submarine is on the surface) :", e_state.shape)
print("RAM state: ", e.unwrapped.ale.getRAM()[:16])
print("------------------------------------\n\n")
foriinrange(100):
s, _, _, _=e.step(5) # go downprint("After 100 actions, now the submarine is at the floor.")
plt.imshow(s)
plt.show()
print("RAM state: ", e.unwrapped.ale.getRAM()[:16])
print("------------------------------------\n\n")
print("Now let's restore. The submarine should be on the surface")
e.unwrapped.restore_state(e_state)
s=e.render('rgb_array') # not restored according to e_state#s, _, _, _ = e.step(0) # re-rendered to 1-step after e_stateplt.imshow(s)
plt.show()
print("RAM state: ", e.unwrapped.ale.getRAM()[:16])
One can see that the rendered frame (which is from getScreenRGB2()) is not updated. It should correspond to the observation of the dumped game state, but it is not. Same thing for RAM.
However, restoring game state itself works well. You can verify that by taking additional one environment step (e.g. e.step(0) as commented).
I believe this is an issue where we need to fix ALE C++ implementation, but for right now I am just reporting the issue. Any idea? Thanks!
The text was updated successfully, but these errors were encountered:
Fixing the ALE implementation may be fine, but it's possible that it makes more sense to just have a wrapper. Specifically the state is not e.unwrapped.clone_state(), but (e.unwrapped. clone_full_state(), e.unwrapped.getRAM(), e.unwrapped.getScreenRGB2()), and it should be restored with the full state as well.
As long as you don't use any stateful wrappers, this may be sufficient. If you do, it may need to be changed to collect/restore state from all wrappers.
To dump(clone) or load(restore) underlying game state, one can use the following methods:
The
clone_state()
andrestore_state()
functions are actually fromgym
(seeatari_env.py
). However it is simply calling ALE'scloneState()
anddecodeState()
.The issue is: after restoring game state, screens and RAM entries are NOT updated. To my best of knowledge they are ONLY updated after
reset()
andstep()
. As a result, we only end up getting last frame/RAM information before reset.Demonstration
One can see that the rendered frame (which is from
getScreenRGB2()
) is not updated. It should correspond to the observation of the dumped game state, but it is not. Same thing for RAM.However, restoring game state itself works well. You can verify that by taking additional one environment step (e.g.
e.step(0)
as commented).I believe this is an issue where we need to fix ALE C++ implementation, but for right now I am just reporting the issue. Any idea? Thanks!
The text was updated successfully, but these errors were encountered: