ISSAI FRP 2026 · AI Engineering

Can a small RL agent beat a hand-written Tetris player under execution noise?

Erkenzhe
FRP 2026, AI Engineering track · ISSAI, Nazarbayev University

The research repository with training code, checkpoints and raw logs remains private. The public repository contains this static page and the replay viewer.

Screenshot of the side-by-side Tetris replay viewer with two boards, score counters and noise controls.
The interactive viewer replays recorded C++ engine simulations side by side. It is not live neural-network inference.

In one sentence: a compact afterstate RL agent beats a hand-written Tetris heuristic at clean play (797.8 vs 740.4 mean lines), but training with 10% execution noise did not make it robust at test time, and the rule used to select moves under a noise model can shift measured performance by tens of lines.

797.8best clean mean lines, Lines RL at 0% noise; 20 seeds, 800-line cap
740.4mean lines for the hand-written RulesAgent at 0% noise
46.0 vs 38.9lines at 10% test noise: clean-trained vs noise-trained Lines RL
+60.2largest expected-selection gain in Study 2: clean Combo RL at 5% noise, 95% CI 29.0–91.2 lines

The problem

Tetris is a sequential decision problem with a huge branching factor. A hand-written heuristic that scores holes, height and surface bumpiness is a strong and cheap baseline. Reinforcement learning should be able to improve on it, but a high score in a clean simulator can hide two weaknesses: the policy may not beat a good heuristic, and the score may depend on perfect execution.

We study both questions with a small, reproducible setup. The first benchmark, Study 1, evaluates five agents on held-out seeds under the original intended-placement protocol. The second, Study 2, asks a different question on fresh seeds: when the simulator applies execution noise, should the agent choose the move with the best clean value, or the move with the best expected value under the noise model? The two studies are reported separately because they answer different questions.

How it works

1. EngineC++ Tetris with seeded pieces
2. Placementsenumerate legal afterstates
3. Featuresfour compact board features
4. Network4 → 64 → 64 → 1 value
5. Noisetrain and select under shifts

The environment is a C++ 10×20 Tetris engine with the seven standard tetrominoes, a seeded piece sequence and a 2,000-piece cap (800 lines). Python calls into it through a small interface for reset, legal placements, afterstate preview and step. The agent scores every legal placement with four features: cleared lines divided by 4, holes divided by 40, the sum of column heights divided by 200, and surface bumpiness divided by 100.

The value network is deliberately small: 4 inputs, two hidden layers of 64 units and one output. Training uses afterstate temporal-difference updates, a discount factor of 0.99, a replay buffer of 50,000 transitions, batches of 256, Adam at 1e-3 and a target network copied every 500 steps. Exploration is epsilon-greedy. The clean-trained agents use no execution noise. The noise-trained agents use 10% training noise and expected-value targets and selection.

Execution noise models a failed or blocked shift: with probability p, the intended horizontal shift is replaced by a one-column shift left or right with probability p/2; if that shift is blocked by the wall or a stack, the intended placement is kept. This is intentionally simpler than real input latency, rotation errors or dropped pieces. The distinction between Qint and Qexp is the core of the second study.

Architecture diagram showing the C++ Tetris engine, Python agent, afterstate features, value network and evaluation loop.
System pipeline: a deterministic C++ engine exposes legal placements to a compact Python afterstate value network. Noise is injected at execution time, not in the piece generator.

The five evaluated agents

RulesAgentHand-coded linear heuristic. No learning. Baseline.
Lines RL · 0%Lines reward, clean training, intended selection.
Combo RL · 0%Tetris scoring plus combo bonus, clean training.
Lines RL · 10%Lines reward, 10% training noise, expected selection.
Combo RL · 10%Combo reward, 10% training noise, expected selection.

All four RL agents share the same network, optimizer and wall-clock budget. RandomAgent is not part of the five-agent comparison.

What we found

Clean play

RL beats the heuristic

The best clean agent reaches 797.8 mean lines, 57.4 lines above RulesAgent’s 740.4. Both clean-trained RL agents are close to the 800-line cap.

Robustness

Noise training is not a free fix

At 10% test noise, clean-trained agents score 46.0 and 47.3 lines, while the noise-trained agents score 38.9. At 5% the gap is much larger.

Reward design

Combo changes style

At 0% noise Combo RL earns 110,145 points versus 93,980 for Lines RL with almost the same number of lines, and it uses a different mix of line clears.

Selection

The evaluation rule matters

