Skip to main content

Super Mario Bros. for OpenAI Gym

Project description

gym-super-mario-bros

PackageVersion PythonVersion Stable Format License

Mario

An OpenAI Gym environment for Super Mario Bros. & Super Mario Bros. 2 (Lost Levels) on The Nintendo Entertainment System (NES).

Installation

The preferred installation of gym-super-mario-bros is from pip:

pip install gym-super-mario-bros

NES Emulator

gym-super-mario-bros uses FCEUX to emulate NES games. Make sure it's installed and in your $PATH.

Unix

sudo apt-get install fceux

Mac

brew install fceux

Usage

Python

You must import gym_super_mario_bros before trying to make an environment. This is because gym environments are registered at runtime.

import gym_super_mario_bros
env = gym_super_mario_bros.make('SuperMarioBros-v0')

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

env.close()

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

Command Line

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

gym_super_mario_bros -e <the environment ID to play> -m <`human` or `random`>

NOTE: by default, -e is set to SuperMarioBros-v0 and -m is set to human.

Environments

These environments allow 3 attempts (lives) to make it through the 32 levels of the game. The environments only send reward-able game-play frames to agents; No cut-scenes, loading screens, etc. are sent from the NES emulator to an agent nor can an agent perform actions during these occurrences. If a cut-scene is not able to be skipped by hacking the NES's RAM, the environment will lock the Python process until the emulator is ready for the next action.

Environment Game Frameskip ROM Screenshot
SuperMarioBros-v0 SMB 4 standard
SuperMarioBros-v1 SMB 4 downsample
SuperMarioBros-v2 SMB 4 pixel
SuperMarioBros-v3 SMB 4 rectangle
SuperMarioBrosNoFrameskip-v0 SMB 1 standard
SuperMarioBrosNoFrameskip-v1 SMB 1 downsample
SuperMarioBrosNoFrameskip-v2 SMB 1 pixel
SuperMarioBrosNoFrameskip-v3 SMB 1 rectangle
SuperMarioBros2-v0 SMB2 4 standard
SuperMarioBros2-v1 SMB2 4 downsample
SuperMarioBros2NoFrameskip-v0 SMB2 1 standard
SuperMarioBros2NoFrameskip-v1 SMB2 1 downsample

Individual Levels

These environments allow a single attempt (life) to make it through a single level of the game.

Use the template

SuperMarioBros-<world>-<level>-v<version>

where:

  • <world> is a number in {1, 2, 3, 4, 5, 6, 7, 8} indicating the world
  • <level> is a number in {1, 2, 3, 4} indicating the level within a world
  • <version> is a number in {0, 1, 2, 3} specifying the ROM mode to use
    • 0: standard ROM
    • 1: downsampled ROM
    • 2: pixel ROM
    • 3: rectangle ROM
  • NoFrameskip can be added before the first hyphen to disable frame skip

For example, to play 4-2 on the downsampled ROM, you would use the environment id SuperMarioBros-4-2-v1. To disable frame skip you would use SuperMarioBrosNoFrameskip-4-2-v1.

Citation

Please cite gym-super-mario-bros if you use it in your research.

@misc{gym-super-mario-bros,
  author = {Christian Kauten},
  title = {{S}uper {M}ario {B}ros for {O}pen{AI} {G}ym},
  year = {2018},
  publisher = {GitHub},
  howpublished = {\url{https://github.com/Kautenja/gym-super-mario-bros}},
}

Project details


Release history Release notifications | RSS feed

This version

2.0.0

Download files

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

Source Distribution

gym_super_mario_bros-2.0.0.tar.gz (202.2 kB view details)

Uploaded Source

Built Distribution

gym_super_mario_bros-2.0.0-py3-none-any.whl (207.1 kB view details)

Uploaded Python 3

File details

Details for the file gym_super_mario_bros-2.0.0.tar.gz.

File metadata

File hashes

Hashes for gym_super_mario_bros-2.0.0.tar.gz
Algorithm Hash digest
SHA256 9a56d63c019c71e9f40526af48883d518ced51c7dcb0fc863b41e3c7e87b1bd5
MD5 462d6a8f4b3911132aec81dbd95f4f96
BLAKE2b-256 f79ec80bba326b69b43e13cae42a4812a56ce4b77584b3ebd8caf2baa0a9f6ef

See more details on using hashes here.

File details

Details for the file gym_super_mario_bros-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gym_super_mario_bros-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 925fcccde2204b178dc2378757eab49fc9f20d916f7b34bd11b69aba1cf6d295
MD5 f8481074a7b1ef01c913bd61999b1652
BLAKE2b-256 6a2824f5e6682760943ce3c34ae2d2554a7a3eb1eacc1ba407e23b1e9e884b45

See more details on using hashes here.

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