Skip to main content

Super Mario Bros. for OpenAI Gym

Project description

gym-zelda-1

BuildStatus PackageVersion PythonVersion Stable Format License

An OpenAI Gym environment for The Legend of Zelda (i.e., Zelda 1) on The Nintendo Entertainment System (NES) based on the nes-py emulator.

Installation

The preferred installation of gym-zelda-1 is from pip:

pip install gym-zelda-1

Usage

Python

You must import gym_zelda_1 before trying to make an environment. This is because gym environments are registered at runtime. By default, gym_zelda_1 environments use the full NES action space of 256 discrete actions. To contstrain this, gym_zelda_1.actions provides three actions lists (RIGHT_ONLY, SIMPLE_MOVEMENT, and COMPLEX_MOVEMENT) for the nes_py.wrappers.BinarySpaceToDiscreteSpaceEnv wrapper. See gym_zelda_1/actions.py for a breakdown of the legal actions in each of these three lists.

from nes_py.wrappers import BinarySpaceToDiscreteSpaceEnv
import gym_zelda_1
from gym_zelda_1.actions import SIMPLE_MOVEMENT
env = gym_zelda_1.make('Zelda1-v0')
env = BinarySpaceToDiscreteSpaceEnv(env, SIMPLE_MOVEMENT)

done = True
for step in range(5000):
    if done:
        state = env.reset()
    state, reward, done, info = env.step(env.action_space.sample())
    env.render()

env.close()

NOTE: gym_zelda_1.make is just an alias to gym.make for convenience.

NOTE: remove calls to render in training code for a nontrivial speedup.

Command Line

gym_zelda_1 features a command line interface for playing environments using either the keyboard, or uniform random movement.

gym_zelda_1 -m <`human` or `random`>

Step

Info about the rewards and info returned by the step method.

Reward Function

TODO

info dictionary

The info dictionary returned by the step method contains the following keys:

Key Type Description
x_pos int Link's x position in the screen (from the left)
y_pos int Link's y position in the screen (from the top)
direction str Link's direction as one of {"N", "S", "E", "W"}

Citation

Please cite gym-zelda-1 if you use it in your research.

@misc{gym-zelda-1,
  author = {Christian Kauten},
  title = {{The Legend of Zelda} for {OpenAI Gym}},
  year = {2019},
  publisher = {GitHub},
  howpublished = {\url{https://github.com/Kautenja/gym-zelda-1}},
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for gym-zelda-1, version 0.0.0
Filename, size File type Python version Upload date Hashes
Filename, size gym_zelda_1-0.0.0.tar.gz (75.5 kB) File type Source Python version None Upload date Hashes View
Filename, size gym_zelda_1-0.0.0-py2.py3-none-any.whl (73.8 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page