Coder Social home page Coder Social logo

tornadomeet / gym Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openai/gym

0.0 2.0 0.0 1.37 MB

A toolkit for developing and comparing reinforcement learning algorithms.

Home Page: https://gym.openai.com/

License: MIT License

Makefile 0.03% Shell 0.05% Python 99.92%

gym's Introduction

gym

image

OpenAI Gym is a toolkit for developing and comparing reinforcement learning algorithms. This is the gym open-source library, which gives you access to an ever-growing variety of environments.

gym makes no assumptions about the structure of your agent, and is compatible with any numerical computation library, such as TensorFlow or Theano. You can use it from Python code, and soon from other languages.

If you're not sure where to start, we recommend beginning with the docs on our site.

A whitepaper for OpenAI Gym is available at http://arxiv.org/abs/1606.01540, and here's a BibTeX entry that you can use to cite it in a publication:

@misc{1606.01540,
    Author = {Greg Brockman and Vicki Cheung and Ludwig Pettersson and Jonas Schneider and John Schulman and Jie Tang and Wojciech Zaremba},
    Title = {OpenAI Gym},
    Year = {2016},
    Eprint = {arXiv:1606.01540},
}

Contents of this document

Basics

There are two basic concepts in reinforcement learning: the environment (namely, the outside world) and the agent (namely, the algorithm you are writing). The agent sends actions to the environment, and the environment replies with observations and rewards (that is, a score).

The core gym interface is Env, which is the unified environment interface. There is no interface for agents; that part is left to you. The following are the Env methods you should know:

  • `reset(self): Reset the environment's state. Returns `observation.
  • `step(self, action): Step the environment by one timestep. Returns `observation, reward, done, info.
  • `render(self, mode='human', close=False): Render one frame of the environment. The default mode will do something human friendly, such as pop up a window. Passing the `close flag signals the renderer to close any such windows.

Installation

You can perform a minimal install of gym with:

git clone https://github.com/openai/gym.git
cd gym
pip install -e .

If you prefer, you can do a minimal install of the packaged version directly from PyPI:

pip install gym

You'll be able to run a few environments right away:

We recommend playing with those environments at first, and then later installing the dependencies for the remaining environments.

Installing everything

To install the full set of environments, you'll need to have some system packages installed. We'll build out the list here over time; please let us know what you end up installing on your platform.

On OSX:

brew install cmake boost boost-python sdl2 swig wget

On Ubuntu 14.04:

apt-get install -y python-numpy python-dev cmake zlib1g-dev libjpeg-dev xvfb libav-tools xorg-dev python-opengl libboost-all-dev libsdl2-dev swig

MuJoCo has a proprietary dependency we can't set up for you. Follow the instructions in the mujoco-py package for help.

Once you're ready to install everything, run pip install -e '.[all]' (or pip install 'gym[all]').

Supported systems

We currently support Linux and OS X running Python 2.7 or 3.5. Python 3 support should still be considered experimental -- if you find any bugs, please report them!

In particular on OSX + Python3 you may need to run

brew install boost-python --with-python3

We will expand support to Windows based on demand. We will also soon ship a Docker container exposing the environments callable from any platform, for use with any non-Python framework, such as Torch.

Pip version

To run pip install -e '.[all]', you'll need a semi-recent pip. Please make sure your pip is at least at version 1.5.0. You can upgrade using the following: pip install --ignore-installed pip. Alternatively, you can open setup.py and install the dependencies by hand.

Rendering on a server

If you're trying to render video on a server, you'll need to connect a fake display. The easiest way to do this is by running under xvfb-run (on Ubuntu, install the xvfb package):

xvfb-run -s "-screen 0 1400x900x24" bash

Installing dependencies for specific environments

If you'd like to install the dependencies for only specific environments, see setup.py. We maintain the lists of dependencies on a per-environment group basis.

Environments

The code for each environment group is housed in its own subdirectory gym/envs. The specification of each task is in gym/envs/__init__.py. It's worth browsing through both.

Algorithmic

These are a variety of algorithmic tasks, such as learning to copy a sequence.

Atari

The Atari environments are a variety of Atari video games. If you didn't do the full install, you can install dependencies via pip install -e '.[atari]' (you'll need cmake installed) and then get started as follow:

This will install atari-py, which automatically compiles the Arcade Learning Environment. This can take quite a while (a few minutes on a decent laptop), so just be prepared.

Board games

The board game environments are a variety of board games. If you didn't do the full install, you can install dependencies via pip install -e '.[board_game]' (you'll need cmake installed) and then get started as follow:

Box2d

Box2d is a 2D physics engine. You can install it via pip install -e '.[box2d]' and then get started as follow:

Classic control

These are a variety of classic control tasks, which would appear in a typical reinforcement learning textbook. If you didn't do the full install, you will need to run pip install -e '.[classic_control]' to enable rendering. You can get started with them via:

Doom

These tasks take place inside a Doom game (via the VizDoom project). If you didn't do the full install, you will need to run pip install -e '.[doom]'. You can get started with them via:

MuJoCo

MuJoCo is a physics engine which can do very detailed efficient simulations with contacts. It's not open-source, so you'll have to follow the instructions in mujoco-py to set it up. You'll have to also run pip install -e '.[mujoco]' if you didn't do the full install.

Toy text

Toy environments which are text-based. There's no extra dependency to install, so to get started, you can just do:

Examples

See the examples directory.

Testing

We are using nose2 for tests. You can run them via:

nose2

You can also run tests in a specific directory by using the -s option, or by passing in the specific name of the test. See the nose2 docs for more details.

What's new

  • 2016-05-28: For controlled reproducibility, envs now support seeding (cf #91 and #135). The monitor records which seeds are used. We will soon add seed information to the display on the scoreboard.

gym's People

Contributors

botev avatar bshall avatar caktux avatar carpedm20 avatar danlangford avatar dribnet avatar gdb avatar hojonathanho avatar iaroslav-ai avatar jietang avatar jkcooper2 avatar jonasschneider avatar joschu avatar joshmarlow avatar justheuristic avatar machinaut avatar maciejgryka avatar mbz avatar olegklimov avatar openai-sys-okta-integration avatar pawni avatar ppaquette avatar rafaelcosman avatar salvatoret avatar sherjilozair avatar shubham1810 avatar shushen avatar tambetm avatar tlbtlbtlb avatar wojzaremba avatar

Watchers

 avatar  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.