From 5ab708331cd80e496c618ec4486aaa6fcf4a8d5b Mon Sep 17 00:00:00 2001 From: Maximilian Weichart Date: Wed, 11 Sep 2024 15:12:40 +0200 Subject: [PATCH] Update readme quickstart --- README.md | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d7422a5..965b429 100644 --- a/README.md +++ b/README.md @@ -16,18 +16,23 @@ Getting started with Tetris Gymnasium is straightforward. Here's an example to r actions: ```python +import cv2 import gymnasium as gym + from tetris_gymnasium.envs.tetris import Tetris -env = gym.make("tetris_gymnasium/Tetris", render_mode="human") -env.reset(seed=42) +if __name__ == "__main__": + env = gym.make("tetris_gymnasium/Tetris", render_mode="human") + env.reset(seed=42) + + terminated = False + while not terminated: + env.render() + action = env.action_space.sample() + observation, reward, terminated, truncated, info = env.step(action) + key = cv2.waitKey(100) # timeout to see the movement + print("Game Over!") -terminated = False -while not terminated: - env.render() - action = env.action_space.sample() - observation, reward, terminated, truncated, info = env.step(action) -print("Game Over!") ``` For more examples, e.g. training a DQN agent, please refer to the [examples](examples) directory.