TrackMania and Tool-Assisted Speedruns

Published on

Introduction

There has been recently quite some interest in performing scripted runs for TrackMania using external tools and for a reason. This interest was induced by certain controversial events and by the fact that some people actually started developing such tools for the game. Let’s uncover some details about TrackMania TAS’ing and also some related topics. This post will be a little Q&A for people who are interested. I will not talk about technical details here, these are deliberately left out.

Q: What is TAS?

A: TAS stands for Tool-Assisted Speedrun and it is basically creating a set of inputs that will be performed to achieve a certain goal within the game. Many games that have speedrunning communities also have TAS’es made for them. These runs are often clearly distinguishable and have separate leaderboards to not clutter „real” record leaderboards for humans. Since TrackMania is a highly competitive game and there’s always been interest for improving current world records, people started to develop tools to improve times.

Q: How does TAS work for TrackMania?

A: Most tools developed rely on creating a script with specific inputs that will be replayed at the run time. This is also the case for other games, but with the exception that these games are ran in an emulator – which means they have 100% reproducibility. Because TrackMania isn’t an „old” game and doesn’t run in the emulator – it is much harder to create such a script because of so-called desyncs. Basically, the script won’t always produce the same output. These desyncs come from the fact (over-simplification) that modern OS’es like Windows don’t run processes in „real-time”. However, it is possible to reduce the impact of these desyncs – but I won’t go into detail.

An example of a script can be:
0ms press up
1200ms press left
2440ms release left
4000ms press right
5500ms release right
6720ms press down

You can also slow down the game time, but this is rather just a helper to get the scripted inputs right.

Q: Is it hard to create a good TAS run?

A: Absolutely. TrackMania is one of these games that for 1 second in-game you need to spend hours to get that 1 second done even decently. This is due to the unbelievable complexity of the game and it’s mechanics. For each input change, you need to make sure that the car stays on the track and also has an optimal line. To do that, you need to restart the run, wait for the script to execute all inputs and then see the outcome for yourself. The longer the track is, the longer the process becomes. Plus, many tracks (especially Nadeo) have really good world record times already (one could say that they’re close to being maxed). These are the hardest to beat even for carefully prepared inputs but are by far the most popular tracks to TAS.

Q: Is it possible to distinguish between a TAS run and a run done by a human?

A: With the introduction of Competition Patch this is not a problem anymore, see TrackMania Competition Patch.

Q: Were there cases where these records appeared on TMX?

A: Yes, notably A04, B10 and C04 have had uploaded TAS’ed replays without any closure from their authors, both of which were removed after people started investigating and proved that these replays were indeed scripted.

Q: Where can I watch some of these runs?

A: These two YouTube channels uploaded some of runs that were tool-assisted:
https://www.youtube.com/user/TmSpeedy0407
https://www.youtube.com/user/Angecide

There are currently no one else uploading such runs to my knowledge.

Q: Are these tools available for download?

A: No, nobody including me released these tools to the public simply to keep the integrity of the leaderboards and to keep up the competitiveness of the game. Could these be published in the future? Maybe, but I believe this is mostly about a community agreement and not about trying to prevent people from misusing these tools.

I think that at least for now, this is a good thing. People who have access to these tools explicitly do not upload fake records to TMX, instead a YouTube video is made to showcase the replay. This ensures that both parties are happy.

Q: Is TrackMania „random”?

A: No, TrackMania physics are completely 100% deterministic. That means that the same set of inputs will always yield the same outcome in the game. For us, humans, certain behavior of the car can be „random” because it is not directly related to the inputs and doesn’t make sense, but that doesn’t mean that the underlying physics are based on any random factor. There just isn’t one.

Q: Can you create an AI to drive tracks perfectly?

A: To my knowledge there have been a few people that tried to create a neural network that would drive a track, but the keyword in the question here is perfectly. These networks could in theory drive a track but nothing more than that. These runs would be really basic and totally not what you would see from today’s world records. I haven’t seen any real results on driving tracks by an AI algorithm to this day.

There is really no „perfect” run existing in TrackMania (except for a few one-turn tracks).

Q: What about maxed records?

A: Besides a few tracks from the TMN ESWC campaign like A-0, there are no maxed records existing in TrackMania. What can look like a perfect run can be only closer or an approximation to a hypothetical real perfect time. Improving this time only brings us closer to that unknown limit. Of course, there can also be a human limit which most people really mean when they’re talking about a maxed record. This limit can be somewhat approximated based on a collection of world records previously set by drivers. By combining the best parts of these runs we can roughly say what would be the limit with current strategies.

Q: Can you write a script to discover a maxed record?

A: It’s possible to write a program to take some existing inputs and change them randomly to discover new runs but even that is hard enough. Searching for a real possible maxed record is completely unfeasible and impossible to do right now even on really short tracks. To really know the optimal time of a track, you would have to try out every possible input combination. It’s much more feasible to take an existing record and change random inputs in it to come up with a new combination that maybe faster than the original record.

But let’s just imagine that we want to find out a “maxed” record on the simplest Nadeo track with one turn: A-0. Let’s see how much combinations it would take to brute force it. The current world record is 04.39.

TrackMania checks for input every 10 milliseconds. Suppose we can only do keyboard inputs. That’s 4390ms / 10 = 439 possible slots in which we can press / release keys. So every 10 milliseconds we can change what keys are pressed.

At each slot we can have 16 possible input combinations since there are 4 keys you can press: up, down, left, right (2^4 = 16). You can press e.g: left, up and down exactly at the same time.

That’s 16^439 possible input combinations on this track. Given that this number far exceeds a 64 bit unsigned integer I won’t try to determine how much time it would take to go through all of these combinations. That’s on a track that is 4 seconds long. Now, most of these combinations would be completely nonsensical but they are still valid. You must admit though that this is pretty useless, but it shows how complex the TrackMania environment really is.