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

Balancing Democracy 4 using stats and number crunching

I’m still working away on improving the balance for my political strategy game ‘Democracy 4‘ which is in Early Access, and likely the hardest game to balance in the history of humankind, due to the insane number of interconnecting variables.

Something I was working on today was the likelihood of each dilemma popping up. These are occasional ‘situations’ that are urgent and need the player to make a choice one way or the other. Basically the choices are always hard, because they mean upsetting someone, or causing an effect that may be undesirable given your goals.

For example, if a company is about to collapse, you could bail it out (pleasing the workers, but setting a bad example for other companies, maybe upsetting capitalists, who prefer a free market), or not, and your decision depends on who you can afford to (or choose to) upset at that moment.

Some of the dilemmas are totally random, but most are influenced by some variables so that they seem fairly ‘relevant’ to the way you are playing the game. So they all have inputs based on certain variables, and thus as the game designer I don’t know in advance when they will happen (they are not timed or scripted in a conventional way).

This is all very easy to design and code, but the problem is you can end up with the inputs being unbalanced, and thus maybe everybody is sick of seeing dilemma A, regardless what they do or how they play, whereas interesting and exciting dilemma B hardly ever gets triggered. For a small studio with a limited budget, having any game content that is rarely seen by the player is an efficiency disaster.

Luckily I (anonymously) keep track of every trigger of a dilemma by version number, so I can guild up big databases of such events. The events database is currently about 4GB in size, and is testing the limits of my MySQL optimization abilities. Thus I copy the last 2 versions events into a much smaller (600MB) database for me to query. That lets me get cool charts like this:

Which lets me visualize the extent to which some dilemmas (the ones with long red bars) are triggering WAY more than they would if their distribution was completely random. I’ve been using this data for the last few versions, but I still have the unbalanced issue despite a lot of manual revisions, so I’m working on code today to visualize this better.

I actually found this easier in excel, once I had data that showed me every dilemma, and what percentage of dilemmas each one represented, over the previous 2 versions:

I can then work out what percentage they *should* be, thus the error in terms of over or under representation. Luckily I’m analyzing 100 dilemmas, so its a simple 1%. I calculate an error in percentage terms, for each version, then calculate the change. A positive value is movement towards better balance, a negative one is movement away, (worsening the balance). This can then be conditionally formatted in excel:

Which is a cool trick, but also depressing to see the extent to which I often am having a trivial effect towards balance, or even making things worse (negatives).

However, at least having a nice process to visualize this stuff makes it more obvious to spot where I am being too timid in my corrections. In an ideal world, this would all be integrated into a single web query, and in an ideal, ideal world, some sort of cool machine-learning AI would be making these adjustments instead of me…

But hey, its a big step up from just ‘setting some numbers and then playing it a lot before release’ which is what I did ten years ago :D I’ll gradually get this stuff more and more optimized.

Hollywood and Gaming is a tale told by an idiot, full of sound and fury, Signifying nothing

Look at me, I know some shakespeare. Actually I probably got it from star trek, whatever.

For my sins, I enthusiastically agreed to watch a movie on the Disney channel (gotta make that Mandalorian subscription worthwhile) for kids called Artemis Fowl. Its a sort of harry-potter meets enders game action adventure about faeries. yeah. I didnt know that when I agreed to watch it. But apparently a popular series of kids books, so there ya go. Harry potter was ok, even His Dark Materials is kinda ok, in a generic lord-of-the-rings clone kinda way so this will be fine right?

No, it was BAD. it was REALY REALLY BAD. I’m not the only person who thinks so. I could whine about the plot, and the script and the casting and the voices (TBH the actors did their best), but what really ruined it for me was the budget. The budget was way TOO BIG.

Judy dench and her army of faerie shocktroopers err…?

You might not think having a big budget can ever be a problem, but maybe its an age thing, when you hit my considerable age (older than Elrond), you have just seen SO MANY CGI BATTLES and so many ‘amazing’ computer generated worlds that they actually start to become bland. After a while you just stop seeing it. The familiar becomes invisible.

We have a really nice view out of our front door, and occasionally delivery drivers on a summers day will say ‘its an amazing view isn’t it?’ and we are momentarily confused, thinking what? However good something is, however amazing it is, familiarity breeds dismissal. Economists call this ‘diminishing marginal utility‘. It applies to movies too, and to video games.

The original Star Wars movie probably had about the right mix of amazing special effects and….not special effects. The number of shots in that movie involving ILM is not that high. As a result when something SFX-like happens, you can legitimately feel the need to go WOOOO. Like when the millennium falcon enters hyperspace. The vast majority of the film is based around characters, plot, and cool production design/costume design.

