back · main · about · writing · notes · reading · d3 · now · contact


How to play the OpenAI Gym environments yourself
13 Oct 2018 · 178 words

Ever wanted to play the games that your reinforcement agents are learning?

OpenAI have a keyboard agent to let you try out the gym environments yourself. Here’s how to set it up.

First, if you haven’t already, install the gym package with pip install gym, or by following the instructions here.

Then:

  1. Go to this link.¬†Click “raw”. Copy the text and save it to a file called keyboard_agent.py
  2. Open up a shell prompt and navigate to where you saved the file.
  3. Run the file with Python, followed by the name of the environment that you wish to play. For example, python keyboard_agent.py MountainCar-v0
  4. Play the game! The actions are normally mapped to the keys 0,1,2,3,4…, just as they are for the agent. You may have to look up the controls of the environment if you can’t figure it out.

Not all of the environments work with this method -¬† I didn’t have any luck with the toy text environments. But I could get the Atari ones and the continuous control ones working, at least. Better than nothing!


back · main · about · writing · notes · reading · d3 · now · contact