Getting started

If you don't have a full install of OpenAI gym, you can install the Atari environment dependencies via the following:

pip install gym[atari]

This requires the cmake tools. This command will automatically compile the arcade learning environment and its Python interface, atari-py. The compilation will take a few minutes on a common laptop, so go have a cup of coffee.

After the Atari environment is installed, try the following:

import gymatari = gym.make('Breakout-v0')atari.reset()atari.render()

If it runs successfully, a small window will pop up, showing the screen of the game Breakout, as shown in the following screenshot:

Get Python Reinforcement Learning Projects 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.