Hello everyone, it’s time for another Dev News post and another update release!
All of the u-turns have been grinding players’ gears since the beginning of the Alpha - sometimes intersections were being blocked without good reason since trucks just didn’t know how to make left turns out of side roads or into side roads.
I realize there is still a lot of things we can do to make traffic better, but I think releasing this week’s Alpha with left turns is a good step in the right direction
Most video games nowadays are especially taxing on the graphics card, while the CPU is pretty relaxed in comparison. However, this is often different for simulation games: Games that simulate thousands or tens of thousands of different people, cars, ships, etc. often run into degraded performance in mid-game or end-game because the processor has trouble handling that many entities at once.
In recent years, processor’s clock speed hasn’t gotten any faster - instead manufacturers have made processors with many cores. That seems like a good solution - but in order to use all these cores, developers have to write code multithreaded, so that the game can calculate many things in parellel.
Multithreading can be a difficult technique and it’s a lot more challenging to make a game’s code multithreaded when the game is already far in development. That’s why with InfraSpace, I have taken great care to design the traffic system in a way that can be multithreaded more easily. Until now, we ran this design on a single thread, but this week I changed it to be executed in parallel. Check out these pictures to see what’s happening under the hood!
This is what a single frame looks like before the change:
The blue bars represent the time our code takes - mostly for traffic simulation - while the green bars represent the time the computer takes to render the world. The first row is the main thread and you can see it does all the work, while the other threads are pretty much idle.
This is what a single frame looks like after the change (more zoomed in):
You can see that the main thread has a lot less to worry about since all the other threads take a large part of the work and split it between themselves. Please note that the second screenshot is a lot more zoomed in: This frame only took about 3.3ms, which is a lot quicker than the singlethreaded version with 14.5ms!
(Full disclosure: I also optimized the graphics by rendering the road system and the cars more efficiently. That’s why you also see a reduction of rendering time in these screenshots)
In my tests I got up to ~200 fps for a city with 2,400 inhabitants. We still have some room for more improvements, so I’m hoping we’ll be able to support some huge cities in the future!
During all this work, Andreas has taken some first steps to switch more buildings from our “first draft” version to a shiny new model. Check out the first teaser images:
You can download the current Alpha from the main menu of the game or from the email you received when signing up to be a playtester.
I hope you have fun with the left turns and let me know if you have any issues with the multithreaded version or if the performance upgrade went well!
Next week I’m hoping to get rid of some of the car bugs