[Python] Analyze Splatoon 2 league match data using a correlation coefficient table

[Python] Analyze Splatoon 2 league match data using a correlation coefficient table

Introduction

The battle record data of Splatoon 2 is stored on Nintendo's server for the last 50 games, and can be confirmed with the official app "Squid Ring 2". In "ikaWidget2", which will be described later, this battle record data can be downloaded and saved, and statistical data such as the average value of kills and deaths and the winning percentage for each stage can be obtained. On websites such as "Splatoon Club", more detailed statistical data can be obtained by using the data saved in "ikaWidget2". However, most of these statistical data are based on the results of each individual, and ** there are few analysis tools that focus on the interaction within the team in the 4-player mode "League Match" **. In this article, we will create a library that calculates the correlation coefficient table of the scores within our team in "League Match" and analyze the match using it.

What is Splatoon 2

Overview

a23d1ef3b585f79db54f5797e1f5173db5b04ee5d149d8db7ed0f1db44cd3794.jpg Splatoon 2 is an action shooting game released by Nintendo on July 21, 2017. As of October 2020, more than 10 million bottles have been sold. It is a very popular game that is updated regularly even now, more than three years after its release.

specification

The player becomes a character dressed as a squid (or octopus), and fights by painting ink with weapons such as water guns and rollers. It can also be defeated by spraying ink on the enemy (kill). The defeated player will be revived in about 10 seconds. Since all rules are 4v4 team battles, cooperation within the team is important. If you paint the stage with your team's ink, special points will be accumulated and you will be able to use powerful "special weapons". However, if the enemy defeats you, the special points will be halved.

rule

Nawabari Battle

The team that paints the ground wider than the opponent within the time limit wins. Basic rules in Splatoon.

Gachi area

Compete for the time to occupy the "Gachi area" placed on the stage with your own ink. A game in which the Nawabari battle is localized and the victory or defeat is set according to the occupation time.

Tower Control

The team that gets into "Gachiyagra" and gets close to the goal of the opponent team within the time limit wins. You can advance "Gachiyagra" by riding on the top, but it will be a good target from the enemy.

Gachihoco Battle

The team that picks up a huge water gun called "Gachihoko" and brings it closer to the goal of the opponent team within the time limit wins. A player with a "Gachihoco" will be able to shoot a powerful "Gachihoco Shot", but the position will be lost from the enemy team, making it easier to be targeted.

Gachiasari

Pick up the "clams" scattered on the stage and put them in the goal of the opponent team to compete for points. Since the goal is initially protected by a barrier, you must collect 10 clams to make a "gachiasari" and destroy the barrier. If you destroy the barrier, you will be able to put clams in the goal of the opponent team for a certain period of time.

League match

A mode in which you can create a 4-person team with your friends and play against other teams. In the league match, you can play with four battle rules: "Gachi Area", "Gachi Yagra", "Gachi Hoko Battle", and "Gachi Sari".

What is the correlation coefficient table?

Correlation coefficient

The correlation coefficient is an index from -1 to +1 that indicates the strength of the relationship between two variables. When the correlation coefficient is positive, there is a "positive correlation", and when it is negative, there is a "negative correlation". When there is a positive correlation, the two variables have a so-called "direct proportionality" relationship, and when one increases, the other increases as well. When there is a negative correlation, contrary to the positive correlation, when one increases, the other decreases. For example, the relationship between height and weight shows a strong positive correlation, and the national unemployment rate and economic growth rate show a negative correlation.

The relationship between the absolute value of the correlation coefficient and the strength of the correlation is as follows.

Correlation coefficient abs(r) Correlation strength
0.7 ≦ abs(r) There is a strong correlation
0.4 ≦ abs(r) ≦ 0.7 There is a correlation
0.2 ≦ abs(r) ≦ 0.4 There is a weak correlation
0 ≦ abs(r) ≦ 0.2 Almost no correlation

図1.png

Correlation coefficient table

The correlation coefficient table is a table that summarizes the correlation coefficients between each of the two variables. 図2.png The figure above is a table of correlation coefficients for variables A, B, C, and D. Due to the characteristics of the correlation coefficient table, the values at the lower left and upper right of the table are line targets.

