Super Mario Bros. for OpenAI Gym
Project description
gym-zelda-1
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 constrain this, gym_zelda_1.actions provides
an action list called MOVEMENT (20 discrete actions) for the
nes_py.wrappers.JoypadSpace wrapper.
from nes_py.wrappers import JoypadSpace
import gym_zelda_1
from gym_zelda_1.actions import MOVEMENT
env = gym_zelda_1.make('Zelda1-v0')
env = JoypadSpace(env, 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: The reward function is a complicated work in progress.
info dictionary
The info dictionary returned by the step method contains the following
keys:
| Key | Type | Description |
|---|---|---|
current_level |
int |
The current level Link is in (0 for overworld) |
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"} |
has_candled |
bool |
Whether Link has candled the current room |
pulse_1 |
str |
The signal playing through pulse 1 |
pulse_2 |
str |
The signal playing through pulse 2 |
killed_enemies |
int |
The number of enemies killed |
number_of_deaths |
int |
The number of times Link has died |
sword |
str |
The kind of sword Link has |
number_of_bombs |
int |
The number of bombs in Link's inventory |
arrows_type |
str |
The kind of arrows in Link's inventory |
has_bow |
bool |
Whether Link has the bow in his inventory |
candle_type |
str |
The type of candle in Link's inventory |
has_whistle |
bool |
Whether Link has the whistle in his inventory |
has_food |
bool |
Whether Link has food in his inventory |
potion_type |
str |
The type of potion in Link's inventory |
has_magic_rod |
bool |
Whether Link has the magic rod in his inventory |
has_raft |
bool |
Whether Link has the raft in his inventory |
has_magic_book |
bool |
Whether Link has the magic book in his inventory |
ring_type |
str |
The type of ring in Link's inventory |
has_step_ladder |
bool |
Whether Link has the step ladder in his inventory |
has_magic_key |
bool |
Whether Link has the magic key in his inventory |
has_power_bracelet |
bool |
Whether Link has the power bracelet in his inventory |
has_letter |
bool |
Whether Link has the letter in his inventory |
is_clock_possessed |
bool |
Whether the clock is possessed |
rupees |
int |
The number of rupess Link has collected |
keys |
int |
The number of keys in Link's inventory |
heart_containers |
int |
The number of heart containers that Link has |
hearts |
float |
The number of remaining health Link has |
has_boomerang |
bool |
Whether Link has the boomerang in his inventory |
has_magic_boomerang |
bool |
Whether Link has the magic boomerang in his inventory |
has_magic_shield |
bool |
Whether Link has the magic shield in his inventory |
max_number_of_bombs |
int |
The maximum number of bombs Link can carry |
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}},
}
References
The following references contributed to the construction of this project.
- The Legend of Zelda: RAM Map. Data Crystal ROM Hacking.
- The Legend of Zelda: Memory Addresses. NES Hacker.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gym_zelda_1-0.2.2.tar.gz.
File metadata
- Download URL: gym_zelda_1-0.2.2.tar.gz
- Upload date:
- Size: 77.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48d9a736072c60e2ca123a7f71b5f7de1b2fcb301a5b229e61b0d5c115b29fee
|
|
| MD5 |
9af41d26b1b45e9ce9490e3258c6edbf
|
|
| BLAKE2b-256 |
d9d624393b735a5627c478292ee0db5811bf673cd1674683dc20c95c68cd907b
|
File details
Details for the file gym_zelda_1-0.2.2-py2.py3-none-any.whl.
File metadata
- Download URL: gym_zelda_1-0.2.2-py2.py3-none-any.whl
- Upload date:
- Size: 75.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa13831b57f2bfafdeddd032d68ff2a35989256dd32af5f7edf2768f1a0db19a
|
|
| MD5 |
5ad4abee92d3aa15c2375e47f9cc8994
|
|
| BLAKE2b-256 |
169afa3c256620efcb1cde9992471d47cf903b7fdaf5bb962ac5918bcf31a210
|