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

Democracy 4: Resizable GUI

For the last week or two I have been working on what seemed like it might not be too bad…but actually turns into a lot of work. This is a resizable GUI for Democracy 4. The current version of the game has fixed size UI elements everywhere which works fine for the old school screen res from maybe 1280×768 up to 1920×1080, but starts to get a bit annoyingly small text at 2560 plus, and frankly the UI can be a bit too big and blocky at the lower res too. I finally got around to fixing this.

The first day or so was wasted trying to find an automated solution. Democracy 4 uses SDL2 and OpenGL, and I was hoping some of SDLs scaling functions would handle this simply. I could easily implement a scaling slider in the game, and then SDL could just handle a final stretching up or down at blit/flip time of a fixed resolution image.

This failed to work. partly because of some messy implementation at my end perhaps, but also because screen aspect ratios can change. Even if it DID work, it would basically mean throwing away the core UI upgrade of Democracy 4 over 3, which is super-smooth fonts and pixel-perfect vector-based icon and UI element rendering. If the player set the render scalar to anything but 100%, any sort of stretching would give a slightly blocky look. I couldn’t live with that.

In the end, I did implement all this as a simple percentage slider on the games options screen. Changing this requires a reboot to see the effect:

In order to get all this to work I just had to make a LOT of small code changes. Probably every UI file in the project got changed in the last week. What I needed to do is get rid of what coders called ‘magic numbers’ and replace them with values that could be scaled up or down based on this slider. For example code that said this:

int iconleft = Area.left + 120;

Would be changed to something like this

int iconleft = Area.left + WIDE_SIDE_PADDING;

The all-caps value could then be coded as defaulting to 120, but be scaled up or down by a global value for RenderScaling, which is decided when the game starts. This way I could reuse that value anywhere in the game and know it would always be the right value. Because I’m not entirely useless, luckily I HAD actually defined and used a lot of named values already like this:

int iconleft = Area.left + STYLEGUIDE_BLOCKPAD;

So in that case no code change was needed, and that value (10 as a default) could be easily scaled at app startup. The problem was… I had not stuck to this, and actually used a LOT of magic numbers (ie: actual numeric values) many, many places in the code. I ended up just having most of the common ones defined as pixel constants:

int iconleft = Area.left + STYLEGUIDE_PAD50;

For example. A bit kludgy, but some values really are used in random places and giving them stupid names like STYLEGUIDE_MINISTER_)SCREEN_TOP_WINDOW_HEIGHT would be overkill if you ask me. In any case, after a LOT of typing and also a LOT of testing, I am very close to declaring this done, and letting users play with it. Its not perfect, because a lot of combos don’t work. If you are playing at a small res like 1280×768 and set the slider >100%, things will overlap and look rubbish. But I’m hoping people are sensible. This is a FIX for people who dislike the default layout for high or low resolutions. Its assumed 95% of players will not touch the slider.

Anyway here is the game in the current (unscaled) view in 2560 resolution and default 100% scaling:

(Its reduced by 50% for here). Check out how small the text is for the finances, and how much space I waste on the timeline at the top. Now here is the exact same screen resolution, but with a 133% slider:

To me this looks WAY better, but you are only REALLY going to appreciate the change if you have a high DPI but smallish monitor, or an insanely high res monitor and poor eyesight. At first glance, you might not be able to tell the difference, but then check out that timeline at the top to see just how things are re-arranged. or check on the far left near the top, the ‘POPULARITY’ text.

Anyway this is coming to the next update for the game. it took a while, but it really needed doing!

Japan’s economy in Democracy 4: making sense of irrational economics

So… I am currently working on adding Japan as a playable country to Democracy 4, which is still in Early Access. Although I think Japan is super interesting in many ways, especially cultural (very conservative on prisons, super-generous on maternity leave, amazingly high percentage of retired people, very high tech, super-low immigration…), its economics are absolutely batshit crazy. Lets look at some numbers.

Tokyo: the latest stock market darling | Business| Economy and finance news  from a German perspective | DW | 16.01.2018

The current GDP of Japan is 559 trillion yen and its debt is currently 1.328 quadrillion yen, which gives us a debt to GDP ratio of 237%. The country in 2019 (pre-covid) had a deficit of 17 trillion yen. Compare this to the USA in 2019 which had a GDP of $21 trillion, debt of $22trillion, which is a ratio of 104% and a deficit of under $1trillion.

The USA has the dollar, which is the reserve country of the whole world, and I think its fair to say both countries have fairly similar stability in political terms. They are both monetizing this debt by using some form of quantitative easing. The US flirts with helicopter money, but the amounts are relatively small. I think its fair to say the biggest difference between the two is that the US debt to GDP ratio is dramatically lower than that of Japan. In other words, its riskier to lend money to Japans government than the US< by quite a margin, as the economy of Japan looks way less likely to repay that debt than the US. This *should* be reflected in the interest people demand to lend to Japan. lets look at 10 year government bonds:

