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

Making a game with real-world issues

My current project is Democracy 4, a game about politics, at a time when politics is…explosive to put it mildly. Right now we are in the middle of a global pandemic, there are riots going on over America, and countries all over the world have problems with fake news, extremism, extreme nationalism, gun violence and many other problems.

Democracy 4 obviously has to reflect the real world. Its a game about politics, so you cant pretend some issues do not exist because they are awkward. In fact, we are hopefully covering all political issues regardless how divisive they may be. Our game lets you outlaw homosexuality, or lets you allow gender-transition on demand. You can outlaw guns or let everyone have machine-guns. You can close all the airports, you can ban abortion, you can legalize prostitution, heroin and much more.

However, one of the topic in the game that I worry about right now, due to the current news cycle is this one:

Race riots are not new to Democracy 4, they were in D3 too, but it feels weird to experience them in-game at the same time as they are actually happening. It reminds me just how *delicate* such topics are. What are the causes of race riots? Not just in the US, or where I live in the UK, but over the whole range of countries that we hope to cover. This is hard to nail down to a few equations in a spreadsheet… Currently the main causes of them are Racial Tension, Unemployment and Violent Crime. Racial Tension itself has a number of causes, but its linked to high levels of immigration. You can mitigate it with a high standard of living, race discrimination acts and a ‘stamp out racism’ week, which is a subtle bit of social engineering.

I’m trying really hard to make a politics game, not a POLITICAL game. There is no magical code buried inside democracy 4 that tries to arrange things to preach a subtle (or not subtle) ‘racism is bad’ message. As an individual, obviously I have my own views, but as I read more and more online political discussion I find it clear that preaching never convinces anybody of anything.

Democracy 4 is supposed to be a fairly accurate simulation. In it, I’m trying to guess what the causes of events are, and the outcomes and then just represent them. You can see that race riots hit GDP, and upset everyone. They should maybe arguably affect tourism too. They will also upset conservatives, who presumably worry that their houses may get looted in riots?

In general I am a believer that logic dictates treating humans fairly and equally, and that if we follow evidence, data and science, we tend to make good decisions. That includes following maths and economics. In Democracy 4, the player will learn that race riots severely affect their re-election chances, hurt the economy, and can be expensive in terms of the policies required to get them under control (rubber bullets, tear gas, water cannons etc). Someone who wants to *win* at Democracy 4 (constant election wins) will learn not to let any one political group get too angry, and that includes ethnic minorities. Its just simple good politics in the real world too.

I think this is self evident to anybody who plays strategy games. There is always a consequence to every decision, and its good to think long term. If you are playing purely as a capitalist, you might see the need for some seemingly socialist policies just to prevent the social-breakdown and expensive consequences of vast inequality. Sure, you can pay people poverty wages, but if that means you need twice the police force to keep you safe as a result, is it really a net win?

I think its also a powerful argument in environmentalism. Sure, you can hate those hippies who hug trees and bang-on about carbon emissions, but have you SEEN the economic costs of extreme temperatures and food riots/wars/sea level rise that are the consequence of inaction? And for that matter have you seen how cheap electric cars are to run?

There is a persistent myth that Henry ford paid his workers a higher than normal salary so they could afford to buy the cars he made. Thats bullshit. I’ve read several books on ford. They were forced to hugely raise wages due to incredibly high staff turnover, but nevertheless its an interesting myth, that makes a lot of sense. Inequality has an ultimate cost, not just in security, but in terms of its negative impact on the economy.

This probably all sounds unfeeling and harsh, but I think of it as pragmatic. I believe in equal pay for women, equality for all races, and fair pay for workers *on principle*, but the most powerful argument is an argument of self interest, and the hardest argument is the ‘you should do the right thing’. There are a LOT of gun-toting, trump-supporting, right wing electric car owners now, because they finally made fast, sexy, affordable ones that people wanted, Appealing to people to buy them out of guilt never worked.

Nobody sums up this school of thought as well as quark from star trek deep space nine when he constructs an argument for ferengi women being allowed to wear clothes. He argues that if they wear clothes they will have pockets, and if they have pockets they will want to put stuff in them, so they will buy more stuff and stimulate the ferengi economy.

Its comedy, but also true.

I write all this to make a point about the style of Democracy 4 and its intentions. We cover a lot of dark, serious topics, and we do so without comment. There is no flashing symbol reminding you that RACIAL TENSION IS BAD. Adding it would be redundant, and change nobody’s opinion. Decisions in the game have consequences, and learning what those consequences are without further comment, or preaching is, I think, the best way to cover issues like this.

