Clash Royale Card Synergy: A Network Analysis Tutorial
Network Analysis
Data Visualization
igraph
R
A network analysis tutorial exploring card synergy in Clash Royale using Season 3 deck data.
Authors
Affiliation
Kevin Euyoque
St. Lawrence University
Ivan Ramler
St. Lawrence University
Published
Invalid Date
Please note that these materials have not yet completed the required pedagogical and industry peer-reviews to become a published module on the SCORE Network. However, instructors are still welcome to use these materials if they are so inclined.
Welcome Video
If you are unfamiliar with Clash Royale, you can watch this short gameplay video for an introduction to the game:
Introduction:
Clash Royale is a real-time strategy mobile game developed by Supercell in which players build decks of eight cards and compete in one on one battles. Each card represents a troop, spell, or building with distinct mechanics and strategic roles.
Success in the game depends heavily on card combinations, as certain cards perform more effectively when used together. Because of this emphasis on synergy, Clash Royale provides a natural setting for studying relationships between elements using network analysis.
NoteLearning Objectives
By the end of this tutorial, you will be able to:
explain how a card-pair dataset can be represented as a network
convert a matrix of card relationships into an edge list
build and visualize a weighted network using igraph
interpret what a card synergy network suggests about the Clash Royale meta
NoteActivity Length
This module could be used as a short in-class lab, a longer out-of-class assignment, or part of a larger unit on network analysis and data visualization.
a class period
NoteMethods
Technology Requirement:
This activity is designed to be completed in R using RStudio and Quarto.
Some previous experience with data wrangling in R is helpful, but no previous experience with network analysis is required.
add a hyperlink that sends the reader to the page for each package
Data
The main dataset used in this module is cr_season3_5000decks.csv, which contains deck-level Clash Royale data from Season 3. Each row corresponds to a card appearing in a specific deck, along with whether that deck won.
We will reshape this data so that each deck becomes one row and each card becomes its own column. From there, we will calculate how often pairs of cards appear together, how often those pairs win, and their overall paired win rates.
Rows: 40000 Columns: 3
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): card
dbl (1): id
lgl (1): winner
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# Now need to remove the self-pairsdiag(clash_deck_n) <-NAdiag(clash_deck_wins) <-NAdiag(clash_deck_rate) <-NA
# convert the table into an edge listpair_data <-as.data.frame(as.table(clash_deck_n)) |>rename(card1 = Var1, card2 = Var2, decks = Freq) |>mutate(wins =as.vector(clash_deck_wins),winrate =as.vector(clash_deck_rate)) |>filter(card1 != card2)# Only show decks that have been used more than 50 times# this allows for only prominently used decks meaning more important# 1572 rows totalpair_data <- pair_data |>filter(decks >50)
# any win rate above 50% convert to a 1 and under to a 0clash_deck_ratebinary <-ifelse(clash_deck_rate >0.5, 1, 0)diag(clash_deck_ratebinary) <-0
# Shows all the cards available to use # including if they have an evo and/or hero upgradecards <-read_csv("clash_royale_cards_125.csv")
Rows: 125 Columns: 5
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (2): card_name, type
dbl (1): elixir
lgl (2): evolution, hero_upgrade
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Network Representation
To represent Clash Royale synergy as a network, we will model the data as a graph.
# Build the network graphnetwork <-graph_from_data_frame( pair_data,directed =FALSE)network
In this we see there are 69 cards that pass the greater than 50 decks filter
69 nodes
There is a total of 1572 card pair connections
1572 edges
Nodes
A node represents one Clash Royale card.
Examples of nodes could be:
Hog Rider
Fireball
Miner
Ice Spirit
In the network, each card appears once as a node.
Edges
An edge represents a connection between two nodes (two cards).
In this module, an edge means:
The two cards are commonly used together and they perform well together based on paired win rate
So if two cards have strong synergy, they will be connected.
Edge weights
Edges can also have a weight, which measures how strong the connection is.
For Clash Royale synergy, the edge weight will be the paired win rate for that card pair.
Interpretation:
Higher paired win rate β stronger connection
Lower paired win rate β weaker connection
Why use a network?
A network is useful here because it lets us study:
which cards connect to many others
which groups of cards form groups of synergy
how the meta might be structured through relationships, not just individual win rates
There are over 37,235,730,424,788 possible unique deck combinations
(Pick 16 cards from the dataset for which we will use, go back to adjacency matrix, only 16 nodes and only have edges for nodes with higher than 50% win rate)
make an exercise using diff win rates diff cards for new matrix
# Filtered more decks since network too dense# show only strongest edgespair_data_small <- pair_data |>filter(decks >290, winrate >0.50)network_small <-graph_from_data_frame(pair_data_small, directed =FALSE)# gives layout more time to spread outlay <-layout_with_fr(network_small, niter =5000)# plotplot(network_small,layout = lay,vertex.size =8,vertex.label.cex =0.75,edge.width =E(network_small)$winrate *4)