Skip to main content

Super Mario Bros. for OpenAI Gym

Project description


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.


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

pip install gym-zelda-1



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/ 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())


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`>


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

Reward Function


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"}


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

  author = {Christian Kauten},
  title = {{The Legend of Zelda} for {OpenAI Gym}},
  year = {2019},
  publisher = {GitHub},
  howpublished = {\url{}},

Project details

Download files

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

Source Distribution

gym_zelda_1-0.0.0.tar.gz (75.5 kB view hashes)

Uploaded Source

Built Distribution

gym_zelda_1-0.0.0-py2.py3-none-any.whl (73.8 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page