To quote a famous expert in chaos theory:

“so preoccupied with whether or not they could that they didn’t stop to think if they should

Sequel Bits: Harry Potter Prequel, Jurassic World 2, and More

Which is so true of SFX and CGI in movies, and also I think games as well. Sometimes you just have TOO BIG A BUDGET, and a desire to just hose it all over the screen. I still remember my confusion, and frankly disgust at playing one of the civilization games that instead of having a simple text-based tutorial, came with a jankily animated ‘virtual sid meier’ to explain things. WTF? Who asked for this? who needed this? where were all the comments complaining that the game was too complex, but would be fine if a 3d animated version of the designer slowly talked through each dialog box?

This is a big problem for ANY part of life where money is involved. Apples market cap has accelerated like crazy since steve jobs died. They have SO MUCH MONEY and have thus slowed their pace of innovation to practically nothing. Oh look, now the iphone has no headphone socket. Now its a bit bigger. Now its a bit smaller. Errr… guys shall we splurge it all on a big headquarters building instead?

Inside The $5 Billion Apple Headquarters - YouTube
$5 billion of shareholders money spent well I’m sure.

Compare the catastrophic waste, failure, delays and nonsense that defines the US governments efforts to fund space exploration through the likes of the ‘space launch system]’ (swimming with cash) versus the scrappy ‘we have no budget’ spacex. Who has made more progress?

Sometimes too much money makes people do crazy things, makes them so keen to prove how big their budget or market cap is, that they act irrationally. Not only could artemis fowl have been made for a tenth of its $125 MILLION budget, it would almost certainly have been a better film as a result. More room for character development, more room for decent plotting. You cannot have a nice emotional scene that deepens the characters motivations when they are surrounded by a million dollars a minute of CGI. Just ask George Lucas. Same director did A New Hope and The Phantom Menace…

I think its worth considering how this applies to videogames. We too have entered an era of fantastic budgets, huge development teams and incredible spectacle… but although we probably don’t have the problem *AS BAD* as Hollywood does in terms of just shoehorning budget in front of our customers to impress them, we are certainly heading that way and occasionally flirting with it.

I have NO IDEA how much it cost to make Minecraft before Microsoft bought it, but you can bet its not a lot. There was no 300-man art teams designing those cubes. There was no symphony orchestra making the music (did it have any?) there was no army of Hollywood actors doing voiceovers…. and yet bizarrely it become a staggering success.

Is Minecraft good or bad for kids?
This did not cost a trillion dollars

For the price of a mere $100 million, you can make an amazingly high budget video game, or I dunno… a hundred REALLY well funded video games. Maybe one of them will take off, angry-birds style. The choice is between an all-eggs-in-one-basket strategy, or diversification. I know which would help me sleep at night.

I think there is a very strong argument, financially, economically, from a business-strategy POV, that companies are better off making more games with smaller budgets. Clearly the heads of studios disagree, and given their bazillions, can I really claim they are wrong? But even if you think I AM wrong on that basis, then I still think there is an artistic argument to be made.

Huge budgets do make art better, and they can very very easily make it worse. Would handing an extra $10 million to George Lucas have made ‘A new hope’ a better movie? or would it have made it more like the phantom menace? Is the relationship between the star wars movie budgets and their value as art in ANY way positively correlated with the budget?

I find myself increasingly ANGRY when i’m watching a movie and I can see the money literally dripping off the screen. A character arrives in 19th century London. Ok cool…what do they do there. NO! WAIT! STOP! You do not understand, you have to be MADE to SEE just how much money we spent on this establishing shot. Did you not SEE all of the CGI horses and carts? did you not count how many actors had 19th century costumes on as they walked down the street? Are you not impressed?

single shot in death valley used to be THE mos eisley establishing shot

I just don’t need this. I was fine in the way Mos Eisley looked before the special edition added all the establishing stuff. It added nothing, except cost. But even that looks tame given the way Hollywood sprays cash around now. The tendency now is to have a million dollars (or way more) spent on an establishing shot while the titles appear. Why? What does this add?

My point here I guess is to encourage people not to do this with games. We don’t need it. We really don’t. By all means hire a lot of people to do better writing (most game writing sucks), or to do more QA, or to work on customer support, but the instant, automatic response to having a big budget is to splurge it on big-name voiceovers, ten hours of orchestral music, and FMW and cutscenes that go on for hours, and hours and hours.

