auto-generating blueprints

Enhance your gameplay with these tools. This category is also the right place for tools useful for modders.
Mod databases, calculators, cheatsheets, multiplayer, scripts, libs and other useful stuff that is not strictly in-game mods.
bobDoesThings
Inserter
Inserter
Posts: 21
Joined: Mon Feb 08, 2021 2:16 pm
Contact:

auto-generating blueprints

Post by bobDoesThings »

I've been experimenting with generating blueprints automatically from a list of desired outputs in a period of time. Attached is such a blueprint book. In theory it would build all the entities in my current base in about an hour. Or, probably not in an hour as bottlenecks and other inefficiencies would take a toll. Has anyone else gone down this path?
Attachments
everything blueprint #1.txt
(195.05 KiB) Downloaded 568 times
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: auto-generating blueprints

Post by Qon »

Title and first part of OP says you wrote a program that solves Factorio automatically by calculating what's needed and generates new blueprints without human interaction and places them automatically.

But then the last part suggests that it's just a big blueprint of your entire base that includes a mall that makes the buildings necessary to complete it.

Could you explain in detail what your system does? Because I'm doing the first, making a program in lua or combinators that plays factorio automatically with recursive blueprints and some other modded entities that lets circuit wire signals code for player actions like setting recipes and train schedules and reading the surface.
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
bobDoesThings
Inserter
Inserter
Posts: 21
Joined: Mon Feb 08, 2021 2:16 pm
Contact:

Re: auto-generating blueprints

Post by bobDoesThings »

The part about the existing base was simply a way to generate input to the algorithm, along the lines of:

Code: Select all

bigBaseEntities

^#(
		"#('' 1) "
#('accumulator' 6019) 
#('arithmetic-combinator' 75) 
#('artillery-turret' 18) 
#('assembling-machine-1' 4) 
#('assembling-machine-2' 334) 
#('assembling-machine-3' 1173) 
#('basic-robots-logistic-chest-passive-provider' 16) 
#('basic-robots-roboport' 29) 
#('beacon' 1474) 
#('big-electric-pole' 431) 
#('centrifuge' 13) 
#('chemical-plant' 151) 
#('constant-combinator' 92) 
#('curved-rail' 691) 
#('decider-combinator' 5) 
#('electric-furnace' 935) 
#('electric-mining-drill' 2068) 
#('express-splitter' 1064) 
#('express-transport-belt' 44631) 
#('express-underground-belt' 2240) 
#('fast-inserter' 5845) 
#('fast-splitter' 100) 
#('fast-transport-belt' 3179) 
#('fast-underground-belt' 441) 
#('filter-inserter' 30) 
#('flamethrower-turret' 1) 
#('gate' 4) 
#('gun-turret' 1) 
#('heat-exchanger' 192) 
#('heat-pipe' 398) 
#('inserter' 259) 
#('lab' 137) 
#('laser-turret' 2916) 
#('logistic-chest-active-provider' 61) 
#('logistic-chest-buffer' 2) 
#('logistic-chest-passive-provider' 225) 
#('logistic-chest-requester' 175) 
#('logistic-chest-storage' 124) 
#('logistic-train-stop' 31) 
	"#('logistic-train-stop-input' 31) 
	#('logistic-train-stop-output' 31) "
#('long-handed-inserter' 590) 
#('medium-electric-pole' 5999) 
#('nuclear-reactor' 16) 
#('offshore-pump' 22) 
#('oil-refinery' 19) 
#('pipe' 2135) 
#('pipe-to-ground' 2497) 
#('power-switch' 1) 
#('programmable-speaker' 1) 
#('pump' 44) 
#('pumpjack' 62) 
#('radar' 260) 
#('rail-chain-signal' 148) 
#('rail-signal' 383) 
#('roboport' 1145) 
#('rocket-silo' 1) 
#('small-electric-pole' 4580) 
#('small-lamp' 157) 
#('solar-panel' 8501) 
#('splitter' 2) 
#('stack-filter-inserter' 571) 
#('stack-inserter' 1818) 
#('steam-turbine' 384) 
#('steel-chest' 995) 
#('steel-furnace' 102) 
#('stone-wall' 19109) 
#('storage-tank' 59) 
#('straight-rail' 15333) 
#('substation' 2351) 
#('train-stop' 32) 
#('transport-belt' 711) 
#('underground-belt' 311) 
#('wooden-chest' 201))
The algorithm then generates factories to try to produce the above items in one hour (or any other chosen interval). A little more on the algorithm:
  • for each item in the list compute raw and intermediate items required
  • generate assemblers/chemical plants/etc to produce these items in the desired time
  • if the resulting factory exceeds belt capacity, split it into multiple factories with lower requirements
  • if the resulting factory has excess capacity, include some of the other items which share the same inputs
  • generate blueprint(s) with factories sandwiched between rows of roboports
