HoI4 Game Analysis Mod – Analyzing the Usage of Different Aspects in a Game in Depth

A stat logger and parser for the video game Hearts of Iron IV by Paradox Interactive

Hearts of Iron IV

Hearts of Iron Iv or just HoI4, is a popular realtime strategy game. It both supports single and multiplayer.

The setting is before the second world war, you pick a country and either replay or write a different history, every game can be completely different.

As a country you build up your economy, infrastructure, political sphere and army.

There are two main areas where you decide what you want to do, the national focus and research tree.

Both influence the strength of your country and army.

Why is there a need for this tool

In 2020 TommyKay, a popular YouTuber, hosted the first ever HoI4 international tournament.

Here two players fought against each other with a limited number of resources.

With this tool it would be possible to analyse the game better and find out more e.g., at which point there was a rapid decline of resources of one player, and how that played out in the end.

Also the game does not have a fixed path you need to take, you can focus on military or not focus on anything and do everything in equilibrium.

This means that there is no “best way” of playing, this tool allows to compare the playstyle of two strategies against each other.

How does it work

The games has logging capabilities built in, but none of them are realized in the base game except for in-game use.

I needed to create an in game event that logged the stats of every country to a specified file, and then read that. To my knowledge that was never done before and the documentation was also very sparse.

After creating the module, the game will be logged every in-game month to a file.

This file contains raw text and a lot of useless information that need to be filtered out.

After filtering the remaining lines need to be cut and parsed into variables and that into a struct. These structs get pasted one by one into a .csv file.

A .csv file represents a table, where every line is a row and every column is separated by a “,”. Most spreadsheet programs support these files as an import or even a regular format.

By importing the data could be used to build graphs and compare values.

Code

The code is being hosted on GitHub under c-jaenicke / hoi4-game-analysis

The mod is both available on Steam and the Paradox Forums.

Last modified 2021.06.14