Game Design, Programming and running a one-man games business…

The impossible task of country simulation in a video game

As you may know, I make the ‘Democracy’ series of video games. They are pretty serious, pretty complex, fairly in-depth simulation games where you run a real world country. At one point I experimented with fictional countries, but it turns out everyone hates that, they want to be the president of their own country, and show they can do a better job than the current leader. Fair enough.

The only problem with this is it means that I need to simulate real world countries accurately enough that people living in them think I have made a proper effort to do so. This is staggeringly difficult to do with a single (albeit flexible and complex) model of politics and economics. What makes it way more difficult, is that it has to be politically, economically and temporally flexible as well.

Allow me to explain.

Imagine you spend months reading statistics and articles and set all of the values of all of the policies for a single country in Democracy 4, for example the UK, and you get all the various values in the model as close as possible to reality. Unemployment looks about right, GDP looks about right, Wages look about right…and on through literally hundreds of different measures. This is VERY hard to do, and a lot of values need to be flexible in interpretation. For example what level is income tax in the UK? Obviously it depends on how much you earn and many other factors…

…but then the very same model has to work if you change some of those variables. Maybe a player decides to abolish the national health service. Or double the minimum wage. Or scrap nuclear weapons, or introduce a new tax on luxury goods. The same model has to cope in all these circumstances, and it has to be credible over time. The national debt is a certain level NOW, and we know roughly what impact it has, but how do we possibly model what will happen in the future? How do we model the impact of increased automation on unemployment, productivity, wages, and international trade? Ideally a video game is made to be playable for many years. Will Democracy 4 make sense in 2025? in 2030? When we all have self driving cars and teslabots, what do the economics look like?

This is all hellishly hard, but one of the particular aspects of what makes it hard is a thing I’m encountering today. I am taking the first gentle steps into looking at an expansion pack that would add some extra countries to the game, and trying to be more organized, and sensible about adding them so that the model is consistent and makes sense. Its way harder than it sounds.

Take for example: BRAZIL. An exciting country to add to the game, as its so different to the others. I am looking forward to adding a special situation for the amazon rainforest, with all its potential economic boom, tourism value and also massive environmental controversy regarding deforestation. Lots of cool stuff here for a potential Democracy 4 player! But lets zoom in on a single statistic:

What is the correct value for the military spending slider for Brazil?

This is not as simple as it sounds. Its pretty easy to google the military budget of Brazil, in USD terms. Thats 25.1 billion USD with a source here: https://worldpopulationreview.com/country-rankings/defense-spending-by-country. It would be easy thus to look at the UK spending (55Bn USD) and do a relative comparison to where we position the UK slider (42%), and use that calculation to set the Brazil military spending at 19%. However, doing a straight USD comparison is fraught with inaccuracies. I cant even find out if that USD number is actual real USD (ie: the value of the Brazilian reals converted at the current exchange rate to USD) or ‘purchase-power-parity‘, which is a different (and generally better) measure altogether. To put it simple: You can probably pay a Brazilian soldier less in USD equivalent than you would pay a US marine. If a Brazilian soldier can buy a house and clothes and food way cheaper than the USD-equivalent spent in a US town, then in effect your military budget is going further…

One way to adjust for this is to take a second measure, using totally different comparisons. So for example, you can also look at the percentage of GDP that is spent on the military, and use that as a baseline. In this case Brazil spends 1.4% of GDP on defense, compared to 2.2% in the UK. Making that adjustment means that the Brazil military slider turns out to be 28% instead of 19%.

To start with, before I go back and play balance and adjust everything (which will take weeks) I’m setting the initial value for those military sliders to be the average of these two measures, so comparing military spending as % of GDP, then absolute value in USD and then averaging the two slider positions. This gives me the following values:

Greece 29%

Ireland 3%

Poland 26%

Switzerland 9%

Turkey 35%

Brazil 23%

At first look, these seem reasonable. Switzerland is famous for its neutrality. Poland is naturally (given its history) more jittery. Ireland… well I cant remember having ever heard of the Irish military at all. Turkey, given its location, probably thinks it can justify quite a strong military.

You might think this is a paper-thin approximation. You are right. I’m sure multiple people have phds in studying the relative military spending of countries around the world. Sadly, I’m just a video game designer and do not have that time, but I do what I can to get sensible numbers where possible, and have to keep in mind that the first priority of any game is to be fun, not accurate.

Still a lot of stats juggling to go!

Code bloat has become astronomical

There is a service I use that occasionally means I have to upload some files somewhere (who it is does not matter, as frankly they are all the same). This is basically a simple case of pointing at a folder on my hard drive and copying the contents onto a remote server, where they probably do some database related stuff to assign that bunch of files a name, and verify who downloads it.

Its a big company, so they have big processes, and probably get hacked lot, so there is some security that is required, and also some verification that the files are not tampered with between me uploading and them receiving them. I get that.

…but basically we are talking about enumerating some files, reading them, uploading them, and then closing the connection with a log file saying if it worked, and if not what went wrong. This is not rocket science, and in fact I’ve written code like this from absolute scratch myself, using the wininet API and php on a server talking to a MySQL database. My stuff was probably not quite that robust compared to enterprise level stuff, but it did support hundreds of thousands of uploaded files (GSB challenge data), and verification and download and logging of them. It was one coder working maybe for 2 or 3 weeks?

