The practical takeaway: you can fit a working "world model" onto a Raspberry Pi Pico 2 W (RP2350) and have it generate and play simple games entirely on-device. The project, tinyworldformer, pairs two tiny neural networks. The first takes the current frame plus an action and predicts the next frame and reward — it is the game. The second reads that generated frame and chooses an action — it is the player. Neither ever touches the real game at runtime; the actor only sees dreamed frames, and the world model only sees the actor's actions. Both run on core 1 of the RP2350 while core 0 handles USB and the display.

The design trick worth stealing is the looped transformer. Instead of stacking distinct layers, a single transformer block (attention plus a ReLU MLP) is applied one to four times with the same weights, re-adding the input before each pass. Reusing weights keeps memory tiny, and because every pass is trained against the target frame, loop count becomes a runtime speed-versus-accuracy dial. The Pico uses two loops to hold a usable frame rate. World models land between 26k and 131k parameters (2–8M multiply-adds per frame); the actor is a two-hidden-layer MLP at 9k–16k parameters. Games like Breakout, Pong, Flappy Bird, a Doom-lite raycaster, and Pac-Man lite reach 83–100% exact held-out frame prediction.

Two engineering details explain why this works at all. First, decoding the model's per-cell scores matters nearly as much as the model itself: background cells each pick their most likely token independently, while singletons (the ball, the player, each ghost) use one global argmax over all cell-token pairs so you get exactly one of each. That single change took Breakout from 91.6% to 99.7% exact frames by eliminating a two-ball bug. Second, accuracy on recorded data isn't enough — an agent drives the dream into states the training data never saw, then exploits any error. The fix is a collect-and-fine-tune loop: let the agent play, record where it went, and retrain the world model on those states.

Tinyworldformer: a self-playing world model that dreams games on a $7 microcontroller

The agents use Stream AC(λ), an online reinforcement-learning method that learns from one transition at a time — no replay buffer, no batches, no target network. Eligibility traces carry credit backward and ObGD clips steps that would overshoot the TD target. This is what lets a fresh agent learn to play on the board itself, inside its own dream, and the project reproduces it in no_std Rust with a hand-written backward pass that matches PyTorch to within 3.5e-6.

For deployment, every world-model matrix is int8 with per-row scales; activations are int8 with per-tensor, per-loop scales, since each loop pass sees different ranges. Matmuls accumulate into int32 using the RP2350's SMLAD instruction, softmax uses a 1024-entry exp table, and norms and embeddings stay float32 to use the chip's FPU. Crucially, quantization-aware training means the int8 model is the trained model, and a numpy reference reproduces the Rust engine bit for bit, verified by cargo tests. Firmware footprints run roughly 360–470 KB flash and 227–357 KB RAM per game.

Why it matters for builders: this is a concrete, reproducible blueprint for shipping learned dynamics models onto cheap hardware without a GPU. If you work on edge RL, embedded inference, or simulation-from-pixels, the repo gives you a full stack — numpy game references, QAT, Rust int8 kernels, and an on-device learner — plus honest notes on the failure modes (agents camping in corners, phantom sprites, agents scoring impossibly high in the dream) and the shaping and noise-augmentation fixes that closed them. You can run the real games locally today with uv run python -m tinyworldformer.games.play.