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

Crazy Energy prices, Short Deadlines, Solar Power.

This is not a blog post about games. Its because I also run a solar energy company, which is in its infancy, but hopefully will start doing cool things next year, like building a solar farm.

How often do you check the price of electricity? If you are like most people its…never. Maybe you go to a price comparison website every few years to see if you can get a better deal for your home electricity, but most people even then will not look at the actual price. Most people have no idea what their monthly electricity price is, and certainly no idea what the price per kwh (1,000 watts used for one hour) is.

I’m not like that.

The entire business model for the solar farm I hope to build next year (hopefully getting topographical survey results today,. probably signing the lease this month…), is based around the price of electricity being a certain value or higher. With current panel prices / inverter prices / storage prices and about 500 other factors, that minimum price is about £55 per MWH. (or £0.055 per kwh). This is the WHOLESALE price, not the price most end users pay. Its been around that price for a while.

Lets look at a fun wholesale price chart for the UK!

So…if you are looking at that and thinking you are confused because no way will the price of electricity be actually £160 per MWH compared to 55 this winter then… I have bad news for you. This chart is, AFAIK, correct. In fact, it gets way, way worse. Lets look at what the forward prices (prices at which electricity is being traded now for delivery at future dates) looked like on the 13th of September:

Yup. its insane. We have had at least one day where the price has spiked to nearly 10x what it had been for the last few years. The price if electricity in the UK for retail customers has a price cap, but thats due to be adjusted next month. The actual price cap rise is about 12%, which if you consider that peoples salaries have not exactly risen 12% in the last year, is pretty shocking, but the really interesting/scary story is that there is NO WAY that energy companies can stay in business with only a 12% rise. The regulator will HAVE to allow higher prices, and soon. They set the 12% change in August which is now…very out of date.

So why Am I blogging about this?

Because the UK is in a serious mess when it comes to energy. To put it bluntly: we cannot produce enough power to keep this country running. We have closed almost all coal mines (necessary, due to climate change), but we didn’t make enough of an effort to fill the gap. And now we are going to have to VERY rapidly switch from gasoline cars to electric cars, our power demand is actually going to go up, not down, despite the best energy efficiency measures.

There is an awesome website that tracks where the UK energy comes from in real time. The UI is horrible but you get the general idea. We have a fair amount of base-load nuclear, and some intermittent wind and solar, but a large part of our energy is either gas (whose prices are soaring, and is also a contributor to climate change and needs phasing out) or energy bought via connecting cables to France and Scandinavia.

Now to be a bit more optimistic I should point out that the UK IS building a huge amount of wind and solar power, but these things take time so we are hopefully currently in a bit of lag, where spiking energy prices should be a reminder that you need to build power-plants in advance of when they are needed, not after a crisis… but the problem is we are both doing it too slowly, and doing it wrong.

Too Slow

From a climate change point of view, the UK is a disaster. Sure, there are truly horrendous countries regarding climate policy such as Australia, but we have nothing to brag about here. Our adoption rate of Electric Cars is pathetic compared to countries like Norway, we have no major electric vehicle or battery production facilities in the entire country, and we got rid of all subsidies for solar power. (My solar farm will be subsidy free). Take-up of solar power for residential users is way too slow, insulation of our leaky homes has not really got going, and the government of the day is basically completely disinterested.

But thats just the background. In practice, even if the people were 100% behind green energy (and endless rants on facebook and planning objections from people who consider wind turbines an ‘eye-sore’ show they are not), and even if companies were full-steam ahead on building out renewable energy, I don’t think we are vaguely going to make it. And not because of evil government policies, and not because of technology… but because of planning.

The solar farm I’m building is tiny (powering about 300 homes), but the planning process is absolutely horrendous. The application itself costs an absolute fortune, and the number of completely different, yet legally required processes you have to go through are frankly ridiculous. You need to check there are no birds nesting nearby, no protected bat species anywhere nearby, need to check the field is not of archaeological interest, need to do mock-ups for every person for miles around showing what they may be able to see on the distant horizon… And the process takes months…

