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.
- Go to this link. Click “raw”. Copy the text and save it to a file called
- Open up a shell prompt and navigate to where you saved the file.
- 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
- 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!