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

Production Line DLC#2 COMING SOON

So we now have an official coming soon page for the new Production Line expansion pack (Design variety pack). Here it is in all its amazing html glory:

https://store.steampowered.com/app/1174730/Production_Line__Design_Variety_Pack/

Obviously the most exciting part of the page is the ‘add to wish-list’ button, which i thoroughly encourage people to do, as gossip among indie devs is that having high wish-list numbers converts into valve sending you nicer chocolate at Christmas, or something like that (I forget the details). Actually the best thing for me to do is probably embed the steam widget thingy:

I have no idea why there is a scrollbar on that widget. I think its safe to blame the mess that is wordpress…

Anyway at the moment the store page is not translated into each language but I’m getting that done now. All the actual content is done, and tested in game, and the new cars look lovely. Its purely cosmetic, so don’t yell at me if you can’t afford it for ruining game balance or whatever. I read that epics cosmetic DLC earns them a bazillion dollars and I’d like to retire eventually (ha!.. will never happen), so somewhere in that paragraph is my reasoning for adding content to the game…

On less business-y levels… I’m tracking down some ultra-rare but annoying Production Line bugs right now. One is a thing where very, very rarely, sounds stop streaming, or the music stops (after a good number of hours). I am digging into this, but its super hard to pin down.

Another bug is related to an error message in logs (which is now harmless…but bugs me) relating to shaders, and some visual artifacting. I discovered that the two different systems I was using to set and unset shaders may potentially have come into conflict, so I fixed that abominable code architecture by ensuring the game only has one possible system for turning shaders on and off, and hopefully now there can never be a conflict or a shader ‘stuck’ on. This will all be in the next patch, just before the DLC release.

Oh…and expect more Democracy 4 update goodness soon

Why you definitely should polish & update your game

I know there have been surveys and studies in the past that show how many indie games on steam have sold a very small number (like under 10) of copies. Its no secret that many indie games are total flops. Its also no secret that the indie games market has skewed in recent years to be more hit-driven than in the past. There are a relatively small number of games making huge sales and a LOT of games making virtually no sales. I think that a lot of devs attitudes to this are somewhat fatalistic, and probably counter-productive and I want to explain why.

The general, subconscious ‘common-sense” supposedly rational mental model to how work equals success looks something like this:

But in actual fact, it seems to me that the real graph, in the real world is actually a lot more like this: (excuse my quick crappy hand drawn mess)

Which is something we are absolutely not used to dealing with, because we do not naturally encounter anything like an exponential curve in our primitive ape-like brains. here is a great article explaining just how ‘against common’ sense this is:

(Scroll down to ‘All of This Could Happen Soon‘ to see an amazing animation that shows just how much exponential curves totally fuck with our brains).

This should be intuitively obvious. Our primitive ancestors did not ever have to deal with exponentials. We hunt for an hour and find a single wild squirrel to kill and eat (my knowledge of primitive man is…sketchy). We hunt for 2 hours, we find and kill 2 squirrels. At no point did we ever hunt for 8 hours and then find/kill 32,600 squirrels. This is not in our experience. In fact, its not been in human experience, in the day-to-day sense, until EXTREMELY recently. Until the internet, we had ‘natural barriers’ to extreme success. To be popular as an entertainer in Michigan, you needed to live in Michigan, or have a sales team/rep in Michigan, or at the very least in the USA. Now anybody can make and sell anything anywhere. The total audience size for your product is probably a few BILLION people. Sell a $20 video game and you can potentially make $40 billion. Its extremely unlikely…but its POSSIBLE.

And even if you never achieve that, you have to accept the fact that other people are doing it. Fortnite and Minecraft are not selling to hundreds of thousands, but to hundreds of millions of people. NOBODY is safe from the financial and marketing reach that those games have. That includes you.

