Docs


Genetic Artist

The genetic algorithm repaints a target image one brushstroke at a time, searching for the stroke that brings the canvas closest to the picture.

Last updated October 26, 2026

Go to the live page Open the Genetic Artist demo

The Genetic Artist starts with a blank white canvas and a target picture, and paints its way toward the picture one brushstroke at a time. Before each stroke it runs a small genetic algorithm to find the single best stroke to add next. Early strokes block in the main colours; later ones sharpen edges and detail.

Targets and the Brush

Pick one of five target pictures: Pyramids of Giza, Mona Lisa, Nature, Sunset or Ancient Cairo. You choose the target before you start; the picker is locked while a run is painting.

Every stroke in the painting uses the same brush: one hard-edged round dab, always the same size and never rotated. The genetic algorithm only decides where each stroke goes.

How a Stroke Is Chosen

Each candidate in the population describes one stroke with just two genes: where it goes across and where it goes down. The colour isn't a gene. It is picked up from the target picture at the centre of the stroke, which keeps the search small.

Fitness tries each candidate stroke on a copy of the current canvas and measures how close the result is to the target, pixel by pixel. The closer, the better. After the search, the best stroke is painted onto the canvas only if it actually improves the match; if it doesn't, it is thrown away. Then a fresh search starts for the next stroke.

How a Run Looks

Click Start. The painting updates as strokes land, next to the target. A small strip on the painting shows the stroke count and the improvement so far, and the bar under it fills as the run approaches its time or stroke limit, whichever comes first. The readouts below show:

  • Strokes. How many strokes have actually been painted. Searches whose best stroke was thrown away don't count here.
  • Generations. Every generation run so far, counting all searches, kept or not.
  • Improvement. How much the pixel error has dropped compared with the blank canvas, as a percentage. A chart tracks it over the run.
  • Time left. How long until the run time limit stops the run.

You can pause and resume at any time, or press Reset to stop and clear the painting. A run stops by itself when it reaches the time limit or the stroke limit, and the status line says which one. The finished painting stays on screen until you press Start again, pick another picture, or press Reset. If something goes wrong on Vilvik's side, the status says so and asks you to press Reset and try again.

Settings to Try

  • Generations per stroke (5 to 50, default 15). Each stroke is searched harder, but fewer strokes fit in the time budget.
  • Population size (5 to 50, default 20). How many candidate strokes are tried each generation.
  • Mutation rate (0.05 to 1, default 0.25). The chance that each gene is replaced during mutation. Higher means more exploration.
  • Max run time (30 to 180 seconds, default 60).
  • Max strokes (50 to 1500, default 1000). This caps the number of stroke searches, including ones whose stroke was thrown away, so the Strokes readout can end below it.

Your settings are kept as you change them (this browser remembers them for your next visit) and take effect on the next Start, so changing them mid-run doesn't affect the run in progress. Done closes the dialog, Apply & Reset also stops any run and clears the painting, and Reset to defaults restores the starting values and forgets your saved choices.

What the Achievement Rewards

Signed-in users unlock the Master strokes achievement when a run finishes, by reaching its time or stroke limit, with an Improvement of at least 40 percent. Resetting before the run finishes doesn't count.

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

Thanks for the feedback!