/colabgymrender

Render OpenAI Gym environments in Google Colaboratory

Primary LanguageJupyter NotebookMIT LicenseMIT

This repository has been archived (read below)

Due to breaking changes released in the introduction of gymnasium, I have taken a similar route to continue support and avoid confusion, hereby moving all future code maintenance to a newly named repository. See renderlab for details.

Gym Rendering for Colab

PyPI download month PyPI - Status PyPI GitHub Open In Colab

Installation

apt-get install -y xvfb python-opengl ffmpeg > /dev/null 2>&1
pip install -U colabgymrender
pip install imageio==2.4.1
pip install --upgrade AutoROM
AutoROM --accept-license
pip install gym[atari,accept-rom-license]

Usage

import gym
from colabgymrender.recorder import Recorder

env = gym.make("Breakout-v0")
directory = './video'
env = Recorder(env, directory)

observation = env.reset()
terminal = False
while not terminal:
  action = env.action_space.sample()
  observation, reward, terminal, info = env.step(action)

env.play()

Demo

Watch it on YouTube

Colab.Gym.Rendering.Demo.mp4
Breakout.Demo.mp4
CartPole.Demo.mp4
Pong.Demo.mp4