> ## Documentation Index
> Fetch the complete documentation index at: https://me.miltonials.com/llms.txt
> Use this file to discover all available pages before exploring further.

# An escape room solved by a genetic algorithm

> A genetic algorithm that learns to escape a room on its own — one of my favorite projects to explain, because there's a video.

This is the project I reach for when someone asks what I like to build. It's an **escape room that a genetic algorithm learns to solve** — no hard-coded solution, just evolution stumbling its way to the exit.

<iframe className="w-full aspect-video rounded-xl" src="https://www.youtube.com/embed/kmKBgAbhE_A?si=1G4SAcp4QDY7JOUB" title="Escape room solved with a genetic algorithm" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />

## The idea

A genetic algorithm treats each attempt to escape as an individual in a population. Each one has a "genome" — a sequence of moves. The ones that get closer to the exit are scored higher, the best are combined and mutated, and over many generations the population converges on a route that works. Nobody tells it the answer; it *finds* it.

## What makes it fun

* **You can watch it learn.** Early generations flail around uselessly. Later ones move with something that looks unnervingly like intent.
* **The fitness function is everything.** How you reward "progress" completely changes what the algorithm discovers — including the clever, cheating solutions you didn't intend.
* **It's all in the browser.** Built with JavaScript, CSS and HTML, so it runs anywhere with no setup.

<Card title="Source on GitHub" icon="github" href="https://github.com/miltonials/scape-room">
  miltonials/scape-room
</Card>

Genetic algorithms are one of those ideas that sound abstract until you watch one work. This was my way of making it concrete — for myself first, and then for anyone I could show the video to.
