Farama-Foundation / Arcade-Learning-Environment

The Arcade Learning Environment (ALE) -- a platform for AI research.
https://ale.farama.org/
GNU General Public License v2.0
2.14k stars 420 forks source link

Pitfall game over check doesn't seem to work #268

Open christopherhesse opened 5 years ago

christopherhesse commented 5 years ago

Using the pitfall.bin specified by the md5 file (3e90cf23106f2e08b2781e41299de556) if you start a game and then do nothing for 20 minutes, the timer runs out but game_over() is not set to true.

It looks like there is a check in the code, but it does not seem to work for me: https://github.com/mgbellemare/Arcade-Learning-Environment/blob/master/src/games/supported/Pitfall.cpp#L58

The following script should eventually finish but it does not:

import atari_py

ale = atari_py.ALEInterface()
ale.setFloat("repeat_action_probability".encode("utf-8"), 0.0)
game_path = atari_py.get_game_path("pitfall")
ale.loadROM(game_path)
ale.reset_game()
step = 0
while True:
    if step % 1000 == 0:
        print(step)
    ale.act(0)
    step += 1
    if ale.game_over():
        print(f"done at step {step}")
        break
mgbellemare commented 5 years ago

Thanks for flagging this! I'll take a look post-AAAI.

Profesor09 commented 1 year ago

One potential fix could be to manually check for the timer value in the while loop and set game_over() to true if the timer value exceeds a certain threshold.

Here's an example of what the updated while loop could look like:

python Copy code while True: if step % 1000 == 0: print(step) ale.act(0) step += 1 if ale.getRAM()[17] >= 250: # check if timer value exceeds threshold ale.setEpisodeOver(True) # set episode over to true if ale.game_over(): print(f"done at step {step}") break This code snippet checks the RAM value at index 17 (which corresponds to the timer value) and sets the episode over to true if the timer value exceeds 250. This should trigger the game_over() function to be set to true and end the while loop.

Note that the threshold value of 250 may need to be adjusted depending on the specific game and its timer implementation.