Using Big Data Technologies to improve own Gaming

Esports is arising more and more and the desire to become a better gamer obsesses many of the engaged players outside. But taking it to the next level is not that easy and requires many hours of “work”. As data are already being used to achieve performance improvements in the “real world”, why should gaming not use it as well?

I am a passionate F1 follower and impressed by the data-driven approach the teams are taking these days and wanted to build something similar for myself. I am by far not the best digital driver on earth, but had fun to start such a project. I was quite surprised how easy it is to make a real-time dashboard work and use it for race/gameplay analysis.

In Formula 1, data are already one of the key success factors for professional teams in the real world. Gathering all data, analyse the driver’s performance and contribute to improvements is only something we know from TV, but all this is also possible with the F1 2020 game as well in our living rooms.

This is a 7 step guide on how to build a real-time dashboard for F1 2020 data analysis. All the code which is needed is stored and accessible on GitLab. Following things will be required:

  • Basic Python Programming Knowledge
  • Codemasters F1 2020 game (in my case on PS4)
  • PC/Mac/Linux-Server where the data gathering will happen (in my case Mac)

Basic architecture

1. Set the UDP Streaming Option

In the F1 game, there is an option in the settings to enable UDP Streaming. Specify the respective port and IP address. This is important that your Websocket later on will receive the packages sent by the game.

2. Establish a Websocket Server

Secondly we have to create a Websocket in Python to be able to receive the packages from the F1 2020 game. I created a Python module “TelemetryServer” wich is called and activated in the main.py file. Once we run this code, the TelemetryServer asks for a session name and after entering one, the Server is listening to any packages sent to the respective Port. The packages which are being sent to the Websocket are structured differently and also arrive in a different cadence. All the details w.r.t the package structure and frequency can be derived from the F1 2020 documentation: https://forums.codemasters.com/topic/50942-f1-2020-udp-specification/

3. Save packets to a database

For the real-time dashboard we have to store the data in a database. The optimal and quick solution for it is InfluxDB, which is a Time-Series-Database and is optimal for this use case as it also has a good integration with Grafana – a real-time Dashboard for visualizing the data in low latency. Additionally, I also used in my code a MySQL database to store certain data in a structured form for later analysis. Any data queries are easier done through SQL than using the proprietary language by Influx.

Configure the InfluxDB using following manual: https://docs.influxdata.com/influxdb/v2.0/get-started/

The SQL database file will be automatically created by Python.

4. Display the data in a Live Dashboard

In order to display the data in real time, we are using Grafana as it is well integrating our InfluxDB. Follow the steps here and check if your Dashboard is working.

5. Integrate InfluxDB into Grafana

The integration of your InfluxDB into the Grafana Dashboard is fairly easy. Just follow the steps layed out here: https://docs.influxdata.com/influxdb/v2.0/tools/grafana/

6. Configure your Grafana Dashboard

Then, start configuring your live dashboard using the various build-in capabilities in Grafana. Make sure to set your refresh-rate to a low number so that your dashboard is as fresh as possible.

7. Start Streaming Data

The last step is to just start a session in F1 2020 and see what your Websocket is recording. Open the Grafana Dashboard and enjoy driving while afterwards or during the session being able to analyse the various data.

As we are also saving some data to a SQL database, I analyze my data and build correlations afterwards in a jupyter-notebook to understand the differences between certain laps in terms of telemetry, steering, etc.

I hope it helped a bit to summarize the steps necessary to build a realtime dashboard.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s