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

New Democracy 4 policies: Workers dividends and Ban on crypto

I’m working on adding two new policies to the next update for Democracy 4 today. By popular demand (deduced from in-game player voting during Early Access) I have decided that these two policies are worker dividends (profit sharing) and a ban on all cryptocurrency. I’d like to talk through what these policies represent from a game design and real world point of view, and show how they have been implemented.

First up is workers dividends. Like all Democracy 4 policies, these are not as specific as they sound, but represent a whole ‘area’ of legislation, in this case legislating on how workers must be compensated. In the overwhelming majority of countries, such legislation basically amounts to laying out a minimum wage (if one applies), and perhaps some rules about grounds the company may have to withhold such payments, or perhaps rules surrounding what kind of deductions from wages can legally be made.

In other words, in general, as long as a company pays you minimum wage, thats all you are entitled to. If you notice you earn $40/year and the company CEO earns $50million a year, and its all your effort that enabled this…then basically your option is to just quit and work somewhere else…

Some people take the view that this is unfair. Others take the view that this is capitalism working as intended. A clever company will reward employees fairly, or risk losing them to cleverer companies who spot their potential. This is the ‘perfect market’ school of thought.

Others might suggest that this is fine when we are talking about headhunting people with phds, but when it comes to warehouse workers, or other minimum wage staff, things don’t work that well. A company like amazon may earn billions in profit, but see no reason at all to pay its warehouse staff above minimum wage. If you are of a socialist mind, this is unfair, and exploitation and needs fixing.

Generally in my lifetime this has been a non issue where I live, until the last UK general election, the left-wing Labour Party did propose something akin to this new Democracy 4 policy:

https://www.bbc.co.uk/news/business-50508369

In this policy, the party suggested that 1% of the shares of private companies be taken from them each year for 10 years (total 10%) and placed into an ‘ownership fund’ whose share of the profits would be paid to the workers. In a Marxist sense, this would be described as ‘seizing the means of production’, although in this case only seizing 10%. The idea was to share the profits of big companies with the staff, and was probably one of the most pure socialist policies proposed at the election.

In the end, the party lost (quite badly) so we do not get to see how the policy worked in practice, but it was popular with its supporters (and VERY unpopular with its opponents).

I need to include policies like this in Democracy 4, because as socialist players have pointed out, the game does not go to any particular extremes on the left economically. We have policies for minimum wage, retirement age, worker safety and even mandatory union representatives on company boards, but no direct pure wealth-redistribution from owners to employees. This policy fills that gap. The slider can be thought of as intensity, showing a range of measures from the ‘incentives for bonus schemes’ all the way up to ‘mandatory allocation of 90% of shares among the workers’.

My first thoughts are that this policy pleases socialists, and union members, angers capitalists and small businesses (effectively entrepreneurs), boost the chances of a corporate exodus, reduces foreign investment, but has a side effect of making all strikes less likely. (Why strike when you will feel the pain as profits drop?).

The second new policy I’m adding is a cryptocurrency ban. Sometimes people ask why such ‘ban’ policies even need a slider, but a ‘ban’ can mean everything from ‘some currency mining is banned if using certain power sources’ all the way up to ‘holding, mining or trading cryptocurrency of any kind is punishable by imprisonment’.

In this case the motivation is a combination of loss of government control (and thus tax revenue) and concerns for the environment. Liberals hate banning anything (because…freedom), and obviously any ban would have a vastly negative effect on the usage of cryptocurrency.

How Bitcoin's vast energy use could burst its bubble - BBC News

For background reading on the environmental costs of cryptocurrencies (specifically proof of work), just use google. Its pretty shocking. I have strong views on all crypto, including proof of stake, which although environmentally better, has the perverse effect of making the rich get richer. Perhaps someone will do an in-depth D4 mod that represents different types of crypto and their effects on socialists and capitalists!

And that reminds me… I must check that crypto’s CO2 impact is modeled in the game…

Improving Democracy 4 events balance by using a LOT of data

I’ve been doing some number crunching to check that I am moving in the right direction regarding balance on Democracy 4.

The game has a series of ‘events’ which are triggered by various inputs. Some of these events are pretty ‘informational’, in that they mark changes the player has made and their impacts, other affect the games difficulty by stopping the player racing too far ahead or too far behind. Others are there as a random curve-ball that the game throws to the player to shake things up. There are about 120 of them.

Because they are not triggered purely randomly, the frequency with which each event shows up is determined by the complexity of the neural network that forms the basis of the games simulation. This means that some events may end up triggering much more than others, if the inputs to those events are not balanced correctly.

In an ideal world, the whole game would be a truly self-balancing neural network, but I don’t trust the systems enough to unleash anything like that, so I collect statistical data on which events trigger in each game version, and then change some of the inputs each update so that things balance out for the better.