Real World Numbers in Democracy 4

I took some time over the last few days to go through some real world numbers on stuff (specifically government income and spending) and apply them to Democracy 4. The base country for the game, like with earlier versions, is the UK, and we then edit the data and scripts to better represent other countries as we add them.

Its been about five years since Democracy 3, and a lot has changed, so I wanted to make sure the starting scenario for the UK in Democracy 4 was vaguely realistic. We cannot ever be 100% realistic, because the model is obviously a simulation, and one that has to be fun, plus the starting date of the game is left deliberately ambiguous.

Also… we are not starting every country in the middle of a global pandemic, as that would seem super hard, and also fix the game in time in peoples minds. We DO have a virus outbreak event that is quite severe, but may have to introduce an even more severe global event at some point. Anyway…

I had to make some noticeable changes to the amount that certain things cost in the game. I was amusingly almost spot-on with the cost of the BBC, but the cost of some things like disability benefit, and the NHS in general (State Health Service) were almost comically low. Also. OMG national insurance (payroll tax) brings in a lot of money. I found a great source for this stuff here: https://www.ukpublicspending.co.uk/ Here are some charts:

In this chart the first thing that leaps out at me is ‘other’. 14% of spending! that is a big lump of money going somewhere nebulous. Here ius the breakdown:

Which just goes to show there is clearly a LOT of government spending on tiny, tiny things. Democracy 4 doesn’t really have a ‘fisheries’ department costing anything, or street lighting, but I guess eventually all those little thingsd add up.

The next big scary thing is that 6% of government spending on interest. This is us paying interest on our UK government debt. Some interesting charts:

My immediate response to such a chart is ‘yikes’. People often look at debt to GDP, but if government spending as a chunk of GDP is low (heavily capitalist), the debt/GDP can be low while interest/public spending is massively high. I would suggest that the best metric to look at is interest payments / public spending because this is the opportunity cost of debt, in other words, all the stuff you could be funding if you didn’t have to pay interest on debt. Right now we pay 6%, the same as the defence budget. Just for fun, here is the interest / GDP chart anyway…

Of course we live in times with stupidly low interest rates, although that varies massively by country.

Some economists say as a general rule that countries default (which is economically speaking REALLY BAD) when interest/GDP reaches 12%. If our current interest is 6%, then we need a simple doubling of the interest rate to hit that (assuming we balance the budget tomorrow and stop adding to the debt…)

Democracy 4 does not have an option to default on debt, mostly because that seems unthinkable for the USA, UK, Germany, France and other countries we will likely include. But maybe we should? Anyway….lets move on to look at where government income comes from…

I guess the big surprise here is how tiny the business taxes are. The Uk has fairly low taxes on companies (19%), but then we do not have the more generous and complex system of rebates and exclusions a lot of other countries have. Positech is a company, and we pay a simple 19% of our profits, with the only complication being if we get to claim video games tax relief on some portion of our expenses. We don’t qualify for anything else.

Indirect taxes are surprisingly large. I find the breakdown on that site to be pretty crap, so wen to the independent ‘office for budget responsibility’ and got this instead:

2019-20Percentage
Income tax1195.224.40%
of which: Pay as you earn163.220.40%
Self assessment32.84.10%
National insurance contributions140.617.57%
Value added tax134.616.82%
Corporation tax256.77.09%
of which: Onshore55.36.91%
Offshore1.40.17%
Petroleum revenue tax-0.6-0.07%
Fuel duties28.93.61%
Business rates31.63.95%
Council tax35.84.47%
VAT refunds14.51.81%
Capital gains tax91.12%
Inheritance tax5.60.70%
Stamp duty land tax313.41.67%
Stamp taxes on shares3.60.45%
Tobacco duties91.12%
Spirits duties3.60.45%
Wine duties4.40.55%
Beer and cider duties3.80.47%
Air passenger duty3.70.46%
Insurance premium tax6.10.76%
Climate change levy2.20.27%
Other HMRC taxes47.50.94%
Vehicle excise duties6.30.79%
Bank levy2.10.26%
Bank surcharge1.80.22%
Apprenticeship levy2.70.34%
Licence fee receipts3.30.41%
Environmental levies11.71.46%
EU ETS auction receipts0.70.09%
Scottish and Welsh taxes510.12%
Diverted profits tax0.30.04%
Soft drinks industry levy0.20.02%
Other taxes6.90.86%
National Accounts taxes746.293.26%
Less own resources contribution to EU-3.4-0.42%
Interest and dividends10.31.29%
Gross operating surplus43.75.46%
Other receipts3.20.40%
Current receipts800.1

