File size: 1,751 Bytes
804bb9c
c59c739
 
 
 
804bb9c
fece72b
1d19ab5
fece72b
 
804bb9c
 
c59c739
 
ae5c7a7
c59c739
 
 
ae5c7a7
c59c739
ae5c7a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c59c739
 
 
 
 
 
 
 
 
 
 
ae5c7a7
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
title: Tetris OpenEnv
emoji: 🎮
colorFrom: purple
colorTo: blue
sdk: docker
app_port: 8000
base_path: /play
tags:
  - openenv
---

# Tetris OpenEnv

A Tetris RL environment for LLM agent training, built on OpenEnv 0.2.1.

LLM agents receive a text-based board representation and must choose spatial actions (left, right, rotate, drop) to play Tetris. Features combo scoring where clearing multiple lines simultaneously gives disproportionately higher rewards.

## Problem Statement

**Wild Card (#5)** - Teaching LLMs spatial reasoning through Tetris. The agent must interpret a 2D text grid and plan piece placements, a fundamentally non-linguistic task solved through language.

## Quick Start

```python
from tetris_env import TetrisEnvClient, TetrisAction

with TetrisEnvClient(base_url="https://VortexedSquirrel-tetris-env.hf.space") as env:
    result = env.reset(seed=42)
    while not result.done:
        action = TetrisAction(action="drop")
        result = env.step(action)
        print(f"Reward: {result.reward}, Score: {result.observation.score}")
```

## Actions

| Action | Description |
|---|---|
| `left` | Move piece left |
| `right` | Move piece right |
| `rotate_cw` | Rotate clockwise |
| `rotate_ccw` | Rotate counter-clockwise |
| `drop` | Hard drop to bottom |
| `down` | Soft drop one row |
| `noop` | Do nothing |

## Reward Structure

| Lines Cleared | Reward | Multiplier |
|---|---|---|
| 1 | +100 | x1 |
| 2 | +300 | x3 |
| 3 | +700 | x7 |
| 4 (Tetris!) | +1500 | x15 |

Penalties: -1/step, -2*height, -5*holes, -500 game over.

## Built With

- [OpenEnv 0.2.1](https://github.com/meta-pytorch/OpenEnv) by Meta PyTorch
- Deployed on [Hugging Face Spaces](https://huggingface.co/spaces/VortexedSquirrel/tetris-env)