Revenant

An AI that teaches itself TrackMania Nations Forever. No recorded runs, no rules about corners. It drives every official level thousands of times and keeps whatever made it faster.

Free and open source. Windows with an NVIDIA graphics card.

The Revenant car in the TrackMania garage: matte black with twin teal stripes over the nose

Where it's got to

After 93 hours of training on one ordinary gaming PC, Revenant has finished 40 of the 65 official levels and beaten the author time on 3. Every time below is its own lap.

Trained offline only. Revenant never plays online, so none of this touches the real leaderboards.

How it learns

Twenty times a second Revenant gets a small grey picture of the screen, its speed, which wheels are touching the ground, and where the racing line goes next. It picks one of twelve key combinations. That's all it ever sees or does.

It's rewarded for getting further along the line in less time, and nudged away from walls. At first it drives into the first barrier over and over. A few hours later it's finishing the easy levels, and then it starts shaving off tenths.

Under the hood it's an IQN reinforcement learning agent, built on Linesight, talking to the game through TMInterface. Two copies of the game play at once while the learner trains on what they bring back.

The Revenant car side on, matte black with REVENANT on a teal side panel

When it gets stuck

D02 has a hairpin that Revenant hit the wall on for five hours straight. Practising from the start every time meant it barely got any tries at the corner itself.

So a spare copy of the game builds a lap out of Revenant's own controls, following the record line one 50 ms step at a time and checking every step replays exactly. Then Revenant starts runs from random points along that lap and takes over the wheel. It finished D02 minutes after the first one.

The Run tab in Revenant's controls, with demo starts, the lap follower and bruteforce

One window runs all of it

Revenant comes with a dashboard that sets up everything on your PC, benchmarks your graphics card and picks settings to suit it. Then it starts and stops training, shows every lap as it happens, and draws the fastest one on the map, coloured by speed.

The Revenant dashboard showing lap times, finish rate, wall touches and the fastest lap on the D02 map

Run it yourself

You need Windows 10 or 11, an NVIDIA card with 4 GB or more, and TrackMania Nations Forever, which is free on Steam.

  1. Download

    Grab the code from GitHub. It starts learning from nothing. For the trained Revenant, also download the zips from the latest release.

  2. Open Revenant.bat

    The first time, it installs Python and the AI's libraries, about 3 GB. After that it opens straight to the dashboard.

  3. Follow the Setup tab

    It checks the game, the mod loader, the maps and your PC, with a button next to anything missing. Then press Start.

Why it exists

Me and a friend wanted to see if it was possible to build a Trackmania AI that teaches itself to beat author times, with Claude Opus 5.5 doing the coding, debugging and testing while I steered it. It turns out it is.

Thanks to

  • Unnamed477, for his own runs of the levels, which Revenant learned its best lines from.
  • The Linesight team, whose AI Revenant is built on.
  • donadigo for TMInterface and Tomashu for TMLoader.
  • TMX for the record replays.