And please remember, its not illegal, its not immoral, and it doesn’t make you a failure, or a fool for uttering the completely forbidden words ‘I don’t think we really need to spend that much to make this’.

Modelling cultural differences in Democracy 4

One of the biggest challenges in designing and balancing Democracy 4 is having a single simulation model work over all countries. In theory, if *everything* is modelled, then you have a perfect model of human society and behavior, and feeding in the correct settings to each country will produce the required results.

Because I am neither superhuman or crazy, I don’t think this is really feasible, so we limit the simulation to that subset of variables that I think makes the game playable and fun, and reasonablyt accurate, and then I am left with the task of working out how to fudge that simulation to fit real world experience.

An example of this in the game is productivity. In the game, worker productivity is quite an important simulation value. The player can see its value, a chart of its history and view its inputs and output:

Of course the simulation is assuming that the list of inputs and outputs to this value make sense over all countries, or in other words, in all cultures, but this is a very simplistic view. Whast actually makes one country more productive than another? there can be a million things, many of which we do not model. For example:

  • Extremes of temperature in a country may require a mid-day siesta where less/no work is done.
  • A culture of extreme deference to authority may reduce productivity due to a lack of suggestions/criticism of bad practice
  • Highly variable and extreme weather may mean that work is regularly interrupted as a result
  • A cultural expectation of strong work/life balance may reduce the tendency to do overtime
  • A cultural work ethic may encourage overwork and unpaid overtime by default

We do not explicitly model any of these things as tracked variables. You could argue that it would be possible, but in some cases they have historical roots that are now just cultural norms and cannot easily be explained. For example here in the UK, the British people tend to have a general distrust of, and dislike of politicians and authoritarian figures. ID Cards are NOT a popular idea here. The reasons for this are hard to discern, but its certainly rooted in the past and not something you could easily model with numbers.

Similarly there is a deferential attitude to age and rank in many Asian countries that works in a similar way, and likely has both positive and negative outcomes. I watch a lot of Korean dramas these days and its fascinating the extent to which people seem both obsessed with education and status, and also massively invested in the minutiae of office politics. Why is this? very hard to say.

Review: Misaeng (First Impression) – The Korean Lass

It might be hard to model this stuff, but we certainly cannot ignore it. For example Germany IS a very productive country, especially at manufacturing. It has decent holiday provision for workers, and strong unions, yet its productivity is super high. why? A lot of it can probably be put down to the cultural work ethic. Take this article, for example:

“In German business culture, when an employee is at work, they should not be doing anything other than their work. Facebook, office gossip with co-workers, trolling Reddit for hours, and pulling up a fake spreadsheet when your boss walks by are socially unacceptable behaviors.”

Because I need to model Germany as accurately as I can, I have blatantly included this as a script that runs and generates extra values for Germany to represent German Culture. in this case, a free bonus to worker productivity:

Adding this may seem like a 2 minute job, but NO. It triggered a boost to GDP that resulted in traffic congestion caused by the emergence of a gig economy (uber!). This has high regulation in Germany, so I had to boost labor laws, which then results in a corporate exodus away from germany…

I am currently considering whether the German language should act as impediment to corporate exodus (Companies tend to prefer to relocate to a country with the same language as them, and German is not as popular as English)… and so the balancing continues…

There are similar scripts for each country, and I’m gradually amassing as much feedback as possible and tweaking the values to make each country feel authentic, while keeping the same basic economic and political model. Lots more tweaking to come over the next few months!

On the topic of voter happiness in 3 party countries

I’m currently balancing Australia in Democracy 4, and its tough as almost any starting condition seems to result in a depressingly small number of people supporting the current party. I have been fiddling with the numbers for this for hours, and its occurred to me that its SO much harder in a 3 party system, and the game may be having trouble conveying this…

Take this screenshot:

Thats the current voter breakdown at the start of the Australia mission. Actually a few people are quite clearly over the 50% mark (to the right) and thus are more happy than unhappy, and in a 2 party election, things here would be looking bad…but not catastrophic.

But in a 3 party system, only people who have happiness of 66%+ are going to vote for you. Your polling numbers are going to be an absolute nightmare. But on the other hand, you do NOT need 50% of the vote to win, only >33% in order to be the largest party in a coalition.

This leads me to another conclusion… The current system has the opposition party taking a 100% opposed view to you on all issues. A 3rd party, if it exists, will take a position between the two, meaning its generally going to be trying to please socialists & capitalists plus liberals & conservatives.

Put another way… the 2nd opposition party will always be pretty moderate. That gives them a bit of an advantage, as they can vacuum up votes from all over the spectrum.

