A Machine learning model to understand the game design and player experience of a video game, the Overwatch.
- Introduction
- Challenges
- Motivations
- Model Selection
- Model Architecture
- Input
- Output
- Repo Structure
- Setup
- Usage
The goal of this project is to predict the outcome (winning-rate) of a team in a video game, particularly multiplayer online games like Overwatch/Dota2/LoL, given the status at a certain time in the game, like kills/deaths/team-compositions, etc.
This repo focuses on part of the project, namely, modeling the team compositions (or the heroes) and maps in the game.
-
The dataset is not large enough. We only have the results from less than 300 games.
-
The dataset consist of a lot of categorical features, like team compositions and maps. A simple one-hot encoding can result in high dimensional sparse input and unfortunately we don't have enough data to conquer the curse of dimensionality. Moreover, the team-composition/map plays an extremely important role in the game, so we can't simply drop it.
-
Just like humans (or words), heroes have their own characteristics and also share some similarities. So rather than one-hot orthogonal vectors, they can be represented by distributed representations. What's more, just like words in a sentence, heroes in a team also have strong co-occurrence. So heroes can be modeled in a very similar fashion as word2vec, i.e., hero2vec.
-
The team compositions are widely available online. This is independent of my own dataset and can serve the training of hero2vec just like Wiki corpus used for word2vec.
-
By modeling heroes in the game by distributed representations, I can not only address the curse of dimensionality, but also gain valuable information on the game designs of the heroes as well as the how the players appreciate these designs.
-
All the above motivations apply to the maps similarly, i.e., map2vec.
-
As mentioned above, heroes in a team have strong co-occurrence, i.e., the conditional probability P(h1|h2.., h6) (6 heroes in a team) is high. h1 doesn't have to be a specific hero, any hero in the team can be this center hero. This is very suitable for the Continuous Bag of Words (CBOW) model, since the attributes of a team (or the 5 context heroes) are really a sum of the attributes of all the individuals, unlike the sum of context words in a sentence is not always intuitive.
-
The map in the game can be modeled in a similar way. The conditional probability P(map|team) is high. So the weight of the last affine layer of the classifier is the embeddings for the maps.
-
hero2vec. The model pipeline is as follows:
input context heroes (5 heroes)
->embeddings
->sum
->fully connected layers
->softmax (center hero)
-
map2vec. The model pipeline is as follows:
input team (6 heroes)
->hero2vev embeddings
->sum
->fully connected layers
->map embeddings
->softmax (map)
-
teams.csv
underinput
folder. This is a csv table that contains the team composition. Can be easily changed to other team-based games like Dota2/LoL. -
map_teams.csv
underinput
folder. This the csv table that contains both the team and map composition. -
hero2ix.csv
underinput
folder. This is csv table that maps the input hero names to their int ID and further to the embeddings. Can be easily customized in case different name is used for the same hero, e.g., 'dva' (used in this one) is written as 'D.Va'. -
map2ix.csv
underinput
folder. This is csv table that maps the input map names to their int ID and further to the embeddings.
hero
folder Output contains a graph showing the embeddings (after PCA to 2D) of the heroeshero_embeddings_2d.png
, a numpy array contains the embeddingshero_embeddings.npy
, a graph of the training lossloss_history.png
and pickled modelmodel.p
. For example, thehero_embeddings_2d.png
looks like:
map
folder Output contains a graph showing the embeddings (after PCA to 2D) of the mapsmap_embeddings_2d.png
, a numpy array contains the embeddingsmap_embeddings.npy
and a graph of the training lossloss_history.png
. For example, themap_embeddings_2d.png
looks like:
The directory structure for the repo looks like this:
├── README.md
├── train_hero.py
├── train_map.py
├── inference.py
├── setup
│ └── install.sh
│ └── install_without_torch.sh
├── model
│ └── __init__.py
│ └── hero2vec.py
│ └── map2vec.py
├── utils
│ └── __init__.py
│ └── dataset.py
│ └── evaluation.py
│ └── prediction.py
├── input
│ └── hero2ix.csv
│ └── map2ix.csv
│ └── teams.csv
│ └── map_teams.csv
└── output
├── hero
│ └── hero_embeddings_2d.png
│ └── hero_embeddings.npy
│ └── loss_history.npy
│ └── model.p
└── map
└── map_embeddings_2d.png
└── map_embeddings.npy
└── loss_history.npy
Under setup
folder, run:
bash install.sh
if issues occurs with installing pytorch, please refer to http://pytorch.org/ for installation of pytorch. Then run:
bash install_without_torch.sh
-
Train hero2vec. run:
python train_hero.py ./input/teams.csv ./input/hero2ix.csv
-
Train map2vec. run:
python train_map.py ./input/map_teams.csv ./input/hero2ix.csv ./input/map2ix.csv
-
Predict the center hero given five other heroes. run:
python inference.py <heroes>
.<heroes>
contains the hero names of five known members. For example:python inference.py dva genji tracer lucio winston
. Note: hero names must be in thehero
column inhero2ix.csv
ininput
folder.