Docs


Dino Runner

A dino learns to play an endless runner, jumping cacti and ducking flying obstacles. The genetic algorithm evolves a tiny neural network from tripping at the first hurdle to long clean runs.

Last updated October 25, 2026

Go to the live page Open the Dino Runner demo

The Dino Runner demo is a take on the offline dinosaur game. A dino runs along the ground while obstacles scroll toward it, and the genetic algorithm evolves a small neural network to keep it alive. Early on the dino trips at the very first hurdle. After a few generations it learns to read each obstacle and react correctly, and the runs get long.

It lives alongside the other live-agent games (Flappy Bird, Snake, the Self-Driving Car, Breakout, Pong, Gem Collector and Frog Crossing) under the same Live Agent demo. Use the tabs at the top of the page to switch between them.

The Problem

Two kinds of obstacle come at the dino, and they need opposite reactions:

  • Cactus on the ground. The dino has to jump it. Ducking still hits it.
  • Flying obstacle at body height. The dino has to duck under it. Jumping rises straight into it, and running hits it standing.

So the network has a real choice to make at every obstacle. The network reads seven inputs: how far ahead the next obstacle is, whether it is on the ground or in the air, how tall it is, the dino's own height and rise or fall, and the current speed. One hidden layer of eight neurons feeds three outputs: run, jump, or duck. The largest output wins.

Fitness rewards how long the dino survives plus a bonus for each obstacle it clears. The course speeds up the longer a run lasts, so later obstacles arrive with less time to react. A network that reacts a touch too early or too late clips the obstacle and the run ends.

How a Run Looks

Click Start. The current best network plays a run live, and a panel in the corner shows the three action scores each step with the chosen one highlighted. The rest of the generation runs the same course next to it as faint dinos, and Still in play in the Training panel counts how many are left. Use the Show all dinos switch next to the Start button to watch only the best one. The chart on the right tracks the best score for each cycle. Each cycle brings a new sequence of obstacles, so the dino has to react rather than memorise a course.

Generation zero is clumsy: most dinos run straight into the first cactus. Within a few cycles the best one learns to time its jumps, and the runs stretch out as the speed climbs. Many champions find a shortcut: they crouch the whole way, which slips under every flying obstacle, and only stand up to jump a cactus. In our tests (24 runs, 20 cycles each), every run's best dino lasted the whole two-minute replay, first between cycle 3 and cycle 16 (half of them by cycle 6), and two out of three of those full runs never used plain running.

Playing It Yourself

Switch the mode toggle from Agent to You to take over. Press Space or the up arrow to jump, and hold the down arrow to duck: the dino stays down for as long as you hold it. On a touch screen or with a mouse, use the joystick over the game: push it up to jump and hold it down to duck. The joystick appears wherever you touch or click the game, so you can play with your thumb in whichever spot is comfortable, and it stays there for next time. When the game ends, tap the game (or press Space, or Play again) to start a new round straight away. There is no step limit in You mode, so you can run for as long as you keep clearing obstacles. Switch back to Agent at any time and the evolved network picks up from where you left off.

Settings Worth Trying

Open Settings to tune the genetic algorithm for the next run:

  • Population size. More candidates per generation means more variety to select from, at the cost of a slower cycle.
  • Generations per cycle. How much evolving happens between each live run you watch.
  • Mutation rate. How much the networks are randomly perturbed each generation. A little keeps the search exploring; too much stops it from settling on a good policy.

The dino records and shares like the other demos. See Sharing and recording for how to capture a clip of a good run.

Thanks for the feedback!