…which goes to show some very interesting stuff. Mostly…UK tax revenue comes from Employees, Payroll tax, Sales tax and a bit of Corporation tax, fuel duty and business rates. The rest is just the remaining quarter.

So a diverted profits tax (basically the google tax) brings in virtually nothing (0.04%) compared to corporation tax as a whole at 7.09%. It looks like I should be tweaking some of the policies in Democracy 4 a lot.

For example right now UK payroll taxes in the game have a max input of only 25% of income tax, they should be 75%! Tobacco and wine taxes should bring in less than they do, and air passenger duty (airline tax) should bring in MUCH less. Also, maybe I need the UK to start off with a few of these policies already in place but super low. For example, we *do* have a pathetic diverted profits tax and a laughably low level of environmental levies…which is sort of a carbon tax. maybe these need to be implemented but at 1%?

Anyway, I guess the interesting point is that most of us voting citizens who claim to be aware of the world have ABSOLUTELY NO IDEA how much the government owes in debt, what it spends, and where it gets its money. In a pop quiz would you KNOW that (in order) the top 3 sources of UK government revenue is Income tax, National Insurance and VAT? Would you guess that the amount of money we raise each year in corporate taxes is only slightly higher than we pay out in debt interest? (56 vs 52 billion).

I find this stuff interesting, and despair at how badly our press does the job of educating us. We need more stats, more pie charts, more line charts, more numbers, and less pontificating about what an MP said on twitter today.

Maybe Democracy 4 can help focus peoples minds of the actual numbers behind politics?

Coding vs Software Engineering

This is a topic I feel strongly about, but at the same time I am very aware that its very difficult to get across in text, because its not something you can really illustrate with a single line of code, or a witty cartoon or a small diagram, so I may go on a bit here…

I have been looking at code *not written by me*, and also talking to friends learning some new stuff who are also working with other peoples code, and have been reading a book on this topic, so my head is full of opinions on the topic of coding versus software engineering. let me first explain the difference.

‘Coding’ is the skill of understanding syntax and principles of how programming works, and slapping together a bunch of code that makes something happen. This is not *that hard*, and in fact yes, you can buy totally serious books that claim to teach you C or C++ in 21 days or less, which is laughable…but yes it does allow you to write code that compiles without errors and does the thing you want it to do.

‘Software Engineering’ is like coding, but much much HARDER. Mostly its about the scalability and long term usability of what you code. Code may ‘work’ in the same way that replacing a key component of an old car with a coat-hanger or a piece of string may *work*, but its likely going to go wrong at some point, nobody else will understand what it is or how it works, and when you try to scale it up, everything may completely fall to bits.

Software engineering is a pain because the best way to really get good at it is probably just experience of writing very large programs again and again and again, with different people, on different platforms, with different requirements, and having people criticize your code, or finding bugs in it, or having to revisit it five or ten years later to fix stuff.

The problem is that to 99% of people, and even 95% of coders, the difference between coding and software engineering is actually REALLY hard to spot. because many coders are managed (especially in the games industry) by non-coders, they aren’t even encouraged to get good at software engineering, because frankly the boss doesn’t know what it is.

When you are working as a coder, in crunch, at a game studio with deadlines, generally speaking the boss wants result X by date Y. The big problem is that result X is really shoddily defined. If ‘compiles and runs and the QA team couldn’t make it crash’ is the criteria, then LOL, yeah done easily mate. Unfortunately anything beyond that level of skill goes unrewarded, because its REALLY hard to spot.

Luckily I’ve worked for some very clever coders. My first coding boss (at elixir) was Dave Silver, who is now a mega-celeb in the world of AI at DeepMind. My second coding boss was James Brown (Lionhead), who now spends his time replicating conways game of life using lego for some reason. Both of them were very clever, and I’m a better coder for working under them. I learned a lot from them, not about *code* (which you can get from a book) but about software engineering.

If you haven’t already read ‘Code Complete‘ I really recommend that you do. Its excellent and is probably step one on the path to this stuff. The next things you should do are to work on a BIG project with other coders, and also work on the complete ‘project lifecycle’. This means, you start off with nothing, and finish when the project has shipped, and gone through multiple updates, ports and patches. Only then do you really know if the architecture choices you made at the start are correct.

A fairly simple blog-post style tip on this stuff concerns feature/syntax use and what I call the ‘gunslinger’ attitude. Take this line of C++:

X = X +1