To put it another way: the natural result of global reach due to the internet, is that the big can get bigger, and bigger and they can and WILL compete with you. There is no local home-team advantage. There are no barriers. We are in the age of exponential entertainment. EVERYBODY knows about Game of Thrones, The Avengers Movies, Harry Potter et al…

So thats just fab…but how does that help a struggling, probably failing, probably bankrupt indie dev?

You have to learn to embrace and enjoy exponential growth.

In practical terms, what it means is that every improvement to your product yields an increasing relative improvement in sales. It also means that the very earliest upgrades and improvements to your product are the least rewarding, in comparative terms. When you check out the graph above you can see that if we make linear steps to the right along the X axis, each step yields a higher and higher boost in sales.

To put it yet another way, the first patch for your game will boost sales by a tiny, almost unnoticeable amount. The 99th patch for your game will double its sales. Yes really.

I am fully on-board with this mentality because my latest game (a car factory tycoon game called Production Line) is about bottlenecks. Like all factories, a factory in production line will move at the speed of the slowest link in the chain. The first few improvements to your line will maybe only raise production from maybe 1 car/hour to 2 cars an hour. The final ironing out of bottlenecks will take you from maybe 250-300 cars an hour.

Think about the effort required to improve fortnite by 1% in terms of content, quality, or presentation. Now think about how to improve your game by 1%. Its probably not a MASSIVE difference. Game engines and game design are very similar whether a game is a smash hit or an also-ran. But a 1% boost in your games sales will buy you a coffee, whereas a 1% boost in fortnite sales buys Belgium.

The problem is…people give up. They put in ALL THAT EFFORT to update their game with less bugs, more polish, more features, or a tweaked balance/difficulty/onboarding process and they earn an extra cup of coffee a month. WHY BOTHER? That is 100% the way most rational humans think. They then abandon the game, and start a new one from scratch, or leave the industry.

Do Not Do This

Read every article you can about compound interest. Then read about the chess rice wager, or simply watch this video to understand exponential growth:

And yes…its seems MAD doesn’t it? Like there is NO WAY that simply doubling something regularly so rapidly builds a pile of rice so high it stretches to the edge of the solar system. Those numbers MUST BE WRONG.

A bit like…. the sales figures of minecraft and fortnite.

So back to indie games… the point of the update that only has the impact of earning you a cup of coffee, is that the extra player (just one) per month builds a bit of momentum. The next update gets you another cup of coffee/month PLUS the extra 1/4 shot of coffee from a partial signal boost from the extra player and so on and so on… until every time you update the game you get a huge boost in the success and sales. This can take a while, and MOST people give up.

I am currently working on update 81 for production line. You can read the list of updates to the game on steam here: https://steamcommunity.com/app/591370/allnews/

Its a very, very long list. Its also enabled me to run a lot of steam visibility rounds on the game. I think the last one was number eight, and every time I run them, they are being shown to a bigger, and bigger audience, which helps grow the game even more because now we have more sales and thus more eyeballs and thus more sales and thus more…

The average indie gamer with mediocre or disappointing sales is at the 3rd or fourth square on the chess board. they have their 16 grains of rice, and they go take a job at facebook which pays them 64 grains of rice, which is obviously a better deal. Meanwhile Tim Sweeny and notch are sat on a pile of rice larger than Everest wondering why everybody else gave up so early.

TL;DR: The first post-release update for your game is the least effective in driving sales. This should be mathematically obvious, as its being delivered to he smallest ever number of customers. Giving up at that point is common sense AND totally and utterly wrong.

Extinction Rebellion, Monday 7th October.

When you read this, I will be on my way up London (if not already there) to take part in the Extinction Rebellion uprising to drag climate change back to the top of the political agenda. This is something I feel extremely strongly about.

I’ve been going on environmental protests, and supporting environmental issues for about thirty years, after first reading a book on topic when I was at university. Over the years I’ve been that guy giving out leaflets in the street, writing angry letters to politicians and businesses, and that guy who stands outside government buildings holding banners and hoping to affect some sort of minor political change through direct action.

