• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

EU4 - Development Diary - 9th of April 2019

Bonjour everyone! It is I, Le French Paradox and I will be your host for this Dev Diary.

Today we will talk about Tech Debt. As @DDRJake has been saying, tech debt has been an important focus for the EU4 team since the release of 1.28.3, the latest support patch we did for the Spain update. While our designers are thinking very hard about the yet-to-be-announced big expansion that is to come, we programmers have been busy tidying up the EU4 codebase.

tidying up.jpg

Microsoft should team up with Netflix, I would watch the hell out of this show

Jokes aside, we keep talking about Tech Debt but realize it might be a bit confusing, especially for our non-programming crowd.

While EU4 was announced at GamesCon 2012, the actual development started a year before, which makes the code 8 years old. And of course, the team at the time didn't reinvent everything, bits were pulled from EU3, some of which are still in use today. I'll let you speculate which is which in the comments.

As I'm sure you all know, technology is a rapidly evolving thing, and software engineering is no exception. In 10 years the development practices have evolved, both because the industry keeps learning and inventing new ways to solve problems, and because the ecosystem (the hardware and software that runs our games) also changes.

10 years ago, SSDs were not that widespread, 1080p was pretty new, DirectX 10 was all the rage in previews and most people were so hostile to Windows Vista that they kept running XP in 32 bits.
That is not to say that EU4 was using only stuff from the late 2000s or early 2010s until now. Over time our engineers have done their best to keep the game up to date, but some stuff inevitably slips through the cracks. It's the accumulation of all this aging stuff that we call tech debt(*).

Here's a few examples of those things that we have tackled so far.

64 bits
As the BattlePope already explained in a past DD, 32 bits was a reasonable choice when EU4 development started, but today 64 bits in the norm.
With that done EU4 will keep running with the next update of MacOS (which removes 32 bit compatibility altogether) and also be able to use more RAM. While there are no immediate plans to increase the memory usage of the game significantly, mods that add a lot of provinces and tags should be able to break the previous ceiling.

Rendering
It is no secret that our games do not use cutting edge graphics. True to its board game heritage, Europa Universalis is mostly about showing a world map with some cool dudes (and elephants) fighting on top of it. Yet if you take a look at the Imperator preview, you will see that our graphics experts have learnt a trick or two since EU4's release.

2xnk41.jpg


While Boromir is (was?) right, we still managed to replicate some of the improvements they have made. The main one is that the colorizing of the provinces on the map is now done mostly on the GPU, while in the past it used to consume precious CPU cycles to display whatever horrible experiment in bordergore your game was about.

capture.PNG

Let's play 7 differences, can you spot what changed from the current release in this beta screenshot?

Crash reporter
Our game never crashes, it just tactically exits. Yet when it happens, we want to know all about it. It helps our QA to reproduce the issue and our programmers to isolate the piece of code responsible and fix it.
Since EU4's release our engine team has made a new and improved crash reporter that brings us more data and help find problems faster. First of all, it now works on Linux and MacOS, meaning we will be able to investigate issues on those platforms much easier. Secondly, it allows us to add some metadata to the dump, such as the current year, the list of enabled mods or how many 6/6/6 heirs died to a hunting accident, helping us understand what triggered the issue.

Startup time
Improving the loading time of the game is something we always want to do. While we can't really apply the best fix to the issue (discontinue Windows support, the game just starts so much faster on Linux and MacOS, trust me), we managed to find some things we could do.
The most notable one was the upgrade of PhysFS, a 3rd party software that a lot of videogames use to load all resources (files on disk, mods, DLCs...). While still far from Unix performance, it should shave off a couple seconds from the startup time on Windows.

capture.PNG

Experienced Byzantium players recommend playing on Linux or Mac due to the very fast restart time