I do NOT plan on actually modelling all the political stances of opposition parties. This is a HUGE undertaking and outside the scope of this game. However, I would like to improve the current situation.

One thought running through my mind is that the 3rd party perhaps should be assumed to be suffering from some sort of ‘small party disadvantage’. So instead of happiness mapping onto votes like this:

0-33% opposition
33-66% 3rd party
66%-100% player

It could map like this:
0-40% opposition
40-66% 3rd party
66%-100% player

…or something similar. I am just brainstorming this right now. I think that there are basically 2 problems apparent here:

  1. The game is maybe a bit too hard for the player in 3 party systems
  2. The simple display of voting intentions on the main screen is perhaps a bit pessimistic in 3 party systems.

Feedback and suggestions are most welcome.

Modelling voter happiness in a video game is… interesting but also horrendous

Its less than 2 weeks until the US election in 2020, and although it looks likely Joe Biden will win, nobody really knows, because modeling how people vote is really hard. I know this, because I’m struggling with it in Democracy 4. Over the previous variants of the game, the voting model has got better and better and more complex, but its still a nightmare.

Here is a very very basic, simple description of how the voting system works:

We collect all of the various inputs to a voter from voting groups and calculate their happiness. If its over 50%, they vote for the player, if its less, they vote for the opposition.

Thats fine, but way too simplistic. For one thing…who says they will vote at all? so we have extra mechanics to decide based partly on age, party membership, and how angry/happy they are… whether or not they even vote. Plus culturally every nation has a background level of ‘apathy’ which feeds into this. Then finally, there are extra multipliers based on how strong a ‘campaign’ each party runs, which help to ‘get out the vote’ by financial means (adverts) or activism (party activist boots on the ground).

Thats better… but not perfect because it assumes rational voters making purely policy-based decisions based on self interest. So I have to then adjust the happiness of the voter based on their ‘perceptions’ of the candidate, which are affected by both policies and ‘spin’ events in the media. I then adjust *that* effect depending how educated the voter is. Basically the poorly educated are swayed more by spin, the better educated less so. (FWIW you can toggle that mechanic off in the game).

That all sounds complex enough…but its not. There is also the matter of party loyalty. So for example, say you are a trade-unionist left winger in the late 1970s, and have voted labour in the UK all your life. Along comes Tony Blair as party leader, by any definition a centrist. You still keep voting Labour because…well you always have done right?

The party position drifts dramatically but for a good few years, maybe multiple elections, you still vote for the same party. You become someone in a centrist party, holding left wing views, but still voting for them. In short, your loyalty has trumped your analysis. To make the game more accurate, we model that too! you can even hover the mouse over a voter and see their loyalty and analyze them (and click-through to a detailed breakdown).

(To illustrate this, generally you see cluster or red, blue and green on this screen to show members of each party, but sometimes those colored dots seem to be further away from ‘the pack’. These are people like I mentioned above… members of a party, and voting for them, but actually holding different views).

This is all a big improvement, but its not *quite right* yet, because the problem is…we still have what seems to be fairly wild swings in voting behavior. This is because of ‘soft’ support for a party position. To put it simply, if 100% of the country have an opinion of you that is 49.9%, you will get 0 votes, and be wiped-out in an election. Shift them all towards you by 0.2%, and you will win a landslide.

This is correct political modelling, exactly accurate and how it should be…but somewhere, some of our numbers are not quite right, so we are not ending up with the real-world results we expect. I have not *yet* completed my analysis of exactly why, but I suspect its because peoples opinions sway too wildly, and because party membership and loyalty is not strong enough.

For example in the UK right now, a lot of polls would suggest everybody is very unhappy with the current government. In Democracy 4, they would be in a bad way, because so many of the electorate are angry…. but I suspect the Conservatives would win an election tommorow, because despite their anger, many people who voted conservative in the last election still prefer them to the alternative. In other words, their party may have changed, and performed badly…but they still have party loyalty, and its not been bad enough for long enough to drag them away from that…

This sort of stuff is a nightmare to balance of course, but not that hard to code. I think I likely already have most of the data and variables exposed for me to get it right. I hope people realize that this is what Early Access is all about, and hope people can see more of whats going on by looking at that scatter chart (these are new to democracy for d4).

The real challenge is explaining all this to the player. I can get a better UI than I currently have. it just takes a lot of time, and experimentation, and analysis. Hopefully people are patient about this during Early Access.

Democracy 4 is on Steam, GoG, itch and the humble store