All Projects → Kautenja → gym-tetris

Kautenja / gym-tetris

Licence: other
An OpenAI Gym interface to Tetris on the NES.

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to gym-tetris

tetris
Html5 tetris game, supports two players. 支持本地双人对战的html5俄罗斯方块游戏.
Stars: ✭ 13 (-60.61%)
Mutual labels:  tetris
sh-tetris
The pure shell script (sh) that implements the Tetris game following the Tetris Guideline (2009).
Stars: ✭ 31 (-6.06%)
Mutual labels:  tetris
mobx-react-tetris
No description or website provided.
Stars: ✭ 30 (-9.09%)
Mutual labels:  tetris
gym-mtsim
A general-purpose, flexible, and easy-to-use simulator alongside an OpenAI Gym trading environment for MetaTrader 5 trading platform (Approved by OpenAI Gym)
Stars: ✭ 196 (+493.94%)
Mutual labels:  openai-gym
go-tetris
Golang Tetris for console window with optional AI
Stars: ✭ 67 (+103.03%)
Mutual labels:  tetris
rl trading
No description or website provided.
Stars: ✭ 14 (-57.58%)
Mutual labels:  openai-gym
TetrisAI
The old school Tetris game in addition with an AI that learns evolutionary how to play this game
Stars: ✭ 24 (-27.27%)
Mutual labels:  tetris
Tetromino
One of my favorite games implemented for iOS, macOS + CLI
Stars: ✭ 17 (-48.48%)
Mutual labels:  tetris
iroko
A platform to test reinforcement learning policies in the datacenter setting.
Stars: ✭ 55 (+66.67%)
Mutual labels:  openai-gym
pong-from-pixels
Training a Neural Network to play Pong from pixels
Stars: ✭ 25 (-24.24%)
Mutual labels:  openai-gym
UnityTetris
Tetris clone written in C# and using Unity engine to render.
Stars: ✭ 131 (+296.97%)
Mutual labels:  tetris
gym-R
An R package providing access to the OpenAI Gym API
Stars: ✭ 21 (-36.36%)
Mutual labels:  openai-gym
gym-cartpole-swingup
A simple, continuous-control environment for OpenAI Gym
Stars: ✭ 20 (-39.39%)
Mutual labels:  openai-gym
robo-gym-robot-servers
Repository containing Robot Servers ROS packages
Stars: ✭ 25 (-24.24%)
Mutual labels:  openai-gym
bark-ml
Gym environments and agents for autonomous driving.
Stars: ✭ 68 (+106.06%)
Mutual labels:  openai-gym
mario
Super Mario Reinforcement Learning from Demonstration
Stars: ✭ 25 (-24.24%)
Mutual labels:  openai-gym
nelua-tetris
Tetris game clone made in Nelua with Raylib
Stars: ✭ 16 (-51.52%)
Mutual labels:  tetris
python-tetris
Tetris game with AI made by pygame, inspired by react-tetris
Stars: ✭ 19 (-42.42%)
Mutual labels:  tetris
Deep-Reinforcement-Learning-for-Automated-Stock-Trading-Ensemble-Strategy-ICAIF-2020
Live Trading. Please star.
Stars: ✭ 1,251 (+3690.91%)
Mutual labels:  openai-gym
RustTetris
Tetris Made in Rust and SDL2
Stars: ✭ 18 (-45.45%)
Mutual labels:  tetris

gym-tetris

BuildStatus PackageVersion PythonVersion Stable Format License

An OpenAI Gym environment for Tetris on The Nintendo Entertainment System (NES) based on the nes-py emulator.

Installation

The preferred installation of gym-tetris is from pip:

pip install gym-tetris

Usage

Python

You must import gym_tetris before trying to make an environment. This is because gym environments are registered at runtime. By default, gym_tetris environments use the full NES action space of 256 discrete actions. To constrain this, gym_tetris.actions provides an action list called MOVEMENT (20 discrete actions) for the nes_py.wrappers.JoypadSpace wrapper. There is also SIMPLE_MOVEMENT with a reduced action space (6 actions). For exact details, see gym_tetris/actions.py.

from nes_py.wrappers import JoypadSpace
import gym_tetris
from gym_tetris.actions import MOVEMENT

env = gym_tetris.make('TetrisA-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_tetris.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_tetris features a command line interface for playing environments using either the keyboard, or uniform random movement.

gym_tetris -e <environment ID> -m <`human` or `random`>

Environments

There are two game modes define in NES Tetris, namely, A-type and B-type. A-type is the standard endurance Tetris game and B-type is an arcade style mode where the agent must clear a certain number of lines to win. There are three potential reward streams: (1) the change in score, (2) the change in number of lines cleared, and (3) a penalty for an increase in board height. The table below defines the available environments in terms of the game mode (i.e., A-type or B-type) and the rewards applied.

Environment Game Mode reward score reward lines penalize height
TetrisA-v0 A-type
TetrisA-v1 A-type
TetrisA-v2 A-type
TetrisA-v3 A-type
TetrisB-v0 B-type
TetrisB-v1 B-type
TetrisB-v2 B-type
TetrisB-v3 B-type

info dictionary

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

Key Type Description
current_piece str the current piece as a string
number_of_lines int the number of cleared lines in [0, 999]
score int the current score of the game in [0, 999999]
next_piece str the next piece on deck as a string
statistics dict the number of tetriminos dispatched (by type)
board_height int the height of the board in [0, 20]

Citation

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

@misc{gym-tetris,
  author = {Christian Kauten},
  howpublished = {GitHub},
  title = {{Tetris (NES)} for {OpenAI Gym}},
  URL = {https://github.com/Kautenja/gym-tetris},
  year = {2019},
}

References

The following references contributed to the construction of this project.

  1. Tetris (NES): RAM Map. Data Crystal ROM Hacking.
  2. Tetris: Memory Addresses. NES Hacker.
  3. Applying Artificial Intelligence to Nintendo Tetris. MeatFighter.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].