Technically I’ve been guilty of breaching a number of laws doing this, even risked arrest under anti terrorism laws (widely mis-used against peaceful protesters in the UK). I’ve been filmed by the police and asked to give me name, but never arrested or charged yet.

Today, along with many thousands of people, I’ll be in London trying to cause as much disruption as possible to drag this issue to the forefront of the political debate. This will likely involve a LOT of disruption, a LOT of police. There will be a lot of arrests, certainly hundreds. It will be a big deal, and its happening all over the world, not just in London. I *probably* wont take any risks that mean I’m arrested and kept overnight, but you never know…

I’d like to bust a few myths on this topic.

Firstly, not all environmental protesters are unemployed hippies. There are ALWAYS some people who show up with dreadlocks and bongo drums. You cant stop them. There are always people who try to twist the whole climate change message into being anti-capitalist, or a far-left agenda, or link it to a number of other issues. This is a small, minor, hardcore set of people who tend to get on TV, and tend to describe themselves as spokespeople, regardless what the rest of us think.

I’m a 49 year old company director in a software company. Not a hippie, not unemployed, have never played the bongos, definitely not anti-capitalist at all. I’m concerned about climate change because its happening RIGHT NOW and if you read about it, its FUCKING TERRIFYING. I am scared. I think this is way scarier than terrorism, or brexit, or inequality, or bio-terrorism. I am not doing this because I care about squirrels, or have a passionate fear for future generations. I’m doing this because if I don’t, its going to ruin my life, along with yours.

The best time to prevent climate change was about twenty years ago, when people like me used to bang on about it. Everyone ignored the issue (and they still are), so now the situation is absolutely critical. This isn’t something we sort out after brexit or after trump. It has to be sorted out immediately, and drastically. This isn’t a problem for your kids or your retirement, its a problem right now, this year.

Which means that this, being the last big environmentalist protest of the year is basically the last chance to protest before ‘shit gets real’ and everyone wakes up to how bad things are. This is the last chance to force governments to take real action. Not ‘£10 million subsidies for some EV charging points’ but dramatic economy-spanning action. We can’t be doing crazy shit like expanding heathrow airport, or fracking. Those are literally suicide. We need to tax airline fuel NOW, we need to increase fuel tax NOW and we need drastic, huge incentives for constructing more renewable energy, and switching cars, trucks and buses away from petrol/diesel.

In theory, I shouldn’t care so much. I’m 49, have had a good life, have no kids, earn a very good income, and sensibly bought a house on fairly high ground. We even have a well, and some land to grow a small amount of food (not enough). I can afford an electric car without subsidies, and I could afford a doubling of food prices. However…most people are not in this position, most people are fucked.

And if you only remember one thing from this blog post, let it be this: That climate change is very likely going to decimate crop production. That means vast increases in food prices. Likely food rioting. Not food rioting just in ‘the developing world’ but everywhere. Imagine the cost of the weekly food shop in the UK doubled in 2 years, think about the implications for poverty, law and order, immigration and the kind of extremist right and left-wing groups that will come to power in the chaos.

Climate change isn’t just about warmer summers or colder winters, its about a dramatic economic shock wave starting at food production and sweeping through the whole economy, destroying political consensus and social stability as it does so. Its already started.

I’ll be in London today because I could not possibly explain to future me what I could have done on this day that was somehow more important.

Democracy 4 Update

YES! We are working hard on this, although its been mostly under-the-hood tech and background stuff so I haven’t been updating people much on progress because there has not been *that much* we wanted to show yet, but that is going to be changing a lot real soon…

So, for those in the dark about this, Democracy 4 is the upcoming sequel to Democracy 3 (what a shock!) which is positech’s best selling game so far. Its a politics strategy game where you play the role of President/Prime Minister of a real world country and have to keep the economy in decent shape while staying popular enough to be re-elected, AND presumably helping change the country for the better (in your opinion :D).

