Predicting Melee with Slippi and Logistic Regression
Does the name Fizzi mean anything to you? If you’ve ever enjoyed the 2001 classic Super Smash Bros. Melee (referred to as simply ‘Melee’), maybe it should.
For most of you reading this, Melee likely occupies only a small corner of your mind and memory. Perhaps it was the game of choice between a handful of friends on some distant night. Or maybe it was a fun timekiller in the early 2000s. Many of you may be more familiar with the most recent release of the Smash franchise, namely Ultimate.
For a surprisingly sizable portion of the gaming world, however, Melee has been the end-all, be-all fighting game since its release. The competitive scene behind Nintendo’s beautiful accident has a long and rich history of tournaments and tribulations, wherein professional players compete for prize pools in the realm of tens (or even hundreds) of thousands of dollars.
In recent times, the dedicated grassroots scene surrounding the game has gotten crafty in terms of ways to play. Most recently, thanks to the help of some very devoted and hardworking tech-savvy community members, anybody can play Melee online with smooth, rollback netcode, a feature that many modern games fail to replicate, through a project called Slippi.
Fizzi is the mastermind behind this and other developments. Working on modding the game full-time, he has also managed to bring to the scene complex statistics unlike those ever seen for Smash previously, essentially revolutionizing the ways in which audiences and competitors alike can analyze the game.
Being the generous god that he is, Fizzi has allowed his online service (coupled with the statistics and replays of every game you play — more on that later) freely available.
Being a massive fan of the game myself, I’ve been thoroughly enjoying the comfort and convenience associated with playing Melee online via Slippi.
Having enjoyed the game in my offtime for about a week or so (I don’t know why I didn’t hop on the Slippi train earlier, to be honest), I’ve since become curious as to one question: Can a machine learning algorithm predict the winner of a game of Melee before it ends?
In order to find this out, I turned to my own (relatively small and unrepresentative) set of some 220 replays (generated by Slippi). My play was to create a logistic regression to predict the winner between two players using only data collected in the first 3 stocks taken. The data, of course, would come from Slippi’s very own statistics calculations.
In order to conquer this task, I first had to learn to handle the .slp
file format in which all replays are saved. Luckily, the Project Slippi GitHub page provides some tools for exactly this purpose. I found that Slippi-js was the most useful of the parsing libraries available.
There was one glaring (and I mean glaring) issue with this plan, however: I don’t know JavaScript. Just Python. There exists a python library to parse .slp
files, but from what I can see, it is much less complete and would require me to do much of the heavy lifting that Slippi-js can already do.
Thus, in order to complete this project, I had to scrape up just enough JavaScript knowledge to combine with the sample code from Slippi-js’s GitHub page to extract all the data from each of my 220 logged games. The data is extracted in the JSON format and can easily be saved in text form to a .txt
file on disk, which is nice. In case you don’t know, JSON objects are essentially just Python dictionaries.
I also had to install Node.js. I don’t know what this does, or how it works, but I did it.
After successfully creating the 220 .txt
files, I was able to convert the data into Python dictionaries, once again in the safe land of a familiar programming language.
From here, it was just a matter of extracting the first 3 stocks of data and training a model to predict the winner. A full list of the data extracted is found at the bottom of this article. Additionally, you can visit this GitHub repository in order to see more details about the project (as well as peek at all of the code used to create this model and the following image).
In the meantime, here are the ROC curves for the testing data of a four-fold cross-validation performed using my model.
For those of you who don’t know what any of this means, I’ll explain. The ROC curve (shown here in red) represents the True Positive Rate and False Positive Rate across different threshold cutoffs. Here, “positive” just means player 1 won, and negative means player 0 won. That may not mean anything to you, but just know this: The closer the red line hugs the upper left corner, the better the model is performing. This can also be seen with the AUC (area under the curve): The closer the AUC is to 1, the better the model is performing.
So, overall the model is performing relatively well. In fact, the model was able to predict the correct outcome of Melee games in the testing data around 78.4% of the time on average. This is a good deal better than the baseline model (a basic model that always predicts the majority no matter what), which only had 56% accuracy.
Overall, I’m satisfied with this project. I could, of course, do much more by collecting more data from more games (and more players), as well as adding more features (engineered or otherwise) to reduce the bias. One large project could be to implement a way to gather 3 stocks worth of data in real-time so that I could generate predictions as to the winner of a game as it was still being played. Useful? Maybe not. Fun and interesting? For sure. I’ll probably return to Slippi data in the future, but this initial exploration was a great exercise for my data extraction and modeling skills.
List of features used by model:
- Duration of the first three stocks in frames
- Number of deaths for player 0
- Number of combos for each player
- The average and standard deviation of combo length (number of moves) for each player
- The average and standard deviation of combo damage for each player
- Combos per kill for each player