News for hackers. Stuff that matters.
Re:Factorio and Software Engineering by kentonv on Sunday August 16, 2020 @07:12PM (#24182196)
> a certain component (electronic circuits) was being produced in 4-5 places. I eventually replaced them all with one centralised production array to simplify the factory.

Nah, electronic (green) circuits are high-volume but low-complexity to build. They are a good example of something that should not be produced centrally, because if you do, you have to invest a lot in high-volume transport to get them where they need to go. Much better to build dedicated electronic circuit factories wherever they are specifically needed.

Silly analogy to programming: Microservices. It makes sense to have a microservice to perform, say, user authentication, which is complex and only needed occasionally. It does not make sense to have a microservice to implement printf formatting, because you'll be calling it way too often and it'll waste a ton of network bandwidth. Better to import a string formatting library into each service.

Re:Factorio and Software Engineering by cortesoft on Sunday August 16, 2020 @07:50PM (#24182403)
Nah, as others have pointed out, green circuits are used everywhere. Since they meet that requirement, the only thing else to ask is, "Do the materials take up more or less space than the item produced?"

For green circuits, it takes less transport to move the green circuits than to move the materials to make them, so you should make them centrally and distribute the circuits.

Copper wire, on the contrary, is used in many things but takes up more space than copper plate, so you should make it locally.

Re:Factorio and Software Engineering by munchbunny on Sunday August 16, 2020 @09:23PM (#24182908)
Electronic circuits are a great example of "it doesn't really matter because for 99% of players the factory won't fall apart due to this decision."

In practice it can go both ways. Many of the production chains that take green circuits as an input require such low quantities that 1-2 assemblers is more than enough, so the marginal complexity of trickling them to where they're needed is low. And they only require the two basic input resources that are needed almost everywhere, so the alternative of making them on site isn't that complex either.

However, if you are trying to do a megabase (where you keep playing post-endgame and basically scale for the sake of scale), your green circuit demand shoots through the roof, and you will end up sinking half of your basic materials into making green circuits. At that point the plumbing itself becomes so complex to maintain high throughput that centralizing green circuits is an economy of scale decision. Additionally, the production ratios (number of assembler units you use for each intermediate product) will change, so it's easier if all of the green circuit production is in one place than to make individual changes in a lot of places.

Green circuits are distinct because (1) they don't save that much space compared to the basic materials you input to make them, and (2) demand for them is modest at first, but becomes a primary bottleneck if you're going for scale, and (3) their inputs are resources you need almost everywhere, so they're already there anyway. Most of the other resources for which you consider centralizing production, you do it because you save a ton of bandwidth by centralizing, or because demand is always high, or because the inputs are more complex to move (such as fluids).

In practice demand for green circuits is so huge primarily because of demand for blue circuits, so I will often make all circuits offsite and ship them in. The 20+:1 compression ratio you get from moving blue circuits offsite is a much bigger win.

Re:Factorio and Software Engineering by infogulch on Monday August 17, 2020 @12:48AM (#24184092)
"Green circuits locally or centrally?"

> it doesn't really matter because for 99% of players the factory won't fall apart due to this decision

"Do I Need Kubernetes?"

> it doesn't really matter because for 99% of developers the infrastructure won't fall apart due to this decision

Factorio and Software Engineering :)

Re:Factorio and Software Engineering by munchbunny on Monday August 17, 2020 @08:50AM (#24186723)
Absolutely, Factorio has so many parallels to software engineering. My buddies have joked that you can tell how someone writes code from how they play.
Re:Factorio and Software Engineering by Sohcahtoa82 on Monday August 17, 2020 @08:34PM (#24194023)
I wonder what they would say about my factory style.

I tend to have a whole bunch of belts running from west to east, each belt carrying one type of item. When I want to add a new product, I put a splitter on each belt that carries and ingredient, with the second output branching down under all the belts carrying other products until it reaches a vertical line of assemblers. The output of those assemblers combines to a new belt that continues east.

The main factory ends up looking almost triangular [0], with vertical strips of assemblers dangling off the hypotenuse. One of the advantages of this approach is that scaling is simple, just add more assemblers and faster belts! Though it's possible to eventually reach a point where even the fastest belts can't carry enough products. In that case, you can just add another vertical strip of assemblers with separate inputs.

[0]https://media.discordapp.net/attachments/741107040079970314/...

Re:Factorio and Software Engineering by a1369209993 on Sunday August 16, 2020 @10:03PM (#24183166)
> However, if you are trying to do a megabase [...] it's easier if all of the green circuit production is in one place

As you allude to later, it's not really about green circuits for a megabase. Since blue circuits require 24 green circuits (20 directly and 2 for each of 2 red circuits), your huge demand for green circuits comes mainly from blue circuit production. It makes sense to centralize blue circuit production, so most of your green circuit production should be right next door, which is both on-site and centralized. But the green circuit production that isn't feeding directly into blue still doesn't really matter whether it's on-site or centralized.

Re:Factorio and Software Engineering by kentonv on Sunday August 16, 2020 @08:23PM (#24182574)
If belt networks were only about capacity, sure. But you can't put two different kinds of things on the same belt lane without creating some serious trouble. So, the more different kinds of things you want to transport by belts, the more parallel belts you need. Plus, you need those parallel belts early on, even before any of them are running at capacity.

I find it much easier to lay down just iron/copper belts and upgrade them as needed -- upgrading speed in cases where adding parallel lanes is inconvenient.

Re:Factorio and Software Engineering by fennecfoxen on Sunday August 16, 2020 @10:13PM (#24183212)
It’s not just about capacity. It’s also about:

- using machines efficiently (in the sense that a central production facility means idle-capacity can be used elsewhere)

- replacing production efficiently, I.e. yolo build a potato-quality factory now so that it’s actually producing, then expand it to hyper efficient maxed productivity modules in all the machines between maxed speed beacons later (so your resources go further and you don’t need to spend as much time building remote bases), but do not interrupt production forever to rebuild everything during the transition.

Yolo-building with a high quality strategy to replace components is also a great strategy for startups. In either case the real limiting resource is manpower.

And I typically target about 8 belts of green circuits, to feed a nonstop-rocket shop (avoiding the major transition off belts altogether.) Get a balancer design off the Internet. It’s fine. :)

Re:Factorio and Software Engineering by cortesoft on Sunday August 16, 2020 @08:35PM (#24182638)
Sure, but this is only an issue if you need less than a full belts worth of green circuits... if you remove that belt of green circuits, you are going to have to replace is with MORE than one belt of raw materials.
Re:Factorio and Software Engineering by llukas on Sunday August 16, 2020 @08:37PM (#24182651)
On full scale it is about trains worth of green circuits.
Re:Factorio and Software Engineering by svick on Monday August 17, 2020 @02:38PM (#24190334)
> But you can't put two different kinds of things on the same belt lane without creating some serious trouble.

Sure you can, it's called a "sushi belt" and with some simple combinators, it can work reasonably well.

Re:Factorio and Software Engineering by Cthulhu_ on Monday August 17, 2020 @05:09AM (#24185415)
But you only need iron and copper plates to make green circuits; in bigger factories, if you want a central place to make green circuits, you'll end up having to use 3 dedicated belts just for green circuits.

But that's what I had anyway in my last game, a big central line with a lot of the essentials. I think next time I'll go for a central line with just iron and copper and mini bases that take from it, or something. More trains as well, bringing in ore from all over the map.

Re:Factorio and Software Engineering by haar on Monday August 17, 2020 @07:09PM (#24193369)
Smelting on site and shipping plates doubles your train volume as you can stack 100 plates per slot vs 50 raw material.

Can make your train routes/efficiencies easier to manage.

Re:Factorio and Software Engineering by me_me_me on Monday August 17, 2020 @05:34AM (#24185554)
Factorio and Soft Engi, it doesn't really compare.

This and parent post quickly proved my wrong.

Re:Factorio and Software Engineering by m463 on Monday August 17, 2020 @12:06AM (#24183840)
> Copper wire, on the contrary, is used in many things but takes up more space than copper plate, so you should make it locally.

I thought the same thing, but I think copper plate stores 100 in a stack and copper wire stores 200 in a stack.

I don't know what that means for inserters. (like low density structures - can stackers move more of them, even though you can store less in one slot?)

Re:Factorio and Software Engineering by cortesoft on Monday August 17, 2020 @12:43AM (#24184061)
Sure, if you are transporting them via rail it would be the same.... but on belts, nothing stacks.
Re:Factorio and Software Engineering by Cthulhu_ on Monday August 17, 2020 @05:10AM (#24185427)
It's not so much about stack size as it is about how much you can fit / move on a conveyor belt. A lot of the setups I've used involve having a copper wire factory (or two) right next to the factory that uses them, no belts / buffers in between.
Re:Factorio and Software Engineering by X6S1x6Okd1st on Sunday August 16, 2020 @09:22PM (#24182896)
Yeah copper wire and wheels are one of the few things that I almost always produce at the local site.
Re:Factorio and Software Engineering by LoSboccacc on Monday August 17, 2020 @02:21AM (#24184516)
tbf of you're shooting at efficiency you should be build a circuit conglomerate not because of transport, but because of beacons
Re:Factorio and Software Engineering by mikeappell on Sunday August 16, 2020 @07:33PM (#24182318)
Gonna disagree there: green circuits (and their descendents) are needed often enough and in high enough volumes that it absolutely makes sense to bus them. I've got four full lanes being almost completely consumed, much by red circuit production.

Certainly if you need a very small volume in one specific location and already have copper and iron present you can slap down an assembler making copper wire and another making the circuits, but that's generally far less space efficient than just pulling them in from the bus.

Re:Factorio and Software Engineering by nordsieck on Sunday August 16, 2020 @07:47PM (#24182385)
> Gonna disagree there: green circuits (and their descendents) are needed often enough and in high enough volumes that it absolutely makes sense to bus them.

I think your parent was making a different argument.

Sure you use green circuits everywhere, but your compression ratio on belts is only 2.5 : 1. Not much better than gears, and I don't think anyone recommends centralizing gear production.

I too centralize green circuit production, but I think it's on the edge of what's reasonable

IMO, the thing that pushes it over the edge for me is that it takes 2 inputs (copper and iron), whereas resources that I distribute like gears or pipes only have 1 input.

Re:Factorio and Software Engineering by oconnor663 on Sunday August 16, 2020 @11:27PM (#24183584)
> Sure you use green circuits everywhere, but your compression ratio on belts is only 2.5 : 1

That said, your compression ratio on trains is double that again, because the green circuits have a stack size of 200.

Re:Factorio and Software Engineering by kentonv on Sunday August 16, 2020 @08:12PM (#24182505)
To me the "main bus" design feels like Java OOP maximalism. Maybe some sound principles behind it, but feels too heavy-handed, unable to adapt to circumstances. Or at the very least, it's not any fun.
Re:Factorio and Software Engineering by lalaland1125 on Sunday August 16, 2020 @08:20PM (#24182556)
It's actually the opposite. Having a main bus tends to make your factory more flexible and easier to adapt for improved technologies / throughput.
Re:Factorio and Software Engineering by munchbunny on Sunday August 16, 2020 @09:10PM (#24182820)
Main bus designs work really well for building one factory to launch a rocket because the resource demands aren't so high that you run into belt scaling problems.

If you're going for one of those crazy ridiculous high output post-endgame factories, the sheer complexity of running 8+ belts of one resource and branching off 2-3 belts at a time, then having to double that to go from 1k SPM to 2k SPM is way too painful. That's why most of the factories you see north of 2k SPM aren't main bus designs (aka well organized monolith), they're modular designs ("microservice" based). I put that in quotes because at those scales the sub-factory for creating a single input resource might be bigger than a whole base used for launching a rocket.

The analogy actually applies really well to software engineering: for a practice that works really well for 99% of the players (main bus), at a certain level of scale the approach breaks down, and you need a different approach to deal with scaling past that point.

As evidence for that, I usually use a main bus design to get to the endgame, but once I start the megabase scale climb, I break the factory out into discrete, networked (by train) modules in order to keep the resource distribution problem under control.

Re:Factorio and Software Engineering by kentonv on Sunday August 16, 2020 @08:25PM (#24182585)
That's what Java OOP people would say too. ;)
Re:Factorio and Software Engineering by Cthulhu_ on Monday August 17, 2020 @05:12AM (#24185432)
It's like the Event Bus pattern, instead of designing loads of point-to-point supply chains you build one big one where everything is pushed to, allowing random factories to consume the products alongside the bus according to need.
Re:Factorio and Software Engineering by fendy3002 on Sunday August 16, 2020 @08:26PM (#24182594)
Fun is relative, however main bus is scaleable, up to certain level.

> unable to adapt to circumstances

One side main bus should be adaptable to many circumstances. I wonder what you mean by it cannot.

Re:Factorio and Software Engineering by munchbunny on Monday August 17, 2020 @12:10AM (#24183866)
In my experience the main bus is perfectly adaptable until approximately “winning the game” (launching the first rocket). Making some broad assumptions, you need to reserve about 16 belts worth of bus width as an upper bound and that’ll be plenty for 99% of players.

It’s like the point of “most web apps don’t need distributed architectures until much later.”

Re:Factorio and Software Engineering by DonHopkins on Monday August 17, 2020 @07:44AM (#24186275)
This is the most interesting, friendly, respectful, online discussion about bussing I've ever read! Usually bussing is such a controversial divisive topic... Kind of like the "tabs -vs- spaces" of transportation and logistics.
Re:Factorio and Software Engineering by hackcasual on Sunday August 16, 2020 @07:19PM (#24182232)
But they stack better in trains. A train load of greens is equivalent to almost 5 train loads of it's precursors
Re:Factorio and Software Engineering by m463 on Monday August 17, 2020 @12:11AM (#24183876)
That's a good point.

300 copper (= 600 copper cables) + 200 iron => 200 green circuits in a stack.

Re:Factorio and Software Engineering by hackcasual on Monday August 17, 2020 @01:48PM (#24189729)
Yep, it's one of the reasons smelting where you mine is popular with train based logistics, since that doubles your density
Re:Factorio and Software Engineering by james_s_tayler on Monday August 17, 2020 @12:05AM (#24183830)
>It does not make sense to have a microservice to implement printf formatting, because you'll be calling it way too often and it'll waste a ton of network bandwidth

http://shoutcloud.io/

Re:Factorio and Software Engineering by Forge36 on Sunday August 16, 2020 @08:29PM (#24182607)
It doesn't make sense to centrally build on belts. At high volumes where trains become more common it can be useful to move to buffer systems dedicated to circuits. It highlights what resources you're short on more obviously (steel or copper).

Sometimes with caching it makes more sense to consolidate. Sometimes the scale can cause latency issues! It's about balancing tradeoffs

Re:Factorio and Software Engineering by searchableguy on Sunday August 16, 2020 @08:00PM (#24182460)
I wonder given the interest of people in factorio here, maybe there could be a HN factorio server.
Re:Factorio and Software Engineering by kentonv on Sunday August 16, 2020 @08:14PM (#24182515)
Eh, personalaly not into internet multiplayer -- prefer LAN parties. https://kentonshouse.com
Re:Factorio and Software Engineering by erulabs on Sunday August 16, 2020 @08:48PM (#24182701)
Happy to host this - my startup already hosts a couple hundred factorio servers :)
Re:Factorio and Software Engineering by keithnz on Sunday August 16, 2020 @10:04PM (#24183167)
an OARC style one would likely work well given how distributed everyone is around the globe
Re:Factorio and Software Engineering by AtomicPlayboy on Sunday August 16, 2020 @07:30PM (#24182300)
DRY, also known as single source of truth, is one of the most important principles in SE. I just could not figure out what the single source of truth is in a factory pattern as is the electronic circuit factory. It implies centralizing the code which is responsible by the fabrication of the circuits, what would be their equivalent in the game? The conveyor belts?

Microservices, on the other hand, are overrated and unnecessary in most cases they are applied.

Re:Factorio and Software Engineering by beckingz on Sunday August 16, 2020 @09:20PM (#24182880)
bleuprints.

You design a decent submodule one time and then make a blueprint and reuse it repeatedly.