PlayTrain: An Efficient Reinforcement Learning Framework for LLM-Generated Adaptable JavaScript Games

Ryan Truong1, Lance Ying1,2, Samuel J. Gershman1,3, Kazuki Irie4
1Harvard University 2MIT, Brain and Cognitive Sciences 3Kempner Institute 4Yale University

Videos render best on a computer.

coinrun

impala128
ppo13.83
20010000100M steps

qbert.bigmap

impala1,283
ppo481
2k1k00100M steps

breakout.multiball

impala777
ppo827
1k50000100M steps

frostbite.jungle

impala254
ppo253
50025000100M steps

downwell.upgraded

impala330
ppo356
50025000100M steps

miner

impala7.7
ppo10.8
201000100M steps

starpilot

impala28.63
ppo41.8
502500100M steps

bossfight

impala73.87
ppo84.27
10043.6-12.80100M steps
IMPALAPPO

IMPALA and PPO per game, with greedy returns and training curves.

TL;DR: We present an efficient RL framework for running single-file LLM-generated JavaScript games. These video-game environments can be playtested by humans easily on a browser and can train pixel-based agents at over 1M decisions per second on one GPU node, measured over our 24-game suite of 16 ProcGen and 8 Atari clones.

Abstract

While many video-game environments (VGEs) have played crucial roles in advancing reinforcement learning (RL), developing novel VGEs or modifying existing ones to support new features has been a laborious process requiring extensive hand-coding. Here we present PlayTrain, an RL framework that combines the abilities of large language models (LLMs) to robustly generate JavaScript (JS) games from a minimal human prompt, and an efficient pipeline that can run any JS game in a standard gym environment. Not only are recent LLMs particularly good at writing JS code, but the JS format also allows users to easily play generated VGEs, while PlayTrain enables us to train RL agents on the exact same games. We demonstrate multiple use cases of PlayTrain, including cloning well-known Atari and ProcGen games in simple JS, where PlayTrain trains pixel-based agents end-to-end at over 1M agent-decisions per second on a single GPU node; and creating modified versions thereof (e.g., that support novel test sets, procedural generation logics, or game dynamics). Through PlayTrain, we reimagine RL VGE development: all we need is a single JS file, generated and modified through an LLM. We discuss promising future RL research directions that PlayTrain unlocks.

Humans and agents, same file

Attached here are the eight games the human study covered. Each panel here contains a participant’s best recorded round paired with both IMPALA and PPO trainers. All of them run on the same study’s seeds 2000-step cap horizon. Underneath the videos are the mean arg-max return values over 30 episodes, ten on each of the three seeds the curve beside them plots. Crucially, everyone here plays the exact same game, and human gameplay’s recordings are simply read off JSON files that contain the seed and keyboard action inputs given the step() index.

IMPALAPPOmin–max over 3 seedshuman mean (IQR over 20 people)

asteroids

human2,160
impala1,246
ppo593
2k1k00100M steps

breakout

human380
impala258
ppo212
50025000100M steps

caveflyer

human22
impala2.7
ppo1.9
201000100M steps

coinrun

human251
impala128
ppo13.83
20010000100M steps

flappy_bird

human28
impala0
ppo17.6
502500100M steps

plunder

human20
impala4.9
ppo7.17
10500100M steps

seaquest

human450
impala777
ppo756
1k50000100M steps

VVVVVV

human600
impala78.33
ppo16.67
1k50000100M steps
loading
Click to play arrow keys and spacebar · Esc to release Playing needs a keyboard.
Open this page on a computer to try the games — the agent and human clips on this page play anywhere.

arrow keys and spacebarkeyboard only · not playable on a touch screen

BibTeX

@misc{truong2026playtrainefficientreinforcementlearning,
      title={PlayTrain: An Efficient Reinforcement Learning Framework for LLM-Generated Adaptable JavaScript Games}, 
      author={Ryan Truong and Lance Ying and Samuel J. Gershman and Kazuki Irie},
      year={2026},
      eprint={2609.09059},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2609.09059}, 
}