Quickstart guide to setup and run Gym Retro

Let's try out the Gym Retro library quickly by installing the pre-built binaries using pip with the following command:

          (rl_gym_book) praveen@ubuntu:~/rl_gym_book/ch9$ pip install gym-retro
        

Once the installation is successful, we can have a sneak peek into one of the available Gym Retro environments using the following script:

          #!/usr/bin/env pythonimport
          retro
          
          if
          __name__
          ==
          '__main__'
          :
             env
          =
          retro
          .
          make
          (
          game
          =
          'Airstriker-Genesis'
          ,
          state
          =
          'Level1'
          )
          obs
          =
          env
          .
          reset
          ()
          while
          True
          :
          obs
          ,
          rew
          ,
          done
          ,
          info
          =
          env
          .
          step
          (
          env
          .
          action_space
          .
          sample
          ())
          env
          .
          render
          ()
          if
          done
          :
          obs
          =
          env
          .
          reset
          ()
        

Running this script will bring up a window with the Airstriker game and show the spaceship ...

Get Hands-On Intelligent Agents with OpenAI Gym now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.