Git Product home page Git Product logo

gym3's Introduction

Status: Maintenance (expect bug fixes and minor updates)

gym3

gym3 provides a unified interface for reinforcement learning environments that improves upon the gym interface and includes vectorization, which is invaluable for performance. gym3 is just the interface and associated tools, and includes no environments beyond some simple testing environments.

gym3 is used internally inside OpenAI and is released here primarily for use by OpenAI environments. External users should likely use gym.

Supported platforms:

  • Windows
  • macOS
  • Linux

Supported Pythons:

  • >=3.6

Installation:

pip install gym3

Overview

gym3.Env is similar to combining multiple gym.Env environments into a single environment, with automatic reset when episodes are complete.

A gym3 random agent looks like this (run pip install --upgrade procgen to get the environment):

import gym3
from procgen import ProcgenGym3Env
env = ProcgenGym3Env(num=2, env_name="coinrun")
step = 0
while True:
    env.act(gym3.types_np.sample(env.ac_space, bshape=(env.num,)))
    rew, obs, first = env.observe()
    print(f"step {step} reward {rew} first {first}")
    step += 1

To visualize what the agent is doing:

import gym3
from procgen import ProcgenGym3Env
env = ProcgenGym3Env(num=2, env_name="coinrun", render_mode="rgb_array")
env = gym3.ViewerWrapper(env, info_key="rgb")
step = 0
while True:
    env.act(gym3.types_np.sample(env.ac_space, bshape=(env.num,)))
    rew, obs, first = env.observe()
    print(f"step {step} reward {rew} first {first}")
    step += 1

A command line example is included under scripts:

python -m gym3.scripts.random_agent --fn_path procgen:ProcgenGym3Env --env_name coinrun --render_mode rgb_array

The observations and actions can be either arrays, or "trees" of arrays, where a tree is a (potentially nested) dictionary with string keys. gym3 includes a handy function, gym3.types.multimap for mapping functions over trees, as well as a number of utilities in gym3.types_np that produce trees numpy arrays from space objects, such as types_np.sample() seen above.

Compatibility with existing gym environments is provided as well:

import gym3
env = gym3.vectorize_gym(num=2, render_mode="human", env_kwargs={"id": "CartPole-v0"})
step = 0
while True:
    env.act(gym3.types_np.sample(env.ac_space, bshape=(env.num,)))
    rew, obs, first = env.observe()
    print(f"step {step} reward {rew} first {first}")
    step += 1

Documentation

Example Environments

  • Example Gridworld - Simple gridworld where you observe the state directly
  • Computer Tennis - Clone of the game "Pong" where you observe pixels. Renders with Cairo or OpenGL headless (no X server required)
  • libenv_fixedseq.c - Example environment using the libenv C API. For a full C++ environment that uses this interface, see Procgen Benchmark

Changelog

See CHANGES for changes present in each release.

Contributing

See CONTRIBUTING for information on contributing.

gym3's People

Contributors

christopherhesse avatar jyotishp avatar mtrazzi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.