General performance
The speed of the game is, of course, always a concern. Every night, we run a couple games on benchmark machines and always make sure that the averages are below a certain value (80ms per in-game day is our current high threshold).
While you may think that performance would improve over time (due to new hardware for example), in practice the average usually go up during the development phase of a new expansion, and is then worked upon to bring it back to acceptable values.
Contrary to popular thought, adding new features in the game is not the only (or even main) source of performance regression. In fact, one big factor is simply the addition of tags and provinces.
Consider this: for every two countries in the game, a bunch of stuff needs to be computed each in-game day (relations, AI attitude...). For every two provinces in the game, the game has to know the way from A to B (what we call pathfinding). This is known as a quadratic problem. For those who don't favor math, it means that for X provinces, the problem complexity is X squared. Doubling the number of provinces does not double the number of computations needed, it quadruples it. Over the years, part of our job has been to allow EU4 to grow from around 2000 provinces to more than 4000 provinces.
Keep in mind though that in software engineering an optimization that makes something 0.1% faster is considered pretty good, 1% excellent and 10% probably means you introduced a serious bug (or fixed a very serious one). How do we manage to improve anything with those numbers? Simple: all those add up in the end.

That's all for today! Should you like to know more meaty details of the tech stuff, you can check-out my blog where I get into more practical details about development practices.

Next week we should return to a more classic Dev Diary by our designers, unless you can help me convince Jake to revamp the wine trade good to include grape kinds and soils and finally settle which of the Burgundian or Bordelaise tradition of winemaking is the best.

(*) It's a bit more complicated than that but should be enough for the sake of this diary
 
Last edited:
I agree with the fact that this game is probably made with a bit old stuff, I changed laptop recently and can't play the game anymore because of UI problems ahah, I hope improvments are planned ! Would be a shame if I can never again play one of the best game ever
 
When a unit moves from one province to another, only the path between those two provinces is needed
yes, but HOW does the unit decide its destination in the first place? this is what @MatRopert was referring to.
 
One of the more recent changes I find very annoying is the game restarting when you exit. It should be an option whether or not you allow it
 
It's actually quite easy to reproduce without a save. Just make sure your army enter a province while an enemy leaves the province on the same day. But because of your tag id is lower on the country id list than the enemy, means he will move first on the same day. But on the UI will say there will be a battle.
This is why you should play as Sweden :)
Joking aside that's an interesting analysis, I'll forward it to the team.
 
If you guys have a save where we can reproduce it please make a bug report.
It's what happens when the defender leaves the province on the same day as the attacker enters. My understanding is that their relative tag-orders can allow the defender to flee before the game processes the attackers move into the province.
The problem is that the battle tooltip doesn't take tag-order into consideration, and always favours the attacker by default.

It can get really annoying to play a modded nation/recently added tag, because they are lower than everyone else, and so get unfairly nerfed. I do understand though that a rework of the tooltip check and the tag-order balance would likely be quite time-consuming to develop, although my personal idea for a solution would be to have tag-order for army movement be tied to leader manoeuvre, and an impasse of stats would favour the defender.
 
How did you set up the benchmark machines?

I have a couple of extra computers to spare and would like to set them up to benchmark a mod

Figured I could use both linux (bunsenlabs debian linux or Ubuntu) and windows 10 LTSB on them

I'd appreciate any help or insight you have @MatRopert
 
In a way I like that it takes a lot to reload. It makes cheating more costly for me: "Yes, I could restart until I get that perfect start, but this above average one is fine" or "My army was stack wiped by bad dice rolls and I'm raging, but man, do I want to wait 20 mins to try again? Nah..."

PS: I'm definitely exaggerating
The issue isn't for save scumming - where your right that it "punishes" you for it it's mostly annoying when I click the wrong button (like going into multi or hitting new game when I mean to load into one) and then have to wait for the whole game to load. Or if I'm in multi and there's some sort of server issue where I have to go back into multi or whatever and I have to reload the whole game.
 
Ι am not a programmer, so this might be a stupid question:

Wouldn't it be possible to make it be multithreaded for everything in single player and keep the current form of single threading results that need to be the same for everyone in multiplayer to avoid desynchs?

That way SP where most people play on speed 4 or 5 is faster and Mp where most play speed 2 or 3 is same as now, but it doesn't matter a lot.