The special upload tool I had to use today was a total of 230MB of client files, and involved 2,700 different files to manage this process.

You might think thats an embarrassing typo, so I’ll be clear. TWO THOUSAND SEVEN HUNDRED FILEs and 237MB of executables and supporting crap, to copy some files from a client to a server. This is beyond bloatware, this is beyond over-engineering, this is absolutely totally and utterly, provably, obviously, demonstrably ridiculous and insane.

The thing is… I suspect this uploader is no different to any other such software these days from any other large company. Oh and BTW it gives error messages and right now, it doesn’t work. sigh.

I’ve seen coders do this. I know how this happens. It happens because not only are the coders not doing low-level,. efficient code to achieve their goal, they have never even SEEN low level, efficient, well written code. How can we expect them to do anything better when they do not even understand that it is possible?

You can write a program that uploads files securely, rapidly, and safely to a server in less than a twentieth of that amount of code. It can be a SINGLE file, just a single little exe. It does not need hundred and hundreds of DLLS. Its not only possible, its easy, and its more reliable, and more efficient, and easier to debug, and…let me labor this point a bit… it will actually work.

Code bloat sounds like something that grumpy old programmers in their fifties (like me) make a big deal out of, because we are grumpy and old and also grumpy. I get that. But us being old and grumpy means complaining when code runs 50% slower than it should, or is 50% too big. This is way, way, way beyond that. We are at the point where I honestly do believe that 99.9% of the code in files on your PC is absolutely useless and is never even fucking executed. Its just there, in a suite of 65 DLLS, all because some coder wanted to do something trivial, like save out a bitmap and had *no idea how easy that is*, so they just imported an entire bucketful of bloatware crap to achieve it.

Like I say, I really should not be annoyed at young programmers doing this. Its what they learned. They have no idea what high performance or constraint-based development is. When you tell them the original game Elite had a sprawling galaxy, space combat in 3D, a career progression system, trading and thousands of planets to explore, and it was 64k, I guess they HEAR you, but they don’t REALLY understand the gap between that, and what we have now.

Why do I care?

I care for a ton of reasons, not least being the fact that if you need two thousand times as much code as usual to achieve a thing, it should work. But more importantly, I am aware of the fact that 99.9% of my processor time on this huge stonking PC is utterly useless. Its carrying out billions of operations per second just to sit still. My PC should be in super-ultra low power mode right now, with all the fans off, in utter silence because all thats happening is some spellchecking as I type in wordpress.

Ha. WordPress.

Computers are so fast these days that you should be able to consider them absolute magic. Everything that you could possibly imagine should happen between the 60ths of a second of the refresh rate. And yet, when I click the volume icon on my microsoft surface laptop (pretty new), there is a VISIBLE DELAY as the machine gradually builds up a new user interface element, and eventually works out what icons to draw and has them pop-in and they go live. It takes ACTUAL TIME. I suspect a half second, which in CPU time, is like a billion fucking years.

If I’m right and (conservatively), we have 99% wastage on our PCS, we are wasting 99% of the computer energy consumption too. This is beyond criminal. And to do what? I have no idea, but a quick look at task manager on my PC shows a metric fuckton of bloated crap doing god knows what. All I’m doing is typing this blog post. Windows has 102 background processes running. My nvidia graphics card currently has 6 of them, and some of those have sub tasks. To do what? I’m not running a game right now, I’m using about the same feature set from a video card driver as I would have done TWENTY years ago, but 6 processes are required.

Microsoft edge web view has 6 processes too, as does Microsoft edge too. I don’t even use Microsoft edge. I think I opened an SVG file in it yesterday, and here we are, another 12 useless pieces of code wasting memory, and probably polling the cpu as well.

This is utter, utter madness. Its why nothing seems to work, why everything is slow, why you need a new phone every year, and a new TV to load those bloated streaming apps, that also must be running code this bad.

I honestly think its only going to get worse, because the big dumb, useless tech companies like facebook, twitter, reddit, etc are the worst possible examples of this trend. Soon every one of the inexplicable thousands of ‘programmers’ employed at these places will just be using machine-learning to copy-paste bloated, buggy, sprawling crap from github into their code as they type. A simple attempt to add two numbers together will eventually involve 32 DLLS, 16 windows services and a billion lines of code.

Twitter has two thousand developers. Tweetdeck randomly just fails to load a user column. Its done it for four years now. I bet none of the coders have any idea why it happens, and the code behind it is just a pile of bloated, copy-pasted bullshit.

Reddit, when suggesting a topic title from a link, cannot cope with an ampersand or a semi colon or a pound symbol. Its 2022. They probably have 2,000 developers too. None of them can make a text parser work, clearly. Why are all these people getting paid?

There was a golden age of programming, back when you had actual limitations on memory and CPU. Now we just live in an ultra-wasteful pit of inefficiency. Its just sad.

VOTING SYSTEMS DLC out now!

So.. at last I finally did it, and managed to get the voting systems DLC released yesterday for Democracy 4. If you want to watch a long video with me rambling about voting systems, boy do I have the video for you:

Also if you fancy grabbing the DLC, you can get it here, or just use the fancy humble widget to buy it direct from me. bwahaha!