For people who have never played the original games, the user-interface is unusual because its basically just a complex connecting web of icons. here is a screenshot from the main screen in Democracy 3:

And here is the current (work-in-progress) equivalent for Democracy 4:

Obviously the general style, fonts and so-on have all changed, but also we have moved the voter groups from the middle to the left. This gives us some interesting options, because this is now a list that can be (at the players discretion perhaps) sorted by popularity, or by membership, or any other metric. Or sorted alphabetically even, none of which were options in the old UI.

its really hard to see in a static screenshot, but the big under-the-hood changes for D4 are that its unicode from the very start (hello Russian and Chinese!), and also most of the UI is being done with vector-art rendering, meaning everything is pixel perfect regardless of screen resolution or zooming/scaling. For a game that is mostly UI, this makes a BIG difference. basically no more blurry UI elements anywhere :D. Its also cross platform from the start.

So far we are still at the ‘getting the core engine working right’ stage along with the ‘commission loads of art’ stage, so although a lot has been done, there is not a LOT that we want to show you in terms of new events, policies or situations yet. However, that will be coming soon. We already have a bunch of new ministers and voters…

Once we are putting in new simulation content, I’ll start doing regular blogs (probably video ones too) that detail the progress made on the game. I’d love to be able to tell you an exact date for us to go early-alpha (likely direct sales), Early-Access beta and final release, but I just cant be sure about those dates just yet. Obviously I’m well aware that 2020 is a US election year and we want to be coming out before the election :D Stay tuned for more updates etc, you can follow me on twitter, or join our mailing list (see sidebar) if you don’t want to miss anything.

Speeding up Production Line (large factories)

I thought I might try another of those ‘live blog’ entries where I go through my thought processes as I do some code profiling to speedup the route-finding slowdowns on super-huge Production Line factories. Here is the map I’m analyzing usage on.

I’m loading the map, waiting 20 seconds, then making a change to the resource route layout, then letting it run another 20 seconds, and taking a look at the function level profiling snapshot using aqtime. This save gamne has 8,994 slots in it (which is massive) and uses a custom map.

Here is the function breakdown for the GeneratePath() code which seems to be a major cause of any framerate issues when changing routes:

I probably need a refresher in my mind as to how this code works so… Lets look at when I change a route by (for example) placing down a new conveyor. This makes the following calls:

			SIM_GetResourceConveyors()->RefreshExits();
			SIM_GetResourcesRoutes()->PurgeAllImpossible();
			SIM_GetResourcesRoutes()->InvalidateRoutes();
			SIM_GetResourceObjects()->OnRouteAddition();

RefreshExits is trivial, taking on average 0.002ms, so not a problem, PurgeAllImpossible() doesnt show up in the profiler, but it basically sets a lot of flags to be false, and calls a sub function that also is presumably too quick to show up, so likely not a culprit.

InvalidateRoutes() is likely the culprit. It tells every slot, and every stockpile that it needs to begin verifying its current cached route table in case something has changed.

Finally OnRouteAddition goes through every intransit resource object and tells them they need to verify their route(over the next two seconds) in case a newer route is available, or the current one just got deleted. This is also too quick to show up.

So it looks like all that route invalidation is the slowdown. But why? The actual function takes 0.2ms, which is slowish…but not noticeable when a frame is 16.0 ms. Its the delay over the next few seconds that causes the problems… Basically every slot with a stockpile calls PrepareToVerifyBays()…

void SIM_PlaceableSlot::PrepareToVerifyBays()
{
	BayVerificationPending = true;
	int limit = BAY_VERIFICATION_INTERVAL;
	if (APP_GetPerformance()->DoRoutesLimitFramerate())
	{
		limit *= 2;
	}
	BayVerificationTimer = GRandom::RandomChoice(limit);
}

