项目作者: MaxStrange

项目描述 :
Wrapper for OpenAI Retro envs for parallel execution
高级语言: Python
项目地址: git://github.com/MaxStrange/retrowrapper.git
创建时间: 2018-05-18T02:35:54Z
项目社区:https://github.com/MaxStrange/retrowrapper

开源协议:MIT License

下载


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!

  1. import retrowrapper
  2. if __name__ == "__main__":
  3. game = "SonicTheHedgehog-Genesis"
  4. state = "GreenHillZone.Act1"
  5. env1 = retrowrapper.RetroWrapper(game, state=state)
  6. env2 = retrowrapper.RetroWrapper(game, state=state)
  7. _obs = env1.reset()
  8. _obs = env2.reset()
  9. done = False
  10. while not done:
  11. action = env1.action_space.sample()
  12. _obs, _rew, done, _info = env1.step(action)
  13. env1.render()
  14. action = env2.action_space.sample()
  15. _obs, _rew, done, _info = env2.step(action)
  16. 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:

  1. import retrowrapper
  2. from retro_contest.local import make
  3. retrowrapper.set_retro_make( make )
  4. env1 = retrowrapper.RetroWrapper(
  5. game='SonicTheHedgehog2-Genesis',
  6. state='MetropolisZone.Act1'
  7. )
  8. env2 = retrowrapper.RetroWrapper(
  9. game='SonicTheHedgehog2-Genesis',
  10. state='MetropolisZone.Act2'
  11. )