In Study 2, choosing the move with the best expected noisy value can add 60.2 lines at 5% noise, but the effect is not uniform and does not replicate every Study 1 pattern.

Study 1: the original five-agent benchmark

Mean lines over 20 held-out seeds. At 0% noise each agent plays one game per seed; at each positive rate each agent plays five noise streams per seed (100 games per agent per positive rate). 1,600 games in total. Higher is better. The cap is 800 lines.
Agent0% noise5% noise10% noise20% noise
RulesAgent740.490.139.814.3
Lines RL · 0% training797.8165.446.013.4
Combo RL · 0% training796.6140.447.313.1
Lines RL · 10% training797.6103.938.913.4
Combo RL · 10% training765.9105.138.912.7

The clean-trained agents beat the noise-trained agents at 10% test noise by 7.1 lines for the lines reward (95% CI 2.7–11.2) and 8.4 lines for the combo reward (3.1–15.0). At 5% the gaps are 61.5 and 35.3 lines. The noise-trained agents also used about 35% fewer training pieces under the same wall-clock budget (81k and 79k versus 121k and 128k), so training budget is a confound. At 20% every agent collapses to 12.7–14.3 lines.

Study 2: intended vs expected selection on fresh seeds

Study 2 does not retrain anything. It takes the four trained RL agents and evaluates them on seeds 7100–7119 with the same execution-noise model, comparing intended selection Qint with expected selection Qexp. The table shows paired mean differences in favor of expected selection; positive values mean the expected-value rule scores higher under the evaluation noise. This study has no RulesAgent baseline and is not a full replication of Study 1.

Fresh-seed paired differences: expected selection minus intended selection, in mean lines, with 95% paired bootstrap intervals where reported. 2,560 games over 20 seeds and four models.
ModelNoiseDifference in mean lines95% interval
Combo RL · 0% training5%+60.2+29.0 to +91.2
Combo RL · 10% training5%+25.4+10.5 to +39.3
Lines RL · 0% training5%+25.2−21.0 to +67.7
Lines RL · 10% training5%+15.4−3.5 to +35.4
Lines RL · 10% training10%+11.9+5.4 to +18.6
Lines RL · 0% training20%−3.7−5.7 to −1.9

The other 10% and 20% cells were small and uncertain. Two positive post-hoc results from Study 1 did not replicate in Study 2. The safest conclusion is conditional: expected selection can help a lot when the clean policy is badly mismatched to the noise, but it is not a universal improvement and can hurt at high noise.

Plot of expected-minus-intended selection effect across noise rates and agents, with 95% intervals.
Expected-minus-intended selection effect in the fresh-seed study. Positive values mean expected selection scores more lines under the evaluation noise model; intervals crossing zero are uncertain.

What the numbers mean

Interactive replay viewer

Screenshot of the replay viewer showing a 10% noise comparison, intended-placement ghosts and error navigation buttons.
A recorded 10% noise comparison. The gold ghost is the intended placement; the solid piece is where the shift actually landed.

The viewer has three comparison presets: Original vs Combo at 0% noise, Lines clean vs noise-trained at 10%, and Combo clean vs noise-trained at 10%. Play, pause, step, restart, change speed, seek, or jump to the previous/next successful shift or blocked shift. The intended-placement ghost can be switched off.

The replays are recorded simulations, not live neural-network inference. They are short demonstration clips, not the 2,000-piece evaluation games, so their scores are not the paper’s means. Manual JSON upload is still supported.

Limitations and ethics

Paper and reproducibility

The verified manuscript is a LaTeX package. A compiled PDF is not included in this public build because the build environment had no TeX engine. The page keeps the abstract, verified tables, figures and a public-safe copy of the LaTeX source. The training code, checkpoints and raw logs stay in the private research repository.

Read the paper summary Download LaTeX source (ZIP)
AI-assistance disclosure: the author used an AI coding assistant (opencode with DeepSeek-V4.1-Flash) to help develop code, run experiments, compute statistics, prepare figures and draft text. The assistant is not an author. Every reported number was traced back to the final result files, and the author remains responsible for the work.

Cite

@misc{erkenzhe2026tetrisrl,
  title  = {Tetris RL Arena: Afterstate Reinforcement Learning under Execution Noise},
  author = {Erkenzhe},
  note   = {FRP 2026, AI Engineering track, ISSAI, Nazarbayev University},
  year   = {2026},
  url    = {https://yerkenje.github.io/tetris-rl-arena-page/}
}