<jupyter_start><jupyter_text>This is a notebook to test rendering OpenAI Gym environments on Windows<jupyter_code>import math

%matplotlib inline
import matplotlib.pyplot as plt
import pyvirtualdisplay
display = pyvirtualdisplay.Display(visible=0, size=(1400, 900)).start()
import gym<jupyter_output><empty_output><jupyter_text>Show available envrionments<jupyter_code>all_envs = list(gym.envs.registry.all())
all_envs[:10]
def plot_environment(env, title='', figsize=(5,4)):
    plt.figure(figsize=figsize)
    img = env.render(mode="rgb_array")
    plt.imshow(img)
    plt.axis("off")
    plt.title(title)
    return img
def plot_env_list(names, nrows=1, figsize=(14, 6)):
    n = len(names)
    ncols = math.ceil(n / nrows)
    fig, axes = plt.subplots(nrows, ncols, figsize=figsize)
    for name, ax in zip(names, axes.flatten()):
        env = gym.make(name)
        obs = env.reset()
        assert env.render() 
        img = env.render(mode="rgb_array")
        ax.imshow(img)
        ax.set_title(name)
    return fig<jupyter_output><empty_output><jupyter_text>Render some environments<jupyter_code>fig = plot_env_list(['CartPole-v1', 'MountainCar-v0', 'Pendulum-v0', 
                     'LunarLander-v2', 'Freeway-v4', 'CarRacing-v0'], nrows=2, figsize=(14,8))<jupyter_output>/opt/conda/lib/python3.8/site-packages/gym/logger.py:30: UserWarning: [33mWARN: Box bound precision lowered by casting to float32[0m
  warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))
{'fraction_non_alphanumeric': 0.14439220953660176, 'fraction_numerical': 0.02350570852921424, 'mean_word_length': 4.5390334572490705, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '462066', 'license': 'MIT', 'n_tokens_mistral': 564, 'n_tokens_neox': 545, 'n_words': 101, 'path': 'example/env_render.ipynb', 'repo_name': 'joanofdart/openai', 'size': '1489'}