The value at the intersection of the row and column of a two variable is the correlation coefficient of that two variable. For example, the correlation coefficient between variables B and C is 0.27. 図3.png In this way, when there are many variables to handle, the relationship between each variable can be described in an easy-to-understand manner by using the correlation coefficient table.

ikaWidget2

ikaWidget2 is Nintendo's unofficial Splatoon 2 analysis app.

App Store : https://apps.apple.com/jp/app/ikawidget-2/id1271025591 Google Play : https://play.google.com/store/apps/details?id=com.flapg.ikawidget2&hl=ja

You can download and store the last 50 games stored on Nintendo's server, and get statistical data such as the average value of kills and deaths and the winning percentage for each stage. The figure below is the actual screen of ikaWidget2. S__58793988.jpg ikaWidget2 also has an external data output function and supports json and csv (extension .tcsv) formats. This time, the correlation coefficient table is calculated using the csv output from ikaWidget2.

environment

Method of calculation

The structure of the csv file of ikaWidget2 is shown below. 図4.png Common data are the start date and time of the game, the stage, the game mode, and the like. After the common data, player information such as kills and deaths is arranged in the order of yourself → ally → enemy. Since the order of ally data is different for each match, it is necessary to link ally data with individual friends when calculating the correlation coefficient table of league match from this data group. This can be done using the Splatoon 2 username, but changing the Nintendo Switch username will also change the Splatoon 2 username, which is not universal and lacks versatility. Here, the "Principal ID" is used for linking. The "Principal ID" is a user-specific value and does not change even if the user name is changed. Since this value is internal data, it cannot be confirmed in the game, but it can be obtained from the file output from ikaWidget2. If you can organize the number of kills and deaths by friends, you can easily create a correlation coefficient table with the .corr () function of pandas.

Download and install

The Splatoon 2 League Match Correlation Coefficient Spreadsheet Library "splatoon_league_corr" created this time has been uploaded to GitHub and PyPl.

GitHub : https://github.com/JmpM-0743/splatoon_league_corr.git

If you install from PyPl, you can install with pip.

pip install splatoon_league_corr

How to use the library

splatoon_league_corr provides the following classes and functions.

class ika_data

Player data storage class.

constructor

def __init__(self,pid,jpname,usname)
Member variables Description
pid Player's Principal ID
The Principal ID is internal data and cannot be confirmed in the game,
Can be obtained from the tcsv file etc. output from ikaWidget2
jpname Name displayed when outputting the correlation coefficient table
usname Name displayed when outputting the battle record data list

Example of use

player = splatoon_league_corr.ika_data('824a58fc35365d11','Maruya','maruya')

class team_data

A team class consisting of four ika_data.

constructor

def __init__(self,player,friend1,friend2,friend3)
Member variables Description
player Data of the person who output the tscv file
friend1~3 Friend data of the same team

Example of use

myteam = splatoon_league_corr.team_data(player,friend1,friend2,friend3)

calc_corr_number_of_games(filename,save_dir,myteam,n)

A function that outputs an Excel file (result.xlsx) of the correlation coefficient table with the number of games as an argument.

argument Description Mold
filename Path of the tcsv file to enter str
save_dir Directory name to store output data (automatically generated) str
myteam team_data class team_data
n Number of games when calculating the correlation coefficient table int

Example of use

splatoon_league_corr.calc_corr_number_of_games('ikaWidgetCSV_20201009231053.tcsv','output',myteam,50)

calc_corr_days(filename,save_dir,myteam,datemin,datemax)

A function that outputs an Excel file (result.xlsx) of the correlation coefficient table with the duration of the match as an argument.

argument Description Mold
filename Path of the tcsv file to enter str
save_dir Directory name to store output data (automatically generated) str
myteam team_data class team_data
datemin、datemax Match period (datemin-datemax) when calculating the correlation coefficient table
Described in YYMMDD.
str

Example of use