In an ideal world, every player gets to see 100% of the content in the game, so they are effectively getting what they paid for, and not being constrained to a tiny subset of the content because of poor balance. In other words, if I have an event called ‘school shooting’ and its triggering one tenth as often as ‘scientific breakthrough’, then the balance may be off, in that the inputs to the first event are too strong, and the second too weak.

Note that I am talking in grand statistical terms over thousands and thousands of players. An *individual* player may never see school shooting, or scientific breakthrough, depending on the countries they choose and their play style and skill, but I need to check I’m not adding content to the game that hardly anybody sees!

By collecting all this data, I can build up tables for each game version showing the total events triggered for players of that version, AND the number of times each event triggered. Like this:

1.27
Event Namecount
shareiposuccess7790
shareipocancelled7112
hugehurricane4515
dubiousrolemodel4190
resourcesobsolete3913
multinationalcompanyheadquarters3810
militarycontractscandal3780

..and so on. Because I am looking at 120 events, I can work out that for version 1.27, if every event was equal, they would all trigger 1,406 times given the number of version 1.27 games played. I can then store the difference between the ACTUAL number of triggers, minus the target, and express this as a deviation in percentage terms from the target:

1.27
Event Namecountpercentage deviation
shareiposuccess7790453.78%
shareipocancelled7112405.58%
hugehurricane4515220.96%
dubiousrolemodel4190197.86%
resourcesobsolete3913178.17%
multinationalcompanyheadquarters3810170.85%
militarycontractscandal3780168.71%

So you can see that back in version 1.27, the top event (Share IPO success) is triggering 4.5 times as often as I would like.

I can then add up all of those percentage deviations and get a final number representing the total percentage deviation (in absolute terms) over all events. That gives me this:

VersionAbsolute Deviation
1.276426.89%
1.285717.38%
1.296128.34%

In an ideal world, this number trends down over time as each version comes out.

Another way I looked at things was to just look at the absolute value of the top 10, and bottom 10 events, to see if I am effectively ‘squashing’ the trigger probabilities to prevent extremes. This is a major goal, because players will not notice and event triggering 5% more than another, but if one triggers EVERY game, or NEVER, then that does get noticed. When I look at this data I get these values

VersionAbsolute DeviationExtremes Deviation
1.276426.89%2941.48%
1.285717.38%2239.64%
1.296128.34%2433.29%

By doing this for a whole bunch of different game versions, I can end up with a chart showing my progress!

More helpfully, I can quantify that the uneven-ness of the event triggering has improved by 14.73% since version 1.27. The extremes have been reduced more, by 30.29%

This probably sounds stupidly maths-y and the system is full of issues, such as events that only trigger in a few countries, and therefore SHOULD be seen less… but there are limits to which a single coder/designer/bizdev/marketer person like me can spend time crunching all this.