United States 10 year bond yield: 1.59%

Japan 10 year bond yield: 0.09%

HELP. At this point I feel that someone like me with a decent (but hardly expert) understanding of economics is basically in this position:

Pied Piper

This makes no sense. Would you lend any money to the US government for just 1.59% return? me neither, especially when just splatting the money onto the S&P500 would get you 13.6% a year over the last 10 years, but OMG why on earth would anybody lend money to the Japanese government for 0.09%. It makes no sense, and much more fundamnetally than this..it breaks the simulation for my game Democracy 4!

Basically the game has hard coded into it the attitude of the international bond market when it comes to government debt. The general principles of the code are that every six months the bond market evaluates your country and looks at the debt/gdp ratio, the deficit/gdp ratio, the level of ‘stability’ and inflation in the country, and then decides on what the credit rating should be. The interest rate on the debt is then applied, based on that credit rating. The game assumes that the maximum conceivable debt/GDP ratio is 250% (Japan has broken this!). As the game stands right now, a few turns into a new game on Japan instantly triggers a really bad debt crisis:

The game also assumes that this upsets everybody, really badly, but in fact, this may be outdated because it seems that people generally seem very unconcerned by the size of japans debt. This is possibly because right now the world has other concerns with covid, and also because we have had a post-2008 general global credit crunch which has meant global use of QE to the extent that global interest rates have collapsed. Every country has bad debt and low interest rates, which maybe makes japan look not so crazy…

But it still should be WAY worse than the USA. Japan *is* in a debt crisis, and the way in which it seems to be given a free pass on staggering levels of debt is baffling…and yet this needs to be somehow handled in democracy 4… Hence we reading a lot, and looking for some justifiable ‘fudge factor’ I can code into the game that justifies all this. By any standard Japans credit rating should be something like D right now. In fact… its A.

The clearest explanation i have found so far is “A large portion of wealth is held by seniors who lack financial literacy and prioritize stability rather than return” (source). This also states that most Japanese govt debt is owned by Japanese citizens. This kind of implies I need to hard-code in something that says ‘Japanese tendency to not realize they are making shit investments’, as a modifier to boost the credit rating of Japan. That can’t be right!

There is an argument for saying that the country is more stable, and less vulnerable to external pressure on its debt because its mostly owned by its own citizens. The current economics of the game are actually giving Japans super-high debt about the right impact on the finances, so the problem is mostly that the debt crisis is triggering when it probably should be put off a bit by these factors.

So I suspect my actual solution here is to add a special modifier (domestic debt ownership) for the debt crisis situation , but leave the credit rating and interest rate stuff alone. I suspect this works because although the current bond yield on japans debt is super low, some of it will be much older and potentially paying out higher amounts.

Anyway….fun fun fun. I guess its different to balancing games with laser guns and magic spells.

Where do the wishlists for my game ACTUALLY come from?

I was this many days old when I discovered this stuff… Anyway, I have been trying to boost sales of Democracy 4, as you do, and thus have been experimenting a lot with the UTM tracking cookie stuff that steam now supports. The results have been mixed, and complex, and not the direct topic of this quick blog post, but one thing did come out of my analysis…

I’ve been tracking a bunch of different ad campaigns I have been running since the 6th april. Lots of spreadsheet crap later, I concluded that I can trace the relative effectiveness of multiple ad campaigns that have led to to be able to vouch for 167 wishlists adds for Democracy 4 during this period. Unfortunately there is a problem with this number:

In that period, Democracy 4 had over 8,000 new wishlists. That means I’m fussing and huffing over a stupid <2% of the total. Why do I give a damn about these -ad-generated wishlists when clearly I am getting so many more from other sources. But where?

The first place to look at is the graph, to see if we had any actual notable spikes in wishlist adds during that period:

Clearly the answer is YES. Around 30th april to the first few days in may there was a big spike in D4 wishlists. Its not earth shattering, but its pretty good. Sadly steam has no way of telling me directly where they came form, unless they came from people using UTM tracked links, which clearly they were not, or I would have spotted them earlier. So I had a hunch this might be youtube related, as I have done some promotion to youtubers lately. I narrowed down a google search for “youtube democracy 4” with a super tight date range, and the top hit was a bunch of lets play videos from a Turkish youtuber. How can I tell if this is the spike?

Well… this is what I learned today. You will not find this information ANYWHERE in the wishlist stats pages for steam. You might imagine if it was anywhere, it would be there…but no. To be fair, its explained in the steam docs, but its hardly intuitive. If you go to the regional sales reports for each app, and look at each country and then expand the little + icon you find it…

