Joshua Gao

deep learning researcher at

SAIL

AI

Mastering Flappy Birds through World Models

Joshua Gao

24 Jul 2026

Mastering Flappy Birds through World Models

This is a World Model playing Flappy Bird — but there is no game running. Everything below is a “dream”: a DreamerV3 world model hallucinating each frame from its own imagination. A learned actor flies the bird inside that dream. Press Space (or tap the frame) and you take the stick.

DreamerV3 Best0
Your Best0
you flapped
loading the dream…

Press Space (or tap the frame) to take over and flap, or switch off DreamerV3 Assist to fly the dream yourself.

Nothing here is a real game — every pixel is hallucinated by the RSSM from a latent it imagines.

How it works

Unlike the two-stage World Models recipe (a VAE, then a separate memory RNN), DreamerV3 learns one joint world model end to end — a Recurrent State-Space Model (RSSM). Its latent state at each step splits in two: a deterministic part h (a GRU carrying history) and a stochastic part z — here 32 independent 32-way categoricals, sampled fresh each step. Everything below runs frozen and exported to ONNX, entirely in your browser with onnxruntime-web.

The RSSM (dynamics). A GRU folds the previous stochastic state and your action into h, and a prior network predicts the distribution over the next z from history alone — no observation needed. Rolling that prior forward is the dream. During training a posterior that also sees the real frame is pulled toward the prior (a KL term), so the prior alone becomes a competent forward model of pipes and gravity.

The decoder + heads. From the combined feature [h, z], a convolutional decoder reconstructs the frame you see, while reward and continue heads predict the expected reward and the probability the episode keeps going. That continue probability is what ends a dream when it drops.

The actor. A small policy mapping [h, z] to an action, trained entirely on trajectories the world model imagines — never on the real environment.

Each tick the loop is: decode [h, z] to the frame you see → the actor (or your Space bar) picks flap / no-flap → the RSSM advances its GRU and samples the next z. When the continue head’s probability crosses a threshold, the dream ends and a fresh one is seeded from a real starting state. Your flap and the actor’s share the same stick, so you’re steering the policy through its own hallucination.