[PYTHON] Get Splatoon 2 battle record data + bonus

This is the 7th day article of CAMPHOR- Advent Calendar 2019. The 6th day was @ watambo's "Come to Nakameguro community space CAMPHOR-BASE!"

Hello. It is @asamas. I read it as tomorrow. While everyone is enjoying "Ring Fit Adventure" and "Pokemon Sword", I'm still playing Splatoon 2.

This time, I pulled out the data recorded in "ikaWidget2" which is a Splatoon battle record management application. I will try a simple analysis.

.ikax -> .zip ikaWidget2 has a backup function, and when you output a file from it, a file like ʻasamas-20191204-1011.ikax` is created. This file can be read as a zip file as it is by changing the extension. After unzipping, you will find info.json and stats.realm as shown in the picture below. The battle record data is in stats.realm. コメント 2019-12-06 162516.png

Write the contents of the realm file to json

Install realm studio. After opening the stats.realm file, you can export it with File> Save Data> Json. ~~ I didn't notice this feature and spent a lot of time trying to use realm (nodejs) ~~

Analysis of battle record data

Using this data, I tried to find out what stage I was not good at. First, let's import the json file

# -*- coding: utf-8 -*-
import json

with open("results.json","r",encoding="utf-8") as f:
    result_json=json.load(f)

Examine the differences between the rules. In the example below, we are examining the Gachi area (splat_zonesgachi). If you want to check Gachihoko, change it to rainmakergachi, Gachiyagra to tower_controlgachi, and Gachiasari to clam_blitzgachi.

area_result={}

for item in result_json["Result"]:
    if item["udemae"]<9 and item["game"]!="splat_zonesgachi": #Limited to S or higher battle record&Eliminate rules other than Gachi area
        continue
    for i in result_json["Stage"]:
        if i["ID"]==item["stage"]:
            stage_name=i["name"]
            
    if not stage_name in area_result.keys():
        area_result[stage_name]={"win":0,"lose":0}
    if item["win"]:
        area_result[stage_name]["win"]+=1
    else:
        area_result[stage_name]["lose"]+=1

for key in sorted(area_result.keys(),key = lambda x:area_result[x]["win"]/(area_result[x]["win"] +area_result[x]["lose"]),reverse=True):
    print(key,area_result[key]["win"]/(area_result[key]["win"] +area_result[key]["lose"]))

The result looks like this. Gachi area コメント 2019-12-06 171637.png Tower Control コメント 2019-12-06 174034.png Gachihoko コメント 2019-12-06 174206.png

Mozuku plantation and New Autoro are ranked high in all rules. It's a rule that I'm good at in my Kugel Schreiber. On the other hand, the winning percentage of Zato, Sturgeon, Mutsugoro, etc. is about 30-40%, so you can see that it is a stage that is not compatible.

from now on

This time it was a half-finished article due to lack of time, but now that I know how to extract data from ikaWidget2, I would like to use LightGbm etc. for more detailed analysis.

Recommended Posts

Get Splatoon 2 battle record data + bonus
Get Gzip-compressed data on-memory
Get structural data from CHEMBLID
Get Youtube data with python