From that point, place the blueprint and connect input belts.
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: auto-generating blueprints

Post by Qon »

Sounds pretty neat then. I wrote some code to calculate the resource need and machines needed for each recipe before.

I then manually converted to a design according to a template design. But I also tried to get it really compact and fitted in oil processing in spaces only large enough for assembly machines really and had to do some creative piping which took a lot of time. And then the recipes got updated and I had some issues where production would drop every 10 minutes or so for some reason I could never find, even though everything was balanced perfectly according to my calculations.

But you didn't share the code though. Just the blueprint.
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
bobDoesThings
Inserter
Inserter
Posts: 21
Joined: Mon Feb 08, 2021 2:16 pm
Contact:

Re: auto-generating blueprints

Post by bobDoesThings »

Sharing the code is doable, but exactly trivial. It's written in Smalltalk (not everyone's favorite language) and making something simple for others to understand and use would take some thinking.

What I was looking to do was something between a purely hand-assembled factory and someone else's blueprint just slapped down on my map. I was interested in what kinds of factories could follow from desired output plus a few simple rules. I also sometimes look at those factory snippets in Factorio ads and splash screens and wonder if something similar could be auto-generated. I don't know if it will ever really be useful, but I like the idea that generated factories are only dependent on a few rawish materials and build everything else they need, so expanding production is fairly straightforward.
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: auto-generating blueprints

Post by Qon »

bobDoesThings wrote: Wed Jun 02, 2021 1:09 am Sharing the code is doable, but exactly trivial.
If it's trivial then do it :)
bobDoesThings wrote: Wed Jun 02, 2021 1:09 am It's written in Smalltalk (not everyone's favorite language) and making something simple for others to understand and use would take some thinking.
Smalltalk is text, so just paste it in in a

Code: Select all

code block
and done...
You don't have to do anything to it really. I haven't used Smalltalk but I'm sure I can skim through it and gain some kind of understanding of what problems you tackled and how they were solved.

It would be more informative than reading the b64 encoded blob in a text editor of a .txt file that you submitted instead.... :shock:
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
bobDoesThings
Inserter
Inserter
Posts: 21
Joined: Mon Feb 08, 2021 2:16 pm
Contact:

Re: auto-generating blueprints

Post by bobDoesThings »

I have added the source code as an attachment rather than inline due to size. I guess you understand I meant to say "not exactly". Anyway, let me know if you find this useful
Attachments
Bob-Factorio.st.txt
(271.51 KiB) Downloaded 291 times
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: auto-generating blueprints

Post by Qon »

That's a lot of code!
And Sublime text doesn't even have syntax highlighting as an installable addon for Smalltalk, and Ubuntu text editor doesn't have it either :o
That makes it a bit harder to read.

I'm a bit confused by the timestamps found everywhere in the code. What are those for?
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
bobDoesThings
Inserter
Inserter
Posts: 21
Joined: Mon Feb 08, 2021 2:16 pm
Contact:

Re: auto-generating blueprints

Post by bobDoesThings »

That's why I said was not trivial. Once that text is filed into a Smalltalk image, it becomes much more readable:
Screen Shot 2021-06-02 at 10.57.20 AM.png
Screen Shot 2021-06-02 at 10.57.20 AM.png (210.07 KiB) Viewed 8461 times
The timestamps in the code are when a method was changed. There is a quite a bit of history available in the browsers.
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: auto-generating blueprints

Post by Qon »

That looks different. Thanks for sharing.
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Post Reply

Return to “Tools”