Report Bug · Request Feature · Suggestions
🟥 Simplified Tetris environments compliant with OpenAI Gym's API
Gym-SimplifiedTetris is a pip installable package that creates simplified Tetris environments compliant with OpenAI Gym's API. Currently, Gym's API is the field standard for developing and comparing reinforcement learning algorithms.
The environments implemented in this package are simplified because the player must select the column and piece's rotation before the piece is dropped vertically downwards. If one looks at the previous approaches to the game of Tetris, most of them use this simplified setting.
The package is pip installable:
pip install gym-simplifiedtetris
Or, you can copy the repository by forking it and then downloading it using:
git clone https://github.com/<YOUR-USERNAME>/gym-simplifiedtetris
Packages can be installed using pip:
cd gym-simplifiedtetris
pip install -r requirements.txt
The file examples.py shows two examples of using an instance of the simplifiedtetris-binary-20x10-4-v0
environment for ten games. You can create an environment using gym.make
, supplying the environment's ID as an argument.
import gym
import gym_simplifiedtetris
env = gym.make("simplifiedtetris-binary-20x10-4-v0")
obs = env.reset()
# Run 10 games of Tetris, selecting actions uniformly at random.
episode_num = 0
while episode_num < 10:
env.render()
action = env.action_space.sample()
obs, reward, done, info = env.step(action)
if done:
print(f"Episode {episode_num + 1} has terminated.")
episode_num += 1
obs = env.reset()
env.close()
Alternatively, you can import the environment directly:
from gym_simplifiedtetris.envs import SimplifiedTetrisBinaryEnv as Tetris
env = Tetris(grid_dims=(20, 10), piece_size=4)
Three agents — described in gym_simplifiedtetris/agents — are provided. There are currently 64 environments provided; a description can be found in gym_simplifiedtetris/envs.
- Normalise the observation spaces
- Implement an action space that only permits non-terminal actions to be taken
- Implement more shaping rewards: potential-style, potential-based, dynamic potential-based, and non-potential. Optimise their weights using an optimisation algorithm.
This package utilises several methods from the codebase developed by andreanlay (2020) and the codebase developed by Benjscho (2021).