…and then once you have that, you need a grid connection and… guess what? That costs a fortune (only tens of thousands if you are lucky), and the process takes months. Maybe 6 months. Yes really. To connect a solar farm to the power grid.

Now don’t get me wrong, in terms of actual work done by people actually doing things, its maybe a week. But the paperwork and pen-pushing can take six months. The whole pre-building process for a 1MW plant can be a year or two years.

We.Do.Not.Have.Time.For.This. as a country. Planning reform is not some minor boring topic, its of national strategic importance. None of our climate change goals will be met without it.

Doing It Wrong

There is a brilliant opportunity before us. The energy market in the UK (and probably every country) is undergoing vast, vast change. There is a great moment here where we can bring about really awesome changes to the way people get their energy, and almost every country on earth is ignoring it, probably due to big phat bribes from lobbyists.

Wind power and hydro power are special cases. They only really work at SCALE. Sure, you can put a tiny wind turbine up in a field if you are a farmer, but the efficiency is low. Its just physics, and the doubling of a blade length meaning 4x the swept area and thus energy captured. In other words, Huge wind turbines make more economic sense than small ones. Same with hydro power (as the fixed costs of putting in a system of any size are high).

But setting aside that special case we have something really cool…solar power. This is a solution we should be embracing massively, yes even in the UK, and here is why:

Solar power scales DOWN really well. The economies of scale when it comes to solar are not actually that massive. Sure, they exist, and if I had the money I would totally build a 2MW solar farm instead of a 1MW one… but they are small enough that its still WAY better for you to generate your own power from your own rooftop than it is to buy the power from someone else’s solar farm. Wholesale energy used to be £0.05. Current retail is £0.19.

Every rooftop having solar power is kinda awesome, especially if there is local (either community or individual home) battery storage. It creates what are called ‘micro-grids’ which keep a lot of the back-and-forth of energy flow off of the main grid, and reduces the extent to which the grid needs mega upgrades to deal with the closure of gas plants and uptake of EVs.

We have 10 solar panels in the garden. Not enough, by any means, but still a decent contribution. At their peak, they generate about 2kw per hour. My EV car battery is huge (85kwh) but its not like we use the whole range every day. Here is the recent output:

My panels are almost exactly 10 years old, so they are low efficiency, old-tech polycrystaline ones that are shaded for part of each day, so my output is nothing close to what you would get with brand new panels on a rooftop. My actual energy use is high (working from home, multiple PCs on all day, electric cooking, electric car, old house), so if I could possibly fit some other panels somewhere I would. (In fact the solar farm, is born from my frustration at not being able to have my own home energy independence).

Anyway, the point i am making is that home-solar is totally viable, and the beauty of it is that is DEMOCRATIZES the grid. This is the first time in generations that people have had the option of being able to say to the big multinational companies controlling energy “Thanks guys, but I generate my own power”. Even if you cannot go off-grid, you can reduce the amount of power you need to buy. Its a brilliant way of giving some power back to people instead of letting them choose between maybe 6 identical giant corporations who will still happily make a profit.

We should be boosting residential solar big time. Its also GREAT for employment, because the installation on rooftops is actually pretty labour intensive. Panels are cheap now, a lot of the cost of the installation is just people going up ladders carrying stuff and connecting stuff.

Where is the push in the UK for rooftop solar? Nowhere. I cannot remember the last time a government minister mentioned it, or encouraged it, or even acknowledged it exists. Where is the information campaign? where is the support?

If we don’t start making noise about the alternatives we will find that the ‘green energy future’ looks exactly like the coal energy past, with giant faceless corporations squeezing money from all of us, with a ‘take it or leave it’ attitude. There is an opportunity here for something way better, if only people looked into it.

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:

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:

Event Namecount

..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:

Event Namecountpercentage deviation

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

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

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!