Skip to main content

TrackmaniaRL

TrackmaniaRL is a Python library for training reinforcement-learning agents on custom Trackmania 2020 maps. It covers map geometry, demonstrations, asynchronous training, checkpoint resume and repeatable evaluation.

The game integration runs on Windows. Training and analysis can also run on Linux. Version 1.2.2 requires Python 3.12 and uses RunSpec 2.0 and checkpoint schema 2.0.

Installation

Install uv, then create a project:

uv tool install "trackmaniarl==1.2.2"
trackmaniarl init my-agent --template trackmania
cd my-agent
uv sync

To install a locally built wheel instead:

uv tool install path\to\trackmaniarl-1.2.2-py3-none-any.whl

To work from this repository, run uv sync --group dev and prefix commands with uv run.

For a game-free installation check, generate the small SDK starter instead:

trackmaniarl init sdk-check --template starter
cd sdk-check
uv sync
uv run trackmaniarl inspect-config run.yaml
uv run trackmaniarl validate run.yaml

Validation executes trusted component code and a synthetic update. It does not drive the game or establish driving performance. CPU execution is sufficient for this check; live neural inference and training benefit from an NVIDIA GPU with a compatible PyTorch build. See platform and performance guidance.

Neural inference in motion

Gameplay alongside road, car and context branches, residual blocks, action values and changing steering and pedal controls

This excerpt visualizes the best-performing model supplied for this release. The panel follows geometry, car and context inputs through model stages to action values and selected controls. The animated summaries are not a causal attribution of individual neurons. This selected lap uses the map-specific neighbors action filter; it is neither an unassisted-policy benchmark nor evidence of generalization. See the model and recording explanation for provenance, the five-attempt film series and GIF reproduction.

Game setup

You need:

  • Trackmania 2020 on Windows
  • Openplanet in School Mode
  • the TrackmaniaRL Connect / SAC_GetData plugin
  • your map open in the editor's validation mode, with the car at the start.

The plugin uses TCP ports 9000 (telemetry) and 9001 (session and map status) on localhost. The setup guide explains plugin installation and controller setup: Trackmania setup.

Check the connection before recording data or training:

uv run trackmaniarl track check

Configure a map

Record both track boundaries from start to finish, then build the geometry file:

uv run trackmaniarl track record-boundary left assets/my-map-left.npy
uv run trackmaniarl track record-boundary right assets/my-map-right.npy
uv run trackmaniarl track build-geometry assets/my-map.geometry.npz `
  --left assets/my-map-left.npy `
  --right assets/my-map-right.npy `
  --map-uid YOUR_MAP_UID `
  --map-path maps/my-map.Map.Gbx

Copy the map to maps/, then replace REPLACE_WITH_YOUR_MAP_UID in run.yaml with the UID printed by track check. See examples/own-map.yaml for a complete configuration. TrackmaniaRL verifies the open map but does not select it for you.

Train and resume

Validate the configuration and run a short smoke test before a full training run:

uv run trackmaniarl validate run.yaml
uv run trackmaniarl track check --config run.yaml
uv run trackmaniarl smoke run.yaml --transitions 100
uv run trackmaniarl train run.yaml

The starter project uses a lidar encoder, a dueling IQN policy and 78 discrete control actions. An actor drives while the learner trains from replay.

Demonstrations are optional:

uv run trackmaniarl track record-demo demonstrations --config run.yaml --count 5
uv run trackmaniarl train run.yaml --demo demonstrations

Resume the full training state from a checkpoint:

uv run trackmaniarl resume run.yaml artifacts/RUN/checkpoints/CHECKPOINT.pt

To start a new run with compatible weights, use train --model-initialization-checkpoint CHECKPOINT.pt. A policy-only checkpoint does not contain optimizer or replay state and cannot be used for an exact resume.

Evaluate a checkpoint

Run every trial and keep the complete result:

uv run trackmaniarl benchmark run.yaml artifacts/RUN/checkpoints/CHECKPOINT.pt `
  --trials 30 --min-finish-rate 1

Add --record recordings/benchmark.mkv to record the Trackmania window. Recording requires FFmpeg. Use --ffmpeg PATH or --window-title TITLE when the defaults do not match your system.

Each benchmark writes evaluation.json and an append-only trial timeline. A DNF still counts as an attempt. Mean and median times cover finished attempts, so report them together with the finish rate. Telemetry drops are recorded because they can delay observations and control decisions. --reject-telemetry-skips rejects the whole evaluation. It never removes individual slow attempts.

More detail: evaluation architecture, recording and troubleshooting.

Documentation

PPO and the graph-based recovery models are experimental and are not part of the default Trackmania training path. The project does not currently provide a camera vision pipeline. Configuration files and PyTorch checkpoints can execute Python. only use files you trust.

Development

uv sync --group dev
uv run ruff format --check .
uv run ruff check .
uv run mypy --strict trackmaniarl
uv run pytest
uv build
uv run python scripts/check_distribution.py

TrackmaniaRL is released under the MIT license. It originated from TMRL. attribution is in NOTICE. It is not affiliated with Ubisoft or Nadeo.

Metadata

Release files for TrackmaniaRL 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for TrackmaniaRL 1.2.2
File Size Uploaded
trackmaniarl-1.2.2.tar.gz 28.0 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for TrackmaniaRL 1.2.2
File Interpreter ABI Platform
trackmaniarl-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 28.5 MB

Release files / trackmaniarl-1.2.2.tar.gz

Download URL trackmaniarl-1.2.2.tar.gz
Size 28.0 MB
Tags Source
SHA-256 checksum
How to use checksums
26dbd8c46d684e8ddd3a15f56d3c076c8f9c34d73a070dcbb03021c756b35046
BLAKE2b-256 checksum
How to use checksums
1bb769052132f660eb03fee3adedde91947138a25abe180268ab01d35272751f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / trackmaniarl-1.2.2-py3-none-any.whl

Download URL trackmaniarl-1.2.2-py3-none-any.whl
Size 498.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ffc2907f29a925b1d1e3c4248d53d1dccff5144d3e30cf705301dbb21d919de7
BLAKE2b-256 checksum
How to use checksums
57a789f957a15fc850accaa57d3f6f41cfe4965c07fca6c72e0575d6cd9f1f03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release history Release notifications | RSS feed

1.2.12

2 release files

1.2.11

2 release files

1.2.10

2 release files

1.2.9

2 release files

1.2.8

2 release files

1.2.7

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

This release

1.2.2 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page