tickgym

pip install tickgym

Drive Trackmania 2020 physics from Python, for training agents on exact, restorable simulation.

Three objects do everything:

  • A Client talks to TICK on this machine and opens a map as a Session.

  • A Session is one map, loaded and ready. Each connect on it opens a gym; open several for several gyms side by side.

  • A Gym is one car on that map. You reset it, step it a few ticks at a time with inputs, snapshot and restore it, and read a typed Telemetry after every call.

from tickgym import Client, TelemetryGroup

session = Client().open_map(r"C:\Maps\Example.Map.Gbx")
with session.connect(TelemetryGroup.RACE | TelemetryGroup.VEHICLE) as gym:
    t = gym.reset(seed=1)
    while not t.finished:
        t = gym.step(3, steer=40, accelerate=True)
    print(t.race.race_time_ms, t.vehicle.position)

The same seed and inputs always give the same race, and the physics is the game’s own.

Requirements

  • TICK 3.0 installed and run once with the game, so it knows the game’s folders.

  • Python 3.11 or newer and NumPy.