splatoon_league_corr.calc_corr_days('ikaWidgetCSV_20201009231053.tcsv','output_date',myteam,'20200901','20201030')

Analysis results and discussion

Below is a correlation coefficient table for 50 games in the Gachi area of my team. 図6.png In this table, each variable during the match is a value per minute to prevent the value from shifting due to knockout.

Variable name Description
win Win / Loss of Match: 1 win and 0 defeat
EnemyUdemae Enemy team average Udemae
Udemae:Something like a rank in one-player play mode
Kill/min Number of kills per minute
Death/min Number of deaths per minute
PaintPoint/min Painting points per minute
Special/min Number of special weapon activations per minute

As an example of the analysis, I will describe what can be understood and what is likely to be understood from this table.

(1) Variable pair with a large correlation coefficient

The correlation coefficient between PaintPoint / min and Special / min of Friend 2 is 0.77, which is the largest value in the table. The correlation coefficients of these two variables are also high for players and other friends. As mentioned above, the special weapon can be activated when a certain amount of painting points are accumulated, so this result can be said to be valid. スクリーンショット 2020-10-12 220747.png

② Variables affecting victory

The variable with the strongest correlation with victory is Friend 1's Kill / min, but other player friends are similarly high and do not stand out. This result is also valid because it is self-evident that "the more kills you have, the easier it is to win." Conversely, the player's Death / min has the strongest negative correlation, with a correlation coefficient of -0.61. This value is large compared to other friends, and it can be said that it is easy to lose when the player is dying frequently.

図7.png

③ Correlation regarding enemy Udemae

Analyze how the strength of the enemy changes the turn of the ally. Here, the characteristics of each individual are more apparent than before. For example, when the enemy's Udemae is high, it is natural that "kills decrease and death increases", but friend 1 has no correlation with the enemy's Udemae and the number of deaths, and friend 3 has no correlation with the number of kills.

Friend 1 often has a rearguard weapon, and it is thought that death will not increase because it is easy to fall to his own side when an avant-garde ally is killed. While he is alive properly, the negative correlation of the number of kills is the largest in the team, and it can be seen that he is struggling when the enemy is strong.

Players have a slightly higher correlation between fill points and specials than other friends. If the enemy is strong, you will not be able to defeat it, so you can see that you are trying to fight with a special by painting the ground. スクリーンショット 2020-10-12 224152.png

④ Consider the correlation within the team

Finally, let's analyze the correlation within the team. The figure below is a correlation coefficient table focusing only on the number of kills. Looking at this table, it can be confirmed that only the player has almost no kill correlation with friends other than friend 1. In other words, the player's kills have no effect on the number of kills of other avant-garde weapons (friend 1 is the main rearguard weapon as mentioned above). Although it is not clear from this table alone, it is thought that it indicates that the player is floating from the front line and conversely fighting at a position in front of the front line. 図8.png

Summary

--By using ikaWidget and Python, it is possible to calculate the correlation coefficient table of league match data. --By using the correlation coefficient table, it has become possible to visualize the interactions within the team that could not be understood only by the kills and deaths of each individual, and the playing situation of each individual.

Recommended Posts

[Python] Analyze Splatoon 2 league match data using a correlation coefficient table
[Python] Scraping a table using Beautiful Soup
Let's analyze Covid-19 (Corona) data using Python [For beginners]
Create a data collection bot in Python using Selenium
Data analysis using Python 0
I tried to analyze J League data with Python
[Treasure Data] [Python] Execute a query on Treasure Data using TD Client
A memorandum about correlation [Python]
Data analysis using python pandas
Try to analyze online family mahjong using Python (PART 1: Take DATA)
How to update a Tableau packaged workbook data source using Python
[Python] Read a csv file with a large data size using a generator
Data acquisition using python googlemap api
I made a Line-bot using Python!
Create a python GUI using tkinter
Drawing a silverstone curve using python
Creating a simple table using prettytable
[Python] Multiplication table using for statement
I tried Python! ] Titanic data _vol.1 (bar graph, scatter plot, correlation coefficient)
Created Simple SQLite, a Python library that simplifies SQLite table creation / data insertion