Back to blog
Sep 10, 2021
9 min read

Factorio

A game about problem-solving, automation, and building a grand industrial empire. And engineeering.

Why a computer game can make you a better engineer.

Factorio was first released in 2016 after a crowdfunding campaign three years earlier, with release 1.0 in August 2020. I bought it in 2017, but didn’t get hooked until the 2nd NZ Covid lockdown in August 2021. It’s currently the 3rd top rated game on Steam.

Factorio

It’s premise is simple - your spacecraft crashes on a resource-abundant but slightly hostile planet; you have engineering skills and need to rebuild your spacecraft to escape. You have some basic tools and land within suspiciously convenient range of deposits of stone, coal, iron and copper; so you use your pickaxe to dig up some of each. Discovering a certain knack of building things, you make a furnace with the stone, fill it with iron ore and stoke it with coal … and now you have some iron plates.

But that was hard work, running around; so you use your iron plates to build an “inserter” - basically a robot arm - and transport belts and a wood box, and start automating - use the inserter to load the furnace with coal and ore, and the transport belts to move the ore and coal around … and after a while you have enough iron plates to make a mining drill - coal fired - so you can stop using your pickaxe, sit back, and watch.

Once you have the iron ore and coal working nicely, expand out to the copper ore, and smelt that as well to get some copper plates. This means you can now make electric circuits, which opens up two new technologies - one is electricity, generating power from coal and water, (this is really important, feeding coal to everything is a pain); the other is the ability to build assemblers. Instead of manually creating inserters and transport belts, you build an assembler that accepts raw materials and assembles them for you. Load it up with resources, or even better, hook them up to belts so they run continuously - and you have the beginnings of a factory.

One of the things you can produce is “science packs”, which you can use in labs to start exploring the tech tree. That gets you really going, and soon you have assemblers taking in raw materials and producing simple things, which in turn get taken in by other assemblers to make more complicated things … and your factory starts sprawling, and you end up having to build a car to drive around it; running around takes too long. Of course, at this point you have built so much you’ve exhausted your resources. No more iron ore … oops …

But … there are patches of resource on the map - the vast, unending map - which you could use. Too far away for belts - but you can research and build trains. The trains are awesome, and there’s enough detail for a whole game here : build new mines far away, then run train tracks out to them. The mines dump their ore into boxes, and when the train arrives at the stop, the inserters load the ore into the train which then runs back to base and offloads into your smelters. You have all sorts of controls on the stops - wait for 30 seconds, or for 5 seconds of inactivity, or until you’re full up … and then you also have signals so you can stop two trains running on the same piece of track (and crashing into each other.) You can hop on them and drive them manually, or simply ride along as a passenger, but most of the time you leave them as fully automatic, fetching ore from far away and bringing it back to your factory.

And for heaven’s sake, look both ways before crossing train tracks. The trains go very fast, and death by train is by far the most common cause of death in the game.

You’re now ticking along smoothly, all your assemblers are humming away … and just like Fantasia, you now have thousands of smelters, but you only need hundreds. So you research and implement the circuit network, where you can hook up pretty much anything … hook up the storage box containing the finished smelters to the inserter feeding the assembler, and tell the inserter only to work if there are less than a hundred smelters in the box. Now everything is under control, managed production, no wasted resources.

But this is all taking too much time. So you research construction robots, and instead of building new areas of the factory, you create blueprints - either manually or by copying existing layouts - and leave the robots to build it all. Realise you’ve put the ‘green circuit’ assembly line in the wrong place ? Grab it as a blueprint, mark it all for demolition (and a hundred robots whir into action) and lay down the blueprint in the right place. Go away for a bit and when you come back, it’s all working again.

Trains

Your factory is growling - and sprawling. Transport belts are everywhere, going over or under each other, mixing up raw materials - you have acheived what is fondly referred to as ‘spaghetti’. So your research the logistics network - and a new kind of robot. Now you can set up storage chests that ‘request’ certain items from the network, and others that will provide them - and a thousand robots fill the skies, picking stuff up and moving it around where it is needed.

But there’s been a problem. I’ve not mentioned it yet, but you will have run into it by now - the native wildlife. Made up of biters, spitters and worms, they were living peacefully before you arrived; and the pollution your factory makes annoys them, so they come over and attack your base. You started with a pistol and ten rounds of ammo, but you’ve been researching and producing more weapons - rifles, better ammunition, gun turrets, laser turrets, flamethrowers. The escalation is well managed - the more pollution you make, the more aggressive the biters become, and they evolve to be bigger, stronger and nastier … but your research keeps up with them, building bigger and better weapons. I’m currently experimenting with long-range artillery, and nuclear weapons are a distant option on the tech tree.

Battle

The game finishes - if you want - when you launch a rocket into space. I haven’t got there yet - I’m probably 60-70% of the way through. And this is where the genius of Factorio lies.

Why it will make you a better engineer

Much of what I have described won’t sound too groundbreaking - a 4X game (Explore, Expand, Exploit, Exterminate), a tech tree, micro-management and macro-strategy. But Factorio does it so well.

The problems start early - you build a furnace, stoke it with coal and ore, go away to do something else - and when you come back, it ran out of coal. So you need to automatically provide coal - but that means you need to keep the coal mining drills working. You can get them to feed themselves with coal, but electricity works better, and pretty soon you have a reasonable sized, electric powered factory all humming along - until you run out of coal and EVERYTHING stops.

So that teaches you to plan - and probably start doing some maths - and you can relatively easily set up some notifications, so that a light goes on if you have less than a certain amount of coal reserves. But if you’re not careful, you do too well, and all your production lines fill up with items and stop working. So you add in some logic - if I have more than X iron plates, stop the transport belt loading new ore into the furnace.

And then the real maths starts kicking in. An electronic circuit is made in an assembler, and takes half a second, using 1 iron plate and 3 copper cables. A copper cable is made in another assembler from a copper plate : that assembler takes half a second and 1 copper plate to make 2 copper cables. But you need 3 for a circuit, so you need to make sure you have 1.5 times (takes 3, but they’re produced twice as fast) as many copper cable assemblers as electronic circuit assemblers. But it’s not that easy ! Iron plates are made in a furnace from iron ore in 3.2 seconds; the same rate that copper plates are made in a furnace from copper ore - so you need 1.5 times as many copper ore mining drills as iron ore. If you get these sums wrong - and you will, all the time - you will see assemblers sitting idle, with too much of one resource, and none of another.

The transport belts are queues - like a Kafka queue. Furnaces and assemblers will both publish and subscribe to the queue - publishing is straight forward, but subscribing, which is done with inserters - and fairly early on you research filter inserters, which only pick off certain items from the belt (so you have a filter on your subscription.) The parallels are so strong that articles have been written on this.

It’s also beautifully produced - some extraordinary animations. The trains have movable bogies (wheels) that angle as you go round corners; they puff steam while running, which drifts with the wind, and when they actually stop, there’s a beautiful puff of steam around the wheels and a big sigh as it sheds all excess steam pressure; the sound effects are perfect, varied and detailed.

Oh, and I’m not the first to post on this subject …

Factorio and Software Engineering

Functorio

Understanding Kafka with Factorio

The Factorio mindset