<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Raffy Santayana on Medium]]></title>
        <description><![CDATA[Stories by Raffy Santayana on Medium]]></description>
        <link>https://medium.com/@raffysantayana?source=rss-62cf88d020d5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*Y9PaZq-5PJ3Ofw-ZDUQLYw.png</url>
            <title>Stories by Raffy Santayana on Medium</title>
            <link>https://medium.com/@raffysantayana?source=rss-62cf88d020d5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 22:51:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@raffysantayana/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Parsing Slippi Files into Pandas DataFrames: Using Pandas Map to Filter Data]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/analytics-vidhya/parsing-slippi-files-into-pandas-dataframes-using-pandas-map-to-filter-data-aebf0dc5e108?source=rss-62cf88d020d5------2"><img src="https://cdn-images-1.medium.com/max/1280/1*CqAeQOCIPcmVRpWx1Y1UBQ.png" width="1280"></a></p><p class="medium-feed-snippet">Filtering Games to Parse Frame Data</p><p class="medium-feed-link"><a href="https://medium.com/analytics-vidhya/parsing-slippi-files-into-pandas-dataframes-using-pandas-map-to-filter-data-aebf0dc5e108?source=rss-62cf88d020d5------2">Continue reading on Analytics Vidhya »</a></p></div>]]></description>
            <link>https://medium.com/analytics-vidhya/parsing-slippi-files-into-pandas-dataframes-using-pandas-map-to-filter-data-aebf0dc5e108?source=rss-62cf88d020d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/aebf0dc5e108</guid>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[esports-market]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[recurrent-neural-network]]></category>
            <dc:creator><![CDATA[Raffy Santayana]]></dc:creator>
            <pubDate>Wed, 12 Feb 2020 16:52:23 GMT</pubDate>
            <atom:updated>2020-02-13T12:49:48.762Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Parsing Slippi Files into Pandas DataFrames: The Metadata]]></title>
            <link>https://medium.com/analytics-vidhya/parsing-slippi-files-into-pandas-dataframes-the-metadata-2efdfcb8562c?source=rss-62cf88d020d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2efdfcb8562c</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[nintendo]]></category>
            <category><![CDATA[super-smash-bros]]></category>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[slippi]]></category>
            <dc:creator><![CDATA[Raffy Santayana]]></dc:creator>
            <pubDate>Sat, 30 Nov 2019 22:35:15 GMT</pubDate>
            <atom:updated>2020-02-12T16:52:50.457Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3KcPZUEg4LfstaQb" /><figcaption>Photo by <a href="https://unsplash.com/@north_of_rapture?utm_source=medium&amp;utm_medium=referral">Paweł Durczok</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Super Smash Bros.</h3><p>Super Smash Bros. is a video game series published by Nintendo where video game characters of different franchises battle it out. The second game of the series, Super Smash Bros. Melee, was released in December 2001. This sparked fun parties, happy players, and heated rivalries. These rivalries grew from friend groups, to local neighborhood challenges, to large-scale tournaments by 2002. If you are interested in learning the history of the Super Smash Bros. Melee competitive scene, I encourage you to watch a docuseries called <a href="https://www.youtube.com/watch?v=NSf2mgkRm7Q&amp;list=PLoUHkRwnRH-IXbZfwlgiEN8eXmoj6DtKM"><em>The Smash Brothers</em></a> produced by East Point Pictures.</p><h3>Tools of the Esport</h3><p>Many players within this community are dedicated to becoming the best player that they can be. There are many fan-made tools and mods to the game for the purpose of either improving the player experience in training or improving the production of content. Some tools allow players to create save states so that they can easily practice a scenario quickly. Others allow content creators to create replays for the audience to enjoy. Today, I would like to highlight one of these tools, Project Slippi.</p><ul><li><a href="https://slippi.gg/">Website</a></li><li><a href="https://medium.com/project-slippi/project-public-release-4080c81d7205">Medium Blog Post</a></li><li><a href="https://github.com/project-slippi/project-slippi">Github</a></li></ul><h3>Slippi Files</h3><p>With Slippi, players are able to record game information such as the stage the players are playing on, the ports the players are using, and the controller inputs for every frame (1/60th of a second) of the game. I will be focusing on the Fight Pitt 9 tournament where all recorded games of this tournament amounts to nearly 2.5 gigabytes of data that will be parsed into dataframes.</p><p>I invite you to reference the <a href="https://py-slippi.readthedocs.io/en/latest/py-modindex.html">py-slippi</a> data dictionary to get an idea of the structure of a Slippi file.</p><p>The source of the data used is from the Slippi Discord using the !replaydumps chat command.</p><h3>The Metadata</h3><p>First things first, here are the libraries we will be using.</p><pre>import pandas as pd<br>import slippi as slp<br>import os</pre><p>To start, the metadata will contain information that is constant throughout a single match. To get the metadata, we must take the filepath of the desired Slippi file and create a Game object. After instantiating the Game object, we are then able to look into the metadata attribute.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nZxEp6KdwSXxULCbzK0KZQ.png" /><figcaption>Navigating to metadata</figcaption></figure><p>You may have noticed that the metadata shows that there are no players within the game. In other words, there are four Nonetype values for each port. In addition to that, information regarding if Team Battle is turned on, what game version is being used, and the selected stage is also missing. Don’t worry! This can be found in the start attribute of the Game object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lgquJs5zSEar3h_4rm3tEQ.png" /><figcaption>Navigating to other metadata</figcaption></figure><p>We now know how to navigate through a Slippi file to get the metadata for a single game. However, a tournament is a collection of games. We will need to create a function to parse all this data. Below is a table describing the columns of the metadata dataframe where each row represents a single game.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SeE1blovz2qKo1B8pecAdg.png" /><figcaption>Metadata Data Dictionary</figcaption></figure><h3>The Function</h3><ol><li>Create the Game object</li><li>Gather the metadata</li><li>Create the dataframe</li></ol><p>To create the game object of a collection of games, we can create a list of all Game objects. However, if we hope to parse all the Slippi files taken at Fight Pitt 9, that is nearly 2.5 gigabytes of data in a single list. In order to alleviate this from memory, we will be creating a list of the filepaths of all games. The goal is to create the Game object of the file we hope to extract data from. Once we are done extracting data from that file, we will overwrite that file with a new file. This way, we will only have one file stored in memory when executing the function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*W-xGKV1jG4vS6ywrZl7RMg.png" /><figcaption>Creating a list of Slippi filepaths</figcaption></figure><p>Now to define our function. We will be using the list of Slippi filepaths as input. Then we will need to instantiate an empty list for each column.</p><p>Note: a codeblock of the full function will be at the bottom of the post.</p><pre>def metadata_to_df(slp_files):<br>    # lists of values to populate dataframe.<br>    dates, game_id, durations, plats, num_players, p1_chars, \<br>    p2_chars, p3_chars, p4_chars, stages, is_teams, is_pal = [], \<br>    [], [], [], [], [], [], [], [], [], [], []</pre><p>Using each filepath we generated in fight_pitt_9 , we will try to create the Game object. In case there is a non-Slippi file in the directory, we will use try-except here.</p><pre>    for path in slp_paths:<br>        count += 1<br>        print(f&#39;Parsing metadata from file {count} of {length}:<br>               {round(count / length * 100, 2)}%&#39;, end = &#39;\r&#39;)<br>      # try to create Game object, else skip it and try the next one<br>        try:<br>            game = slp.Game(path)<br>        except:<br>            print(f&#39;Skip game {count} of {length}&#39;)<br>            continue</pre><p>Finally, we can populate each of our lists. Taking the date, duration, platform, stage, teams settings, and game version is as simple as navigating to the appropriate attributes.</p><pre>        # take the date, duration, and platform data<br>        dates.append(game.metadata.date)<br>        durations.append(game.metadata.duration)<br>        plats.append(game.metadata.platform)</pre><pre>        # get stages played on<br>        stages.append(game.start.stage)<br>        <br>        # is the game a 1v1<br>        is_teams.append(game.start.is_teams)<br>        <br>        # is this a PAL match<br>        is_pal.append(game.start.is_pal)</pre><p>To get the active ports, we will use a list comprehension that will provide the port index of the player. With that information, we are then able to create a list of four elements. Either the character that the player is using or None if there is no player at that port index. This makes it easy for one to determine how many players are in the game.</p><pre>        # get active ports<br>        ports = [game.start.players.index(port) if port != None else<br>                  None for port in game.start.players]</pre><pre>        # get characters<br>        characters = [game.start.players[port].character if port !=<br>                       None else port for port in ports]<br>        p1_chars.append(characters[0])<br>        p2_chars.append(characters[1])<br>        p3_chars.append(characters[2])<br>        p4_chars.append(characters[3])</pre><p>Once we have finished parsing the last filepath in the input list, we can return our dataframe.</p><pre>    # return metadata DataFrame<br>    return pd.DataFrame(data = {<br>            &#39;game_id&#39;: game_id,<br>            &#39;date&#39;: dates,<br>            &#39;duration&#39;: durations,<br>            &#39;platform&#39;: plats,<br>            &#39;p1_char&#39;: p1_chars,<br>            &#39;p2_char&#39;: p2_chars,<br>            &#39;p3_char&#39;: p3_chars,<br>            &#39;p4_char&#39;: p4_chars,<br>            &#39;stage&#39;: stages,<br>            &#39;is_teams&#39;: is_teams,<br>            &#39;is_pal&#39;: is_pal<br>        })</pre><h3>Creating the DataFrame</h3><p>All that is left to do is to create the dataframe! Call the function we just made and assign it to a variable. Then walk away and take a well-earned break. The amount of time instantiating each Game object quickly adds up.</p><pre>df = metadata_to_df(fight_pitt_9)</pre><h3>The Function and DataFrame</h3><p>As promised here is the full codeblock and a screencap of the first 5 rows of the resulting dataframe.</p><pre>def metadata_to_df(slp_paths):<br>    &#39;&#39;&#39;<br>    Of a collection of games, store the metadata as a dataframe.<br>    <br>    slp_paths (list): each value is the file path to games<br>    returns a dataframe<br>    &#39;&#39;&#39;<br>    # Used to determine how far along the function is while waiting<br>    length = len(slp_paths)<br>    count = 0<br>    <br>    # lists of values to populate dataframe.<br>    dates, game_id, durations, plats, num_players, p1_chars, p2_chars, \<br>    p3_chars, p4_chars, stages, is_teams, is_pal = [], [], [], [], [], \<br>    [], [], [], [], [], [], []<br>    <br>    # For each filepath in the provided list of filepaths<br>    for path in slp_paths:<br>        count += 1<br>        print(f&#39;Parsing metadata from file {count} of {length}: {round(count / length * 100, 2)}%&#39;, end = &#39;\r&#39;)<br>        <br>        # try to instantiate the Game object, else skip it and try the next one<br>        try:<br>            game = slp.Game(path)<br>        except:<br>            print(f&#39;Skip game {count} of {length}&#39;)<br>            continue<br>            <br>        # set game ID<br>        # to get file path using game_id:<br>        # ../folder_directory/Game_[game_id].slp<br>        ident_strip = slp_paths[count - 1].split(&#39;/&#39;)<br>        game_id.append(ident_strip[-2] + ident_strip[-1].strip(&#39;Game_&#39;).strip(&#39;.slp&#39;))<br>        <br>        # take the date, duration, and platform data<br>        dates.append(game.metadata.date)<br>        durations.append(game.metadata.duration)<br>        plats.append(game.metadata.platform)</pre><pre># get active ports<br>        ports = [game.start.players.index(port) if port != None else None for port in game.start.players]</pre><pre># get characters<br>        characters = [game.start.players[port].character if port != None else port for port in ports]<br>        p1_chars.append(characters[0])<br>        p2_chars.append(characters[1])<br>        p3_chars.append(characters[2])<br>        p4_chars.append(characters[3])<br>        <br>        # get stages played on<br>        stages.append(game.start.stage)<br>        <br>        # is the game not a 1v1<br>        is_teams.append(game.start.is_teams)<br>        <br>        # is this not a v1.02 match<br>        is_pal.append(game.start.is_pal)<br>    <br>    # return metadata DataFrame<br>    return pd.DataFrame(data = {<br>            &#39;game_id&#39;: game_id,<br>            &#39;date&#39;: dates,<br>            &#39;duration&#39;: durations,<br>            &#39;platform&#39;: plats,<br>            &#39;p1_char&#39;: p1_chars,<br>            &#39;p2_char&#39;: p2_chars,<br>            &#39;p3_char&#39;: p3_chars,<br>            &#39;p4_char&#39;: p4_chars,<br>            &#39;stage&#39;: stages,<br>            &#39;is_teams&#39;: is_teams,<br>            &#39;is_pal&#39;: is_pal<br>        })</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XOhYtXnn3tc9ysCX0Vig4Q.png" /></figure><h3>Coming Up</h3><p><a href="https://medium.com/@raffysantayana/parsing-slippi-files-into-pandas-dataframes-using-pandas-map-to-filter-data-aebf0dc5e108">Next</a>, we will filter these games using the created dataframe to only contain Fox vs. Falco on Final Destination.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2efdfcb8562c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/parsing-slippi-files-into-pandas-dataframes-the-metadata-2efdfcb8562c">Parsing Slippi Files into Pandas DataFrames: The Metadata</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>