The Point MatRopert made was not that you can not utilize multithreading because that would create problemsd for multiplayer, but that there are a lot of things that can not utilize multithreading because of program logic. Mutliplayer desyncs was just meant as an example what would happen if you tried to do those things in seperate threads anyway. But it would create lots of other problems in SP as well.

So no, that would not make sense.
 
Of course it's not a dev diary that adresses the gameplay issues that part of the community eagerly wants being fixed, and it's been quite a while since we've heard news on that front so I'd be happy if it were adressed, but it was a funny dev diary that gives me hope that the game would be better optimised in the future.

I'm also looking up for some "tech transfer" with the Imperator team, one thing that's a pet peeve for me is the planar representation of the map (earth in EU4 is a flat cylinder), which induces major distorsions especially near the poles (and I don't mean Poland but rather Scandinavia ;) ). Will we see progress on that matter? I don't really care about the scroller being flat, but having distances distorted is quite horrible and seriously affects gameplay, including, but not limited to, travel time and coring range.
 
It's actually quite easy to reproduce without a save. Just make sure your army enter a province while an enemy leaves the province on the same day. But because of your tag id is lower on the country id list than the enemy, means he will move first on the same day. But on the UI will say there will be a battle.

Did a quick search and I couldn't find a thread on bug reports forum.

To give some background information, we fixed a bug on this for 1.17. The UI used to always say there was gonna be a battle, even if there wasn't. This was fixed so that the UI would use the same calculations as the game whether there would be a battle or not.
If I remember/understood it correctly, it used to decide if there should be a battle or not based on the tags. Not the index of the tag, but alphabetical order.

After initial testing on it now I could at first not reproduce your bug, but after some additional testing I found something that might be plausible (but I don't fully know until a programmer confirms it):
The game decides if there should be a battle or not, based on index of tags
The UI says if there should be a battle or not, based on the alphabetical order of tags

If this is the case, something either changed or broke since that patch (or it never worked properly).

What I am trying to say, if you ever have bugs, even if they are super obvious to you, please please please make a thread on the bug reports forum and attach saves.
 
Wouldn't it be possible to make it be multithreaded for everything in single player and keep the current form of single threading results that need to be the same for everyone in multiplayer to avoid desynchs?

That way SP where most people play on speed 4 or 5 is faster and Mp where most play speed 2 or 3 is same as now, but it doesn't matter a lot.

The problem is a bit more complex than MP which is the most easy one to see.

But for instance, let say that income and expense are multithreaded. I could be earning cash but because I spent all my cash on building an army, I have 0 left. Then, if the expense is calculated first, I will need to take a loan, while it would not have been true if I got the income first or if I got both at the same time.

In battle you cannot make one side hit before the other as it would randomly give advantage to one side...
There are a lot of thing that cannot be multithreaded while some are easy and some might be hard but possible.
 
Probably stupid question but, will any of this tech debt *theoretically* open the lower end of supported hardware slightly?

Cause been relegated to computer running an integrated gpu in the intel chip, and for whatever reason EU4 is the only one it crashes on (runs great with ck2, hoi4, vic, all the older versions of games aswell)
 
The "return to menu" is a legacy from EU3 in which going back to the menu after you start playing will result in a different checksum.
In EU4 it was quickly addressed by the "exit and restart to menu".
We have been wanting to fix it entirely for quite some time now but I can't make any promises as the cost is expected to be high and we have to prioritize it along many other things we could also look at (and, of course, the gameplay content of the next big patch).
Then again we also thought that we would never manage to make hotjoin work and in the end we did, so who knows?

I understand the original reason for forcing a full restart of the game due to changing meta-data through various forms.

What I would really like to have is a button after clicking new-game to exit fully to desktop and not restart EU4.

For example, If I am just browsing mini-map and changed my mind to not play right now. My currently ONLY option, for a good while now, is to alt+tab and kill EU 4's process.

Here what I am talking about. You can see I only have "back" button on the bottom left. I have nothing UI-wise to tell the game to exit to desktop and don't restart. We have been asking for a long long long time about this by now. There is no excuse to not implement an exit to desktop here; as that would wipe the checksum/metadata clean.

529DF0A657179FB4C034BF01070E8725BD09C58A