Giter Site home page Giter Site logo

retrowrapper's Introduction

retrowrapper

Build Status

Wrapper for OpenAI Retro envs for parallel execution

OpenAI's Retro exposes an OpenAI gym interface for Deep Reinforcement Learning, but unfortunately, their back-end only allows one emulator instance per process. To get around this, I wrote this class.

To Use

To use it, just instantiate it like you would a normal retro environment, and then treat it exactly the same, but now you can have multiples in a single python process. Magic!

import retrowrapper

if __name__ == "__main__":
    game = "SonicTheHedgehog-Genesis"
    state = "GreenHillZone.Act1"
    env1 = retrowrapper.RetroWrapper(game, state=state)
    env2 = retrowrapper.RetroWrapper(game, state=state)
    _obs = env1.reset()
    _obs = env2.reset()

    done = False
    while not done:
        action = env1.action_space.sample()
        _obs, _rew, done, _info = env1.step(action)
        env1.render()

        action = env2.action_space.sample()
        _obs, _rew, done, _info = env2.step(action)
        env2.render()

Using a custom make function

Sometimes you will need a custom make function, for example the retro_contest repository requires you to use their make function rather than retro.make.

In these cases you can use the retrowrapper.set_retro_make() to set a new make function.

Example usage:

import retrowrapper
from retro_contest.local import make

retrowrapper.set_retro_make( make )

env1 = retrowrapper.RetroWrapper(
    game='SonicTheHedgehog2-Genesis', 
    state='MetropolisZone.Act1'
)
env2 = retrowrapper.RetroWrapper(
    game='SonicTheHedgehog2-Genesis', 
    state='MetropolisZone.Act2'
)

retrowrapper's People

Contributors

maxstrange avatar frenchie4111 avatar cle-ros avatar n00b001 avatar

Watchers

James Cloos 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.