Docs


Evolving 2D Walker

A population of random vehicles tries to roll across uneven terrain. The GA evolves better cars over time.

Last updated June 3, 2026

Go to the live page Open the 2D Walker demo

The 2D Walker drops fifteen random vehicles onto a hilly course and lets them try to drive themselves to the right. Most of the first batch are awful at it. The genetic algorithm fixes that.

The problem

Every car is a small object with two motorised wheels:

  • An irregular polygon body shaped by eight radii.
  • Two wheels, each with its own radius and density, attached to two of the body's corners.
  • A motor torque that both wheels share.

That is fifteen real-valued numbers. The genetic algorithm searches the space of those numbers.

How a run looks

Click Start. The first generation is fifteen random designs. Some flip over. Some drive backwards. Some sit and spin their wheels. A generation ends when every car has either fallen off the course or stopped making progress for a few seconds.

The platform then evolves the population. Four elites carry over unchanged, eleven children are bred from the top performers, every gene is mutated with a small probability, and the new batch arrives on the next round. The card row under the canvas keeps the best car of each generation as a thumbnail so you can scroll back and watch the shape converge.

Within a dozen generations or so the population looks intentional. Within thirty most cars are crossing terrain that nothing in generation zero could touch.

Things to try

  • Switch Difficulty in Settings. Easy is gentle rolling hills; challenging stacks sharp climbs, deep pits, and swinging pendulums.
  • Bump Mutation probability up. The population explores wildly and the leader changes shape every generation.
  • Drop Elites preserved to zero. The best design from one generation is no longer protected, so progress is jumpier.
  • Cap Max generations low to see a short run, then click Reset (new seed) to start over with the same settings.

What the achievement rewards

The first time a best-of-generation car covers at least one hundred meters of the current course, the 2D Walker champion achievement unlocks for signed-in users. Most evolved cars hit that mark within a handful of generations on medium difficulty. On challenging it can take a lot longer, which is part of the point.

For more on how the demos catalog works, see What the demos do.

Thanks for the feedback!