So as I understand it, I got a 2,600% increase in the usual number of wishlists per-day from Turkey over that period. Its actually *not a lot* in revenue or wishlist terms, but the percentage difference is pretty eye popping. This is handy because its not just saying I made $x extra revenue thanks to this youtube coverage, but also potentially more due to the wishlisters who would hopefully then buy the game on sale later.

Of course thats interesting…but it begs the question as to how effective is it compared to ads, and if its effective enough, how to encourage it in future. I got about 8,000 wishlists over my examined date range, and 513 seemed to come from this youtube vid. Total Turkish wishlists were 965, so over half of them came because of one youtube vid. That means its DEFINITELY worth trying to repeat that in other countries.

And of course there lies the issue. How to get youtubers to play my game? And not just the wannabes with 5 followers and 2 views per video (1 to check it uploaded, and 1 from your mother). This is the real problem. You can get your game in front of a lot of youtubers with ads on keymailer, but still, thats just a capsule. How to really get across to them that this is a GOOD video for lets plays?

FWIW I think the game is unusually good for youtub,e but especially twitch. You can literally poll your viewers on what laws to pass or spending to cut/increase. What could be better for hilarious results and interaction with your viewers? The trouble is, finding a way to tell that direct to youtubers without just shoveling money at PR companies to pester them for me. I’m still not 100% sure on the ROI there. (its so fuzzy).

Food for thought anyway. BTW if you *do* want a key and have thousands of followers/views, you can see our keymailer link here:

Updated Democracy 4 to build 1.28. Lots of super cool balance tweaks.

Soooo… I just uploaded the latest build of Democracy 4 everywhere, after 2 days of non stop testing. Lucky I did that because I found a few little visual anomalies that I could fix straight away, like some missing text in one dialog, and some occasionally ‘leaky’ underlined buttons in other places. Anyway…apart from some (minor) bug fixes, this was mostly a big run through all the stats in the game balancing things. First here is the complete list of changes:

1) Removed duplicate impact on security from mandatory microchip implants (2 appearances on security screen)
2) Reduced Technology impact of driverless car laws by 50%.
3) Doubled the cost of Stem Cell policy.
4) Reduced Technology impact of Technology Colleges by 25%
5) Boosted Technology impact of Rare Earth Refinement by 100%.
6) Reduced Technology impact of Technology Grants by 25%.
7) Illegal immigration situation is now slightly harder to trigger, easier to solve.
8) The Private Space Program,Armed Religious Communities and Doctors Strike situations are now harder to trigger.
9) Egalitarian society situation no longer influenced by Education, but needs Gender Equality and low Generational Wealth Gap.
10) Reduced link between Rare Earth Refinement and Productivity.
11) Reduced impact of Alcohol Consumption on Productivity.
12) Reduced default level of Productivity.
13) Slowed most inputs to the Corporate Exodus situation by 50%.
14) Slightly easier now to trigger the Teachers Strike.
15) Plastics Tax and Packaging Tax are now also inputs to the Black Market situation.
16) Homelessness,Antibiotics-ResitantBacteria,Class War and Food Banks situations now trigger more easily.
17) Dilemmas rebalanced so some are more frequent, others less frequent.
18) Bug fix for theoretically fixed situations like EU monetary policy stopping or starting.
19) Media Monopoly situation now reduces Democracy.
20) Fixed bug where some values on the ‘disposable income’ screen were inaccurate, or garbled (esp for South Korea).
21) Car Emissions limit’s impact on motorists income is now scaled by inverse of EV transition.
22) Cost of body cameras now scaled to numbers of police,community police & armed police.
23) Fake news now increases chance/effect of Contagious disease situation and boosts racial tension.
24) Fixed links for minister icons on main screen to correctly show inputs and outputs from them and their sympathy groups.
25) Education now takes time (2 years) to feed through into a change in Productivity.
26) Air travel now slower to respond to GDP, but boosts pollution more.
27) Worker productivity impact on GDP now a gentler curve.
28) GDP impact on unemployment now a gentler curve.
29) GDP has a steeper impact on pollution, homelessness and car usage now.
30) Corruption and average minister effectiveness now shown at the bottom of finance screen. Corruption affects policy costs/income now.
31) Corruption and minister effectiveness now shown at bottom of finance history for each policy, mouseover shows cost impact of each.
32) Corruption slightly boosts tax evasion now.
33) Rebalanced many inputs from state services to state employee membership and unemployment to make them more accurate.
34) Voter turnout is now generally higher in all situations.