Pretty much anyone (coder or not) can tell you that this adds 1 to the value of X. You can also write this

X += 1

Which does the same thing actually, and theoretically is very very very slightly faster because X is only evaluated once. However, its dark times indeed if in 2020 we cant expect a compiler to realize this and do that sort of thing for us.. Lets get a bit more vague…

float fInitA = InitA > 0 ? ( float )InitA : 1.f;

WTF? Now I am a C++ coder, so I can understand this… but I have to actually engage my brain to do so, which slows me down. Its not immediately intuitive to my half-asleep brain exactly whats going on here and… It really does not have to be written this way. You can just do this:

float fInitA = (float)InitA;
if(InitA < 0)
{
  fInitA = 1.f;
}

And OH MY GOD THE HORROR, its 5 lines of code instead of one. My god. What a n00b. Obviously this idiot doesn’t know about the C++ ternary operator and its syntax. The fool!

And yet its actually readable, and much easier to debug because its multiple lines allowing for breakpoints. The longer simpler version here is much BETTER code. And thats generally IMHO a principle that you can stick with. The trouble is, some coders adopt a ‘gunslinger’ attitude where they are presumably living out dreams of alpha-male dominance through writing the most complex obfuscated mess imaginable. Believe it or not your job as a coder is to write CLEAR and MAINTAINABLE code. You do not get fined for every line you use, and you do not earn points for confusing the people working with you.

There is a very ‘macho’ culture in programming, built around showing off, and using obscure stuff that you just learned. This is nuts. Just because you learn how to use a certain feature/function/syntax does not mean you HAVE to use it everywhere. I’ve worked with coders like this. Its a nightmare.

Its a worthy goal to write code that someone who isn’t even a programmer can look at and go “errr… I think I can see what you are doing here.”. This is because really GOOD code is code that can be understood by someone you have never met, five years later when a bug has been found and they need to work out if its in that function or not. If you are writing a tiny program thats only 1,000 lines of code and nobody else will ever see it, and you will never edit it then…ok maybe you can hack it together, but a proper software engineer always writes code that can be maintained.

Programming is a HUGE topic, and to get good at it, to get REALLY good at it takes an entire lifetime. I started coding aged 11, which is 39 years ago. I think I’m pretty good at C++ now, but not an expert, and its the only language I’m comfortable with. The internet and its many youtube vids and forums have spawned an attitude that you can learn to code one summer, or during lockdown, and…yeah not really. You can learn to hack stuff together by copying and pasting from stackoverflow…but thats really not proper software engineering.

Its worth saying I’m not exactly at the end of the journey myself yet either. The code for Democracy 4 is *not perfect* by any means. Some bits are hacky, there were some fundamental design decisions I made about 15 years ago with the basis of my GUI library that are embarrassing but still there (of COURSE buttons should be a subclass of window you idiot!), but overall my code gets better with each game.

I coded about 5 games before I realized that having a decent separation and naming convention to keep GUI and Simulation code entirely separate was a worthy thing! I probably coded 8 games before I had a rock-solid translation-management system that meant not a single line of text exists in code. It took me maybe 10 games to get threading to work safely, and maybe another 2 until I had a rock-solid and highly-optimized multi-threading system. I didn’t really start to use the power of macros for about 10 games. I’ve only just (in the last 2 games) really got my code for setting up configurable color palates to be usable.

I had most of the technical knowledge to do all of that stuff about 15 years ago, but to do it *well* and to know how to arrange things, and to set them up to be re-usable, optimized, stable, and readable… thats what those extra fifteen years were spent doing.

The VAST majority of comments you read online about programming, especially games programming are written by coders, not software engineers. They suffer a lot from the delusion that they have mastered code, because (as is natural) they don’t know what they don’t know. Its REALLY hard from a distance to spot the software engineers from the coders, but in my experience the amount of time they have been in the industry, and the number of large completed projects is a really good sign.

A final way of spotting the difference: If a lot of someones code has been copied and pasted from stackoverflow or pastebin then… yeah. Thats not a software engineer.

Democracy 4: Variable slider costs…

An experiment for Democracy 4. The game now differentiates between <10%, <25% and larger policy slider moves with differing political capital amounts, indicated on the slider by red/green if achievable right now. Very happy with this :D. #smallerchangesareeasier

It makes sense that a 5% tweak to income tax (just an example) is easier to get agreed than a 50% rise or cut, and it also makes people stop and think about the various positions they can put sliders on some of the smaller and less dramatic policies. I think the green/red lines surrounding the chunks on the slider are self explanatory?