Bitboard version of Tetris AI
Organizations: School of Computer Science, Nanjing University of Posts and Telecommunications, Nanjing, Jiangsu, 210023, China
Abstract
The efficiency of game engines and policy optimization algorithms is crucial for training reinforcement learning (RL) agents in complex sequential decision-making tasks, such as Tetris. Existing Tetris implementations suffer from low simulation speeds, suboptimal state evaluation, and inefficient training paradigms, limiting their utility for large-scale RL research. To address these limitations, this paper proposes a high-performance Tetris AI framework based on bitboard optimization and improved RL algorithms. First, we redesign the Tetris game board and tetrominoes using bitboard representations, leveraging bitwise operations to accelerate core processes (e.g., collision detection, line clearing, and Dellacherie-Thiery Features extraction) and achieve a 53-fold speedup compared to OpenAI Gym-Tetris. Second, we introduce an afterstate-evaluating actor network that simplifies state value estimation by leveraging Tetris afterstate property, outperforming traditional action-value networks with fewer parameters. Third, we propose a buffer-optimized Proximal Policy Optimization (PPO) algorithm that balances sampling and update efficiency, achieving an average score of 3,829 on 10x10 grids within 3 minutes. Additionally, we develop a Python-Java interface compliant with the OpenAI Gym standard, enabling seamless integration with modern RL frameworks. Experimental results demonstrate that our framework enhances Tetris's utility as an RL benchmark by bridging low-level bitboard optimizations with high-level AI strategies, providing a sample-efficient and computationally lightweight solution for scalable sequential decision-making research.
Figures & tables
| Method | Avg. Removed Lines | Training Samples | Feature | Generator |
| BCTS Thiery and Scherrer (2009a) | 3,000 | DT features | Random | |
| CBMPI Gabillon et al. (2013) ; Scherrer et al. (2015) | 4,300 | DT features + RBF heights | Random | |
| dSiLU-TD( ) Elfwing et al. (2018) | 4,900 | 200,000 | Bertsekas features + neural networks | Random |
| STEW Lichtenberg and Şimşek (2019) | 4,800 | 238,000 | DT features | 7-Bag random |
| Buffered PPO (Ours) | 3,850 | 61,440 | DT features | Random |
| Feature | DT-10 weight | DT-20 weight |
| Landing height | -2.18 | -2.68 |
| Eroded piece cells | 2.42 | 1.38 |
| Row transitions | -2.17 | -2.41 |
| Column transitions | -3.31 | -6.32 |
| Holes | 0.95 | 2.03 |
| Board well | -2.22 | -2.71 |
| Board Size | Weights | Gabillon et al. (2013) Gabillon et al. (2013) | Our bitboard impl |
| 10 10(10,000 games) | DT-10 | 5,000(-) | 5,152.02(5,137.51) |
| DT-20 | 4,300(-) | 4,188.61(4,153.42) | |
| 10 20(10 games) | DT-10 | 29,000,000(-) | 54,377,543(54,353,156) |
| DT-20 | 51,000,000(-) | 75,093,204(65,000,224) |
| Implementation | Time for 10,000 samples |
| OpenAI Gym Kauten (2019) | 12.92 seconds |
| Bitboard Tetris (ours) | 0.24 seconds |
| Bitboard Tetris via Python (ours) | 0.59 seconds |
| Param | Value | Param | Value | Param | Value |
| 0.99 | 0.5 | 3e-4 | |||
| 0.99 | 0.00025 | 3e-4 | |||
| 10 | 0.1 | 12,500 |
| Parameter | Value | Parameter | Value | Parameter | Value |
| 0.99 | 0.2 | 2,048 | |||
| 0.99 | 3e-4 | 256 | |||
| 10 | 3e-4 | 61,440 |
| Algorithm | Sampling | Policy Updates | Total | Update Ratio |
| Trajectory PPO | 10,536s | 436s | 10,972s | 3.97% |
| Buffer PPO | 112s | 54s | 166s | 32.53% |
| Algorithm | Total Steps | Avg. Converged Score |
| Trajectory PPO | 69,046,726 | 3,840.30 |
| Buffer PPO (optimized) | 61,440 | 3,829.04 |
| Feature | Weight |
| Landing height | -0.51 |
| Eroded piece cells | 0.16 |
| Row transitions | -0.40 |
| Column transitions | -0.75 |
| Holes | -0.18 |
| Board well | -0.39 |
| Algorithm | Score |
| Trajectory PPO | 32,110,545.18(30,425,374.19) |
| Buffer PPO | 13,936,917.72(13,198,381.24) |
| Block Generation Rule | CBMPI | Trajectory PPO | Buffer PPO |
| Random (Baseline) | 4,300 | 4,965.44 (4884.14) | 3,590.90 (3545.05) |
| 7-Bag | 251,501.20 | 173,489.37 (177,212.68) | 198,206.23 (198,903.07) |
| Adversarial Sequence | 75 | 34(0) | 53(0) |
Game-Playing Agents
Game-playing agents use search, learning, and reasoning to choose actions in games with strategic, uncertain, or changing environments.
See all 200 papers