Use Python and Heat-Maps to prepare Chicken Dinner

Mayur Rahangdale
cybercz.io
Published in
4 min readNov 1, 2018

Winner Winner Chicken Dinner [1/100]

“person holding riffle near post” by Kony Xyzx on Unsplash

According to an article from statista.com “ In early January 2018 the PUBG reached 2.9 million concurrent players on Steam. According to the estimates, the battle royale game developed by Bluehole crossed the one million concurrent player mark in early September 2017, and on September 23 the game managed to break DOTA 2’s record on Steam, reaching 1.52 million peak concurrent players that day.”

Number of peak concurrent players of PlayerUnknown’s Battlegrounds (PUBG) on Steam worldwide as of January 2018 (in millions)

The stats really show the extreme growth in number of users. It’s like a forest fire. Ultimately, though, that’s the economic reality of this industry. Esports is a feeding frenzy, and latching onto a title like Battlegrounds is just another means of survival. There are plenty of horror stories about esports companies drying up overnight, just like there’s plenty of triumphs of companies getting rich off the right players and the right game.

So, what magical recipe is there behind creating such a game. How do these companies attract Top Gamers? Well, there’s really not any magic, it’s all mathematics! Let’s unveil all the facts we can derive using statistics one by one.

In this part, we’ll be looking towards the best strategies to win the game using previous player data.

Download the prerequisite Datasets using this link:

Let’s start by importing required python libraries.

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import os

Extract the dataset folder in your working Directory. If you are working with windows, there is no need to change file path. But if you are working with Linux OS , you will need to change filepath and replace double backslashes with a frontslash.

print(os.listdir(os.getcwd()+'\\pubgstats'))
train = pd.read_csv(os.getcwd()+'\\pubgstats'+'\\train_V2.csv')

You can check whether there are any null values in the dataset. Pandas chose to use sentinels for missing data, and further chose to use two already-existing Python null values: the special floating-point NaN value, and the Python None object. This choice has some side-effects, as we will see, but in practice ends up being a good compromise in most cases of interest.

train.isnull().values.any()# list all the columns to know your datasetlist(train)

(Note: DBNO means Downed but not out)

Now, we will be using seaborn to plot out heatmap.

import seaborn as sns

f1 = (
train.loc[:, ["winPlacePerc","killPoints", "killPlace", "kills", "DBNOs", "headshotKills", "assists", "longestKill","heals", "revives" , "teamKills" ]]
).corr()
plt.figure(figsize=(14, 12))
sns.heatmap(f1, annot = True)

DataFrame.loc is used to access group of rows and columns by label(s) or a boolean array .loc[] is primarily label based. Target feature labels are added to f1. The 0–1 scale refers to 1 being the won condition.

Heatmap 1

Studying this heatmap, we can get the conclusions that :

Most fighting features seem to matter.
killPoints (Kill Rating for Ingame Statistic/Leaderboard) are not that important.
teamKills are friendly fire kills.
killPlace is the most Important feature so far.

[Note: If you still can’t get the plot, try importing matplotlib instead of matplotlib.pyplot and then use class reference as plt.pyplot.figure()]

Let’s create another heatmap with features related to player movement.

f2 = (
train.loc[:, ["winPlacePerc","winPoints", "maxPlace", "numGroups", "walkDistance", "swimDistance" , "rideDistance", "roadKills", 'vehicleDestroys', "weaponsAcquired" ]]
).corr()
plt.figure(figsize=(12, 10))
sns.heatmap(f2, annot = True)
Heatmap 2

What do we see here? For surviving as long as possible (high winPlacePerc):

  • maxPlace (almost) equals numGroups, so one of both features is enough.
  • walkDistance seems very important, which makes sense: you can only walk around if you are still alive!
  • Same for swim and rideDistance but not that important (swimming is slow and riding a car is very loud so enemys could hear you better)
  • The second most important feature in this Heatmap seems to be weaponsAcquired
  • The winPoints you gain are not that much connected to your actual surviving time

Conclusion of the analysis:

To survive longer in PUBG, you should be able to fight well, but also acquire many weapons.In general walking should be the preferred way to move.

Even Noobs know this :)

Source code and rendered python notebook is available at:

https://github.com/mayurcybercz/PUBG-data-analysis

--

--