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

Updated Democracy 4 to build 1.24

Here are all the exciting changes!

1) Improved new game debt slider so it always defaults to the middle and allows zero or doubling the debt.
2) Added Tobacco Awareness Campaign to the Canada, Australia and Spain missions.
3) Cynicism has a stronger effect now.
4) Added a link between inequality (low equality) and violent crime.
5) Added a link between average temperature and violent crime.
6) Edits to South Korea Mission: President not Prime Minister, Removed Royal Family, Added State Broadcaster.
7) Fixed bug where the North Korea threat could we warned about to any country!
8) New Australia-specific dilemma: Mining on aboriginal lands.
9) Australia gets a default energy industry boost, and some other values have been tweaked.
10) Australia now has stronger impacts on CO2 from renewable energy due to good solar power potential.
11) Fixed bug where the financial cost of situations never seemed to change.
12) France and Germany now have an EU Contribution situation that costs money, Spain has EU Subsidy situation as income.
13) Added EU Monetary policy to France, Germany and Spain. Effectively uncancellable Quantitative Easing.
14) Members of the EU can no longer impose capital controls.
15) Optimizations to startup, and general UI.
16) EU countries now have a 4x multiplier to the political capital required to change immigration / tariff rules, due to needing EU agreement.
17) The US now has custom names for ministers (like sec of state etc…)
18) The US now has reduced anger at handgun laws from parents, reduced anger at armed police from liberals, and higher default racial tension due to it’s history.
19) UK now has a monarchy situation.
20) Added Nuclear Weapons policy.
21) Fixed tooltips on customise mission screen, and we now hide 3rd party details if not enabled.
22) Fixed bug where start of new game added one turn’s deficit to the debt.
23) Increased Canadian government debt to the correct (much higher) figure.
24) Private Prisons now also reduce the severity of prison overcrowding.

BTW the game is currently 30% off on steam. OH MY GOD Grab it now etc.

Improvements to the political compass / voters opinions

I’ve been trying to improve voter behavior in Democracy 4 with a bunch of goals. Firstly to maker the political compass Overton window not look so ‘forced’, and more importantly, to allow for more realistic modeling of the variety of opinion. As some players have pointed out, there is always SOMEONE in the electorate who will not ever vote for you, always some communists, always some capitalists, and so on. How to fix this?
Here is the political compass for a new game as Australia:

And here it is with my new changes I am considering:

The voters are less confined to the Overton window, and yet are still influenced it. We clearly have people far to the left of the political consensus zone, but not quite as far left as Stalin and Lenin. I think this makes sense. Even people who are claiming to be outsiders and not swayed by the mainstream media or mainstream politics are still vaguely influenced away from the extremes.

The (debug-mode-only) tooltip data for impressionability illustrates this. The game has always modelled the ‘impressionability’ of voters, but with recent changes, I’ve improved how this calculation is used to determine a final opinion. Here is the final calculation:

Final Socialism = (CurrentGlobalSocialism * Impressionability) + (InnateSocialism * (1-Impressionability))
(This is a new equation for this version, it was different before)

So every voter is born with an innate predisposition to socialism (also liberalism) or not, and this is their ‘starting’ position. They then get swayed towards the ‘consensus’ position (Global Socialism) by how impressionable they are.

Impressionability is calculated as a normal distribution but then squeezed in so its between 15% and 85%. (Its then multiplied by 0.95 which is an internal value and not important…)

Note that if the ‘Polarization’ situation is active, the value of InnateSocialism gets pushed out to the extremes by the strength of the situation.

I need to do a lot of play testing, but I think this change will make the game feel more realistic.

Democracy 4 Updated to build 1.23

Lots of changes, here is the complete list:

1) Fixed incorrect or broken effects & costs for EV transition, Plant Based Diets, Judicial Independence, Nuclear Fission.
2) Changed scaling for simulation values so in ‘value’ mode they show difference from the midpoint.
3) Added South Korea as a playable country!
4) Added support for country-specific minister art groups.
5) Improvements to how sensibly the icons are positioned on the main UI.
6) UK now has Tobacco Awareness Campaign enabled to reflect the warnings on packets.
7) Reforestation policy is now slower to implement, and slower to impact the environment.
8) Synthetic meat research now boosts plant based diets, and pleases instead of upsetting environmentalists.
9) Improved election analysis screen so it uses tiny people symbols rather than an ambiguous ‘dot’.
10) Slightly boosted impact of voter ‘complacency’ over time for when they start to take the governments policies for granted.
11) Fixed a bug that artificially limited how complacent voter groups could be at a lower level than it should.
12) Party analysis screen now also uses people icons instead of meaningless dots.
13) Possible fix for rare bug where alt-tabbing to and from the game can lead to ‘phantom clicks’ on items like the next turn button.
14) Fixed bug where the background fade effect disappeared when canceling an industry privatization.

