MTGO-Tracker: Compiling and Analyzing Gameplay Statistics on Magic Online

Problem


Communities of Magic: the Gathering Online (MTGO) players track match results data to get a quantifiable measure of player/deck strength. This process is done manually and often requires the effort of multiple people. Can this process be automated and can we further the scope of our analysis to include in-game actions and decision-making?

Collecting Data


MTGO saves a log in the form of a *.DAT file (found in it’s AppData folder) at the conclusion of each match. These logs contain each string that was printed to the screen in the in-game client, along with machine-readable formatting. We want to convert this information from raw text into a relational database.

Raw MatchLog File.

Building a Solution


Parse log files using Python:

  1. Parse the *.DAT file, stripping away the excess formatting and converting to a list of strings.
  2. Iterate over our list of strings, creating records (in the form of a list) to be added to one of three dataframes (Matches, Games, Plays).
  3. Repeat for each *.DAT file found in MTGO’s AppData folder.
Iterable List of Strings.
Relational Databases.

From here, we could simply export to Excel or CSV, relying on the user to manually input key information that is not explicitly stated in the MatchLog files (deck names, match format), but I wanted to create a GUI application to make this tool as accessible as possible. I also felt more could still be done in terms of automation.

Building GUI

The interface was written using tkinter and displays the relational databases created using our parsing solution described above. The user can make manual changes such as revising/removing records from their database, filtering, or exporting their data.

Predicting Deck Names:

The idea here is that for each match, I had a list of each card played by each player. If I had access to every decklist, I could compare my lists of “cards played” against each decklist and score their similarity to come up with a “best guess deck name”.

  1. Write a script to scrape decklist repositories, saving decklists as a Python dictionary. Export using pickle.
  2. Compare “cards played” list against each decklist.
  3. Calculate similarity scores as a percentage of matching unique cards. Return deck names with scores > 20% as possible matches.
  4. Return deck name with the highest score as the best guess.
Calculating Similarity Scores.

Built-in Dashboards

While users are able to export their data and create their own visualizations, I wanted something available in the application to quickly perform exploratory data analysis. Dashboards displaying summary statistics were created using pandas to filter and manipulate data.

1 of 6 Dashboards available in-application.

Tableau Dashboards


Player Profiles – Tableau Public

Match Performance – Tableau Public

Game Actions Breakdown – Tableau Public

Sideboarding Stats – Tableau Public