# Mario Kart and the Pareto Frontier

Who is the best character in Mario Kart? This is actually a non-trivial question, because the characters have widely varying stats across a number of attributes. (For the unfamiliar, Mario Kart is a video game where you select characters from the Nintendo universe and race them against each other in cartoonish go-karts.) The question is compounded when you consider the modifications introduced by the the various karts and tires players can select from. In general it isn’t possible to optimize across multiple dimensions simultaneously, however some setups are undeniably worse than others. The question for an aspiring Mario Kart champion is “How can one pick a character / kart / tire combination that is in some sense optimal, even if there isn’t one ‘best’ option?”

To answer this question we turn to one of Mario’s compatriots, the nineteenth century Italian economist Vilfredo Pareto who introduced the concept of Pareto efficiency and the related Pareto frontier. (If you’re just here for the interactive character selector, you can click here to skip ahead.)

The concept of Pareto efficiency applies to situations where a finite pool of resources is being allocated among several competing groups. A particular allocation is said to be Pareto efficient if it is impossible to increase the portion assigned to any group without also decreasing the portion assigned to some other group. The set of allocations which are Pareto efficient define the Pareto frontier. As with many things, this is more easily explained with a picture (courtesy of wikipedia).

The elements in red lie on the Pareto frontier: for each element in the set an increase along one axis requires a decrease along the other.

We can apply this same concept to Mario Kart: the resources are total stat points and the groups are the individual attributes, for instance, speed, acceleration, or traction. (In general, characters in Mario Kart have the same number of total stat points, and differ only in their allocation). Speed and acceleration are generally the two most important attributes of any given setup, so the goal of this post is to identify those configurations that lie on the Pareto frontier for speed and acceleration.

As usual, we start with a little data wrangling to get things into a form we can use. One particular quirk of Mario Kart is that while there are a couple dozen characters, lots of them have identical stats. We’ll start by picking out one character from each stat group to use in this analysis (and then do the same for karts and tires).

From here on out, I’ll refer to the character (or kart, or tire) class by the name of its first member. For example, in the heatmap below the row labelled ‘Peach’ also describes the stats for Daisy and Yoshi. The complete class memberships are listed at the end of the post in case you want to see where your favorite character lands.

There are seven classes of characters, let’s have a look at how their stats compare.

The most obvious trend is the trade-off between speed and acceleration; heavy characters have good speed but bad acceleration, while light characters have snappy acceleration but a low top speed. There are variations in the other stats as well, but to a large extend the speed and acceleration dominate the performace of a particular setup so we’ll be ignoring the rest of the stats.

Karts and tires modify the base stats of the characters; the final configuration is a sum of the character’s stats and the kart / tire modifiers. As with characters, there are dozens of karts and tires but only a few categories with different stats.

The trends here are less obvious, but they generally agree with what we saw in the character stats: improvements in speed come at the expense of acceleration, and vice versa.

Our goal is to find all the configurations that have an optimal combination of speed and acceleration, so the next step is to compute the stats for each unique (character, kart, tire) combination.

Equipped with the statistics for each possible combination, we can can plot the speed vs the acceleration of each possible setup, and identify those that lie on the Pareto frontier.

Looks like the optimal configurations make up a fairly small subset of the total possible setups. In fact, we can quantify this.

```
Possible combinations : 149760
Unique stat combinations : 294
Optimal combinations : 15
```

Let’s have a look at what these optimal configurations look like.

```
Speed Acceleration
Character Body Tire
Baby Mario Biddybuggy Roller 1.00 5.75
Toad Biddybuggy Roller 1.50 5.50
Peach Biddybuggy Roller 2.00 5.25
Mario Biddybuggy Roller 2.50 5.00
Donkey Kong Biddybuggy Roller 3.00 4.75
Wario Biddybuggy Roller 3.50 4.50
Donkey Kong Sports Bike Roller 3.75 4.25
Wario Sports Bike Roller 4.25 4.00
Wood 4.50 3.25
Biddybuggy Slick 4.50 3.25
Donkey Kong Sports Bike Slick 4.75 3.00
Wario Gold Standard Roller 4.75 3.00
Sports Bike Standard 4.75 3.00
Slick 5.25 2.75
Gold Standard Slick 5.75 1.75
```

Unless you’re going all-in on acceleration, it looks like a heavy character is the way to go; the two heaviest character classes (Wario and Donkey Kong) account for 11/15 of the Pareto-optimal configurations.

We can also look at the other main stats for each of these configurations.

So there it is, if speed and acceleration are your main concerns then one of these 15 configurations is your best bet.

Sometimes an optimal configuration isn’t what you’re looking for though (say, because your roommate threatened to stop playing if there wasn’t some sort of handicap, to choose a random example). In that case, we can explore all the possible configurations with a quick bokeh interactive graphic. I’ll omit the code here, but you can find it in the notebook for this post.