And todays blog video!

How I address a tricky, user-interface layout / physics code challenge

Democracy 4 has one aspect of its GUI that still screams IMPERFECT at me, and needs fixing, but its at least 10x harder than it sounds. Its the sizing, and positioning of the icons on the main UI:

This looks like just a bunch of different sized circles on a screen. How is that tricky? Let me count the ways:

  • The icons have to be in specific zones, which are not rectangles, but could be any polygon. These change size and shape over time
  • There has to be consistency of size. A radius 10px icon in zone A has to represent the same value as a radius 10 icon in zone D
  • We could have ANY screen resolution or aspect ratio.
  • There could be ANY number of icons.
  • There is finite time, on perhaps a CPU-limited laptop to do all the calculations.
  • The icons cannot touch the center icon, or each other, or the zone boundaries.

Now it turns out…coding that is a real pain in the neck. The system that you *think* will solve it all, is to have each zone boundary and icon project a sort of repulsive force on to all the others, then step through an iterative system of applying forces and moving stuff around until an equilibrium is reached. Well kinda… but no. Look again:

Those icons with black arrows are the pain. They are kind of stuck next to corners and other icons. its the shortest distance between two icons ANYWHERE on the screen that limits the size of all of the others.

My initial solution to fix this, DID make it better, but its not good enough. What was it? Basically I do the physics-repulsing-forces thing as usual, then I ‘jiggle’ each icon in turn, randomly kicking it a few pixels in different directions, then checking to see if the overall separation of the icons got better or worse with each jiggle. I keep the jiggles that improved the situation.

Actually I improved that algorithm by first finding the icon that was the closest to the others and giving that 32 initial jiggles. This is the result, (less force is better, it means the separation is better)

Pre Jiggle. Total force:[0.39] Strongest: [0.14]
Post Jiggle. Total force:[0.03] Strongest: [0.03]
Pre Jiggle. Total force:[1.31] Strongest: [0.45]
Post Jiggle. Total force:[0.23] Strongest: [0.23]
Pre Jiggle. Total force:[1.67] Strongest: [0.32]
Post Jiggle. Total force:[0.19] Strongest: [0.19]
Pre Jiggle. Total force:[1.23] Strongest: [1.19]
Post Jiggle. Total force:[0.06] Strongest: [0.06]
Pre Jiggle. Total force:[1.14] Strongest: [0.13]
Post Jiggle. Total force:[0.17] Strongest: [0.17]
Pre Jiggle. Total force:[2.17] Strongest: [0.68]
Post Jiggle. Total force:[0.31] Strongest: [0.31]
Pre Jiggle. Total force:[0.53] Strongest: [0.40]
Post Jiggle. Total force:[0.26] Strongest: [0.26]

Which is what brings me to the current state of affairs. However, this is just one of those tasks’ that humans excel at and machines suck at. I bet you can see locations where the icons should be shuffled really easily.

Something I intend to experiment with is a more focused approach to the jiggling! I can tell now which icons (in this case two of them) seem ‘trapped’ and are causing the biggest problems, so rather than just going through all of the point containers and jiggling everything, I should now focus my attention just on the containers with the problem

Maybe I can even focus my attention just on the half-dozen icons per container that are closest to the problematic ones, but that may not actually be the solution. Check out this section in more detail:

This row of icons has basically got trapped. Moving any of them upwards and to the right is going to be tricky, unless the icons *above* them can get out of the way. The trouble is, we need some super-clever algorithm that could move an icon above them higher (thus making *that* icon worse off… so that later we can jiggle these others… and everyone will be better off.

It might be that the initial force algortihmn is too linear. A linear force would not concentrate midns enough of the dire plight of the icon in the bottom left. If the squeeze here was not seen as just *slightly* worse than the squeeze on others, but exponentailly worse… that might fix it.

…and also this icon is receiving some strong forces from its location in the corner., Unlike other icons, boundaries cannot move, so maybe we should prioritize their plight more? Surely no coincidence that both worst-case icons are in corners?

This all strikes me as something that would be easy if I’d learned more physics and maths, but hey… working it out alone from basic principles is kinda fun. I have plenty of ideas to tweak my algorithm.