So in English, this code tells the slot that it needs to verify its nearest import bays, and to do so at some random time over the next 60 frames (1 second). A globally calculated value works out if we have a poor framerate, and if we are verifying bays, and thus notes that given this PC, this map etc…we need to allocate twice as much time as usual (4 seconds) to verify those bays…

Thus we have maybe 4 seconds max (4,000ms) over which to spread the effect of all this route re-calculation. That might mean up to 4 seconds of lag, which may seem a short time, but if you are watching a resource item getting delivered in the game, and it travels down the wrong route for more than four seconds…you would be perplexed, so its a reasonable target. How to make it faster?

Bays are verified every frame. a check happens every frame to see if a verification is pending, and if it is, a function gets called. That function is pretty huge and its called SIM_ProductionSlot::RecalculateNearestBay(). In my profiled sample it was called 2,200 times and on average takes 2.8ms. OH MY GOD. Almost all that time is spent inside SIM_ResourceConveyorManager::GetNearestBays(). This function itself does some fancy multithreading, spinning off taks to a lot of threads (8 on my PC) each of which processes a list of routes, eventually calling SIM_PathFinderManager::FindPath(). This gets complex so lets look at a multithreaded analysis of it in vtune:

This actually looks pretty efficient and packed, so i think that the real answer to speeding this up is not speeding up the actual route-verification, but culling the cases in which I actually even bother verifying a route. For example…Here is a simple map with production slot stockpiles at A and D, and import bays at B,C,E,F…

Both A and D keep a track of the shortest route along conveyor belts to the 2 nearest import bays. Note not every tile is a route, only each one marked with conveyors, so we have the following.

Now lets say I add a new conveyor belt tile to improve the routing from A to its two nearest bays…

Now as mere humans, its pretty clear to us that as soon as possible, we need to get A to recalculate those two routes it has to its nearest bays, because there is now a shorter route from A to B (but actually not C). Its also pretty clear that D’s routes (to E and F) are totally unaffected. Right now… my algorithm is dumb as fuck, because it tells A and D ‘OMG something changed! redo everything!’, which is a massive waste of resources. The problem is…How exactly does a better algorithm look?

This is one of those things that sounds simple but actually is not. If I learned computer science at school I’d likely be better at this, but I’m self taught. Here is my current thought process:

The route from D to E is 4 tiles. The distance from D to the new tile (pointed at by the arrow) is greater than 4. Thus there is NO way that my route from D to E can possibly be affected by this change. Thus I can leave D as a slot that keeps its old fashioned routes.

So an algorithm that made this optimization would be something like:

For Each Slot
bool bcheck = false
int max_dist_bay = GetMaxDistToBay()
For Each changed tile
If CrudeDistanceToTile <= max_dist_bay
bcheck = true

So its worth trying to see if that helps…

…And I tried it! I even wrote some debug output to verify that the number of slots that got verified each time was below 100%. Something I didn’t realize was that obviously for changes taking place right in the middle of a map, the majority of the map ends up being covered by this algorithm, as the distance for slots to the center of the map is often about the same as the distance to the nearest importer. However, when making changes nearer the edges and corners of the map, a way smaller percentage of the slots need verifying, sometimes just 2-4% of them.

Even if I just assume that we average 50% of slots being verified instead of 100%, this represents a 2x speedup in the game during these events, which should be super noticeable. Of course the only way to be sure this feeds through to user experience is to stick the new algorithm on a togglable switch and watch the frame rate counter and…

YES

It boost the framerate a LOT. Obviously its still spread out over the same amount of time, but the total amount of recalculating needed is way lower so… obviously we get a big framerate boost.

This is NOT a perfect optimised way to do it, but you can bet its already roughly twice as fast, which is great. I need a better way to work out what slots are needlessly recalculating, AND I need to ensure I can use similar techniques on situations that cause a recalc by other means, such as when stuff is deleted but…its definite progress.

I’ll probably work on the deletion case tomorrow, do some more extensive testing, then try it out in the 1.80 preview build (unstable beta) on steam.