Analytics Methodology (Using Python and Matplotlib)
To collect analytics info during the playing process, we defined several events to be tracked. When a player reaches specific steps, the events will be triggered and user playing data would be sent to the server.
Copyright By PowCoder代写 加微信 powcoder
For example, the main gameplay of our game is the drink mix process. When the player finishes mixing and serves the drink to the customer, we will send analytics related to this serving (e.g. base/modifier/flavoring selected, requirements satisfied, etc.).
We export our analytics as raw data (json format). After we save the exported data, we need to parse and plot on it. We use Python to process data, then utilize matplotlib visualization library to plot charts with much more customized features, for example, color, title and legends.
# import library
from matplotlib import pyplot as plt
# define plot function
def plot_pie_chart(labels, counts, title):
plt.figure(figsize=(6, 6)) # set figure size
counts, # set values
autopct=lambda x: str(x)[:4] + ‘%’, # set percent format
labels = labels, # set labels
plt.title(title) # set chart title
plt.legend() # display legends
plt.show() # show the plot
# call function to plot
labels = [‘ ‘, ‘Fire Breath’, ‘Flower Elixir’, ‘J & K Whiskey’, ‘Szechuan Sauce’, ‘Tomato Juice’]
counts = [15, 4, 34, 8, 11, 7]
title = ‘Which base is selected?’
plot_pie_chart(labels, counts, title)
In the demo code above, we define a function to plot the pie chart with given arguments, then pass parameters and call the function to plot. As you can see, we want to plot the pie chart to show the proportion of each base drink the player selected. After execution, you will see the chart.
Midterm Analytics
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com