TBH its just a big relief that the numbers DO seem to be trending in the right direction, especially as I keep adding new countries and complex simulation elements (meaning that the simulation is in flux, and thus just remaining the same would be a balance-win of sorts.

It might be bizarre but I really enjoy this kind of analysis :D Now go tell your friends how well balanced Democracy 4 is :D

Democracy 4 Translations. The Economics

I’m trying to decide what other translations make economic sense for Democracy 4. Its never a clear issue. There are some countries where sales are potentially high, but then most gamers speak English anyway, so the boost effect of a translation is small. Then there are countries that sales are entirely dependent on translations being available. Also some countries have higher piracy rates, meaning you are basically just making pirated copies better! Time to look at some stats. Obviously I cannot make any decision without stats. Yes, I may well be on the spectrum…

Here I am going to consider the arguments for translating into Korean, Chinese and Japanese. Which, if any, of these countries make sense as a potential translation target? One useful stat would be to look at Democracy 3s steam sales figures in each country, as a percentage of revenue, as this game is older so it has lifetime (not just early access) stats.

  • China: 1% of revenue (Chinese translation available but added post-release. 5% revenue in prev year)
  • South Korea: 1% of revenue. Not translated 2% in prev year
  • Japan 0% of revenue. Actually to be precise: 0.478% of revenue. Not translated Yikes…

There are a bunch of countries where we do not have a translation with higher revenues such as these:

  • Sweden. 2% revenue
  • Norway 2% revenue
  • Netherlands 2% revenue
  • Denmark 1% revenue

But I think its fair to say that English is commonly spoken in those countries by gamers, and if not, they also have French or German to choose from, so not bad. The big question is picking between Russia, China and S Korea. Its worth noting that S Korea is a playable country in the game… so maybe this needs adding? So is Japan!

So to get really stupid, lets look at the population under 30 to get the total addressable market for each of our now 4 countries:

  • Japan: 27 million
  • China: 237 million
  • South Korea: 13 million

Hmmm… not helpful. Maybe a better source would be to look at steam traffic in general, which I found on this page.

  • Japan: 1.5% of traffic
  • China: 22.7% of traffic
  • South Korea 3% of traffic.

So frankly Japanese is looking like a bad idea. Untranslated sales were close to zero, and as a percentage of steam traffic, its really low for EVERYONE. South Korea is better, but still low. China might be a better bet. We DO have a swanky Unicode engine which will effortlessly render everything in Chinese and Korean… so it seems like that could be a good idea. I need to get a translation quote, and then look at the numbers a bit more, and then pace up and down and lose sleep some more. I’ve scheduled the stress and pacing for tomorrow…

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!

Upgrading my home solar to solar edge

Yesterday I got my ground mount solar panels upgraded to solar edge. This is something people very rarely do, for very sensible reasons, so I thought I’d blog about it, as its something you wont ever find explained.

As some background, I have a 10-panel ground mount solar array in my driveway. We live in an very old ‘listed’ building in the UK so we cannot have roof mounted solar, but I’m a huge fan of green energy and wanted them anyway. 10 panels is all we could fit in the vaguely sunny part of the driveway so thats what we got, and the peak output is 2.1kw. Thats pretty low, and by Californian standards hilariously low, but this is the UK, and we don’t even have air-con (but I DO have an electric car to charge).

Because there is no other sunny part of the garden, and the neighbors are not likely to sell me extra space to put solar,m I have ended up starting a company to build a solar farm, but it still frustrates me that we are not energy independent at home. This is REALLY hard to do for an old house in the UK without a huge flat un-shaded garden. Thus I took it upon myself to try and squeeze as much efficiency out of our existing solar panels as possible. Enter solar edge!

Solar edge is a system that is almost ALWAYS fitted when you get new solar panels (if you opt for it, most don’t), and rarely done as a an upgrade. As an upgrade, it makes very sketchy financial sense, unless you are in my position, have variable shading, and are desperate for higher efficiency.

Solar edge fixes a problem in the way solar panels are wired, that almost no homeowners realize. They are wired so that power flows from one panel to the next, and the next, until eventually they reach the inverter, and get converted from DC to AC. What this means is, in practice, if you have 10 solar panels and solar panel number 1 is shaded, then the output of ALL TEN panels is reduced.

Yes really.

In almost all ground mount, and many rooftop installations, this does not matter. But if you have partial shading at some point during the day, or if you have constant shading of just one panel, you lose a massive amount of potential output. It also means that solar panels have to ideally all be facing the exact same way (not both sides of a roof, unless you literally live at the equator), and be the same type/output. Otherwise you are losing energy.

Solar edge is essentially a bunch of widgets (optimisers) that get wired onto the back of each panel. here is one on one of my panels:

All most all of that extra cabling and cable ties is due to the solar edge system, so its actually a lot of annoying, slow, fiddly work to do it. You need one of these for every single panel:

They are also not cheap, but frankly these days even if they cost $10, the main cost is getting an electrical engineer to come wire everything up. As ever, humans are the point at which renewable energy gets most of its costs these days… Anyway, you also get a new inverter, which is a lot smaller and simpler than many others. Like most inverters these days, it can talk to your wireless network and give you internet-based tracking of everything:

The beauty of this system for people with complex roofs is that a single inverter can now manage multiple groups of panels, even when one might be slightly shaded in the afternoon when the other is in full sunlight. The thing is, it also helps for stuff like partial shading due to clouds, or maybe in my case treetops which will affect coverage for one panel but not others. Check out this screenshot from the solar edge site:

Thats taken at a specific time this morning, around 10am, where either clouds or treetops have shaded a lot of the panels, except panels 4 and 8. In this case they get to produce 65w and 68w, instead of being limited to the 40w of that first panel. (its a cloudy day today, normally output would be way higher!)

What is especially cool about the site is it has a sort of ‘scrubber’ where you can slide through time on any day and see the output of each panel at each point in time. It will also show you total power for the day/week/month for each panel, so you can work out if one of the panels is maybe covered in bird crap or some fine dust, or if it has a technical problem and is failing. Its also apparently safer in case of electrical fires and faults.

This is all total nerdgasm silliness that only someone like me would ever actually do, because the extra output is likely about 10% and the costs are in the thousands, so although yup, I did get a spanking new inverter out of it, the actual economics of it make little sense in the UK, unless your inverter is failing anyway.

However, if you ARE thinking of getting solar, have a complex roof and some shading at parts of the day from a neighbors tree or a power-line or phone line, it may well be worth considering a solar edge setup.