Quite a list this time… but that’s because a lot of it was small statistical nudges here and there. Actually this is one of the most time consuming things about developing a game like this. I don’t have any fancy new particle effects to show you, or any new horse-armor options or new fireball spells or laser upgrades. All I can offer you is “After careful consideration and spreadsheet analysis, Corruption is X% more likely when Press Freedom is below Y”. This is actually stupidly important because its getting all those numbers right that makes the game playable and fun and not a mess.

The only big noticeable changes that players will see rather than *experience* are that bureaucracy is now a thing (triggered by having a LOT of policies, or not so many if you are the weirdly bureaucracy-obsessed Italians), and I added some extra data at the bottom of the finance charts to show you that corruption also affects policy effectiveness along with ministerial effectiveness.

In theory Democracy 4 gets easier to balance over time, because we are slowly homing in on the ‘perfect’ game balance, by pruning obvious dumb edge cases as they are reported or spotted by me, and also I get more and more data from players on what happens too often, what happens too rarely. For example each update should have you experiencing a larger and larger percentage of the dilemmas and events in the game. They may *feel* random, but they are actually being triggered by various in-game parameters. Balancing those so that they show up at appropriate times, but you also get to experience most of them is really tricky…

As always, don’t forget to voter on priorities from the games main menu screen, and like I always say, leaving a positive steam review is a really big help, as is telling your friends about the game if you are enjoying it. Its also really great to get helpful feedback. The best possible feedback is stuff like “When playing country Y as a conservative, it feels too easy to keep voter group X happy by doing Z, even though it doesn’t upset anybody else” or whatever…

Improving accuracy of state employee & unemployment effects in Democracy 4

One of the problems with making a vidoe game with one person doing the development, where you try to model the entire world in inter-connecting detail…is that its impossible, so you end up doing a lot og guessing and thinking ‘yeah that looks ok to me’. Then eventually you find the free time (ha! its the weekend, who am I kidding?) to go back and check that the wild ass guesses you made were just wrong, and not OMG emebarrasingly badly wrong. Its a low bar, but i’m determiend to hit it.

My game Democracy 4 has a lot of policies that affect two important variables in the game – The membership of the ‘State Employees’ group, and the level of unemployment. For hopefully obvious reasons, these numbers are important in a government/ politics sim. They have to make some vague sense. Until now, the numbers in the game have kind of been guesswork, and result in equations like this:

StateEmployees_freq,0.02+(0.05*x)

That means that the effect of that policy will vary between a 2 percent and 7 percent boost to the number of voters who identify as state employees, depending how the policy slider is set. In other words, this policy assumes that at max capacity, this policy represents a seven percent higher chance of any voter joining that voting group, although in practice its much more complex than this, due to internal algebra that I wont bore everyone with…

The problem for me is that although I do not mind that seven percent figure being possibly inaccurate, I DO want the games model of this stuff to be internally consistent. To put this another way, if in the real world, a state health service employs 10x the people of a state postal service, the game should attempt to get that ratio correct, at the very least. With this in mind I have done some research, using the USA as my base case for the policies most impacting state employees:

These figures are NOT 100% accurate. This is mostly because the US does not have a state health service in the same way the UK does, so I had to take NHS figures and then adjust for population. I also had trouble getting energy figures, so I extrapolated from the top 10 companies employees and adjusted on a per-household basis. The point is that although the figures (like all figures) are a bit wrong (probably) they are massively less wrong than my guesses!

So now to make the game values make sense, I need to work out how to adjust those values in the second and third columns, which are my current effects (at max slider) on state employees and unemployment. Given that I do not want top massively unbalance the game, I thought it was prudent to keep the total combined effects of all of these policies the same (93% and 126% respectively) and just adjust the figures internally to fix the relative impact,

The way I’ve done this is to use the employment percentage (the actual percentage as a portion of total employment of all these policies) and multiply that by the total current in-game effect (93 or 126) to give me the new adjusted effects. That looks like this:

In some cases its not too big a change but in others its hilariously different. Currently the game is giving a HUGE (18%!) boost to state employees from armed police when it reality it should be about 3%. On the other hand state schools were set to have a 10% boost to employees, and should be having a 29% boost instead! So many teachers! Its also evident that in the grand scheme of things, prisons and a state broadcaster employ virtually nobody. (I scaled up the BBC employment figures to USA size to get that data too).

I have just done the data so far, but later today I’ll go through all the policies and adjust the values in each equation. I guess the takeaway from all this as a player is that if you really want to cut unemployment when you spend money on public services, you want to splurge cash on the health service and schools/universities. Everything else is trivial.

Keen-eyed economists might note that the REAL employment impact would be different. For example, the direct employment from the US military may be 1.3 million, but defense contractors etc will employ many more, and the knock-on effects from the contractors CEOs buying new ferraris is even higher. I agree, but that is best dealt with through a GDP boost I think.