Page 1 of 1

Nano factory with push down automata

Posted: Sun Mar 19, 2017 2:40 pm
by gridstop
So ever since I saw Case's original nano factory viewtopic.php?f=8&t=27349 I wanted to do something like that. And I had been experimenting with state machines for solving train issues, so I figured I'd give a universal nano factory w/ push down automata a try.

This uses a single assembly machine (plus two for barelling, more on that later) to build any item in the game, and automatically compute & build all the intermediates in the same machine. The crafting combinator viewtopic.php?f=93&t=34405 is used to switch recipes and compute intermediate products.
The state machine
The stack
The basic operation is something like this. When idle, if there is something on the stack, pop it off the stack into the temp register. Figure out the sub-components, if we have what we need to build it in storage, go ahead and build it. If we are missing at least one sub-component, push the temp register back onto the stack, then go through each sub-component, and anything we're missing push that on the stack too, and go back to idle.
Example transition rules
The assembler
Fluid handling
You could use the same setup to do all your chemical plant stuff as well. Though if you didn't have separate light oil cracking it would probably spend all its time doing that. So far this is just built in creative mode, I'm trying to decide if it's worth trying to actually build a factory using this. It'll probably depend on if there's anything in 0.15 for handling blueprints earlier. I don't really want to rebuild it all by hand.

Practical? Of course not. But it was a lot of fun and taking on the challenge made me feel good about my theory of computation class in college (anybody need a context free language parsed in factorio?), as well as learning a lot about combinators.

Re: Nano factory with push down automata

Posted: Mon Mar 20, 2017 5:24 pm
by Ratzap
Very nice. The first question that springs to mind is this: how easy would it be (or is it even possible) to fetch open logistics requests from the player which cannot be satisfied from storage and then build them for delivery.

Eg: request 3 pumpjacks, 1 in storage then the nano factory builds the last two and places them in storage.

Re: Nano factory with push down automata

Posted: Mon Mar 20, 2017 10:33 pm
by gridstop
Ratzap wrote:Very nice. The first question that springs to mind is this: how easy would it be (or is it even possible) to fetch open logistics requests from the player which cannot be satisfied from storage and then build them for delivery.

Eg: request 3 pumpjacks, 1 in storage then the nano factory builds the last two and places them in storage.
Thanks!

I was trying to figure out a way to see if you could get a 'unsatisfied requests' count from the network. I know when bots are in flight sometimes you can see negative numbers in the logistics network's contents, but I'm not sure what that represents precisely, and it doesn't show you simply 'amount of requests'. For instance a network with a requester box asking for 50 copper, but no actual copper in the network just shows no signal from the roboport.

Re: Nano factory with push down automata

Posted: Tue Mar 21, 2017 9:09 am
by Case
Wow ... just wow .. very impressive.

I would like to see this thing in action - so plz :) make a nano factory out of this concept.

Take Care
Case

Re: Nano factory with push down automata

Posted: Tue Mar 21, 2017 9:51 pm
by gridstop
Case wrote:Wow ... just wow .. very impressive.

I would like to see this thing in action - so plz :) make a nano factory out of this concept.

Take Care
Case
Thanks! Ever since I saw your factory I wanted to build one, but I'm too lazy to sit there and change the recipes to make everything. Hence... this contraption.

Re: Nano factory with push down automata

Posted: Thu May 11, 2017 10:49 pm
by gridstop
I did actually do this before 15.0 dropped. Got lazy bastard too. Research took a LONG time. Let it run overnight twice.

Here's the final setup. I used the crafted artifacts mod to make the chemical processes more interesting (had to make superconductors). Otherwise all it would ever do is make sulfuric & plastic. And since I wasn't going to run with biters.
nano-4.png
nano-4.png (2.83 MiB) Viewed 27517 times
At this point everything was fully automated, I could put it into 'research mode' where it would automatically queue & construct science packs, and I used the research queue mod to keep it going when I was away.

Victory. I feel bad for running over those 4 trees.
nano-win.png
nano-win.png (265.12 KiB) Viewed 27517 times

Re: Nano factory with push down automata

Posted: Mon Jul 31, 2017 11:43 am
by kann_
That is super cool. I was building a very similar setup, but wasn't happy enough with it to post it. very very cool!

You should make a movie and post it on reddit. My plan was to contact the guy with the self expanding mining grid to combine both. https://www.youtube.com/watch?v=xF--1XdcOeM

edit: reading through the description it is fascinating how similar my solution was. I also had a state machine, a stack, the temp register...
My problem was that I tried to do it with less combinators and without bots. -.-

Re: Nano factory with push down automata

Posted: Tue Nov 21, 2017 4:31 pm
by kleopi
Is there a save somewhere, or a blueprint? I'd like to learn some stuff (splitting signals, the stack system, etc).
Awesome work!

Re: Nano factory with push down automata

Posted: Sun Feb 17, 2019 1:50 pm
by T-A-R
im trying my nano attempt now in .16.(waiting for 0.17) i use a beltloop shuffeling a fish trough boxes to create singular signals to determin what is needed to craft. The ingredient combinator (from crafting combinator mod) also saves alot of headache.

Im producing blue potions now, ill make a showcase after i launched a rocket.

Re: Nano factory with push down automata

Posted: Sun Mar 03, 2019 3:10 pm
by gridstop
I did another one of these with a bit different sub-product calculation system (calculates all sub-components at once and inserts them into a single register instead of using a stack) for 0.16. Also did a lazy bastard rocket launch and nuclear power (with a single centrifuge & single reactor of course). Then it could automatically (slowly) do infinite researches, which I did a couple bot speeds before retiring it.

Using a single refinery & chem plant to do all refining/cracking/oil products was interesting too. LOTS of issues counting fluids & preventing jamming when changing inputs & outputs though, it was pretty tedious.

Not sure how fluid system will work with crafting combinator (if and when it gets updated for 0.17) and whether that'll make it easier or worse. They didn't fix any of the real problems with circuit network & fluids with the fractional values not showing up as a signal. Between that and the fact that you can't read logistics requests I probably won't do another one, as there's not really much more to do with it that I can see.

Re: Nano factory with push down automata

Posted: Thu Apr 18, 2019 3:33 pm
by T-A-R
I left my machine after 0.17 dropped. I saw the crafting combinator has updated, but the fluid update is not complete yet. well see what that brings

Re: Nano factory with push down automata

Posted: Fri Sep 10, 2021 12:40 pm
by zynixen
I know it's an old tread, but was hoping someone had a blueprint for this?

Re: Nano factory with push down automata

Posted: Thu Oct 21, 2021 3:35 pm
by T-A-R
The way i tackled the fluid mixing was by using barrels. The crafting combinator can be configured to remove fluids from the connected pipe, thereby automate switching the fluid input. This required a extra barrel assemblers (disqualifying the run somehow). Pics are all version 0.17 btw, the factory was named "We are one", but never launched a rocket yet. I guess i won't be upgrading the 0.17 file so all we have is some pics and a single bp.

178k items crafted.png
178k items crafted.png (3.1 MiB) Viewed 11829 times
Raws are taken from the wagon, intermediates are stored in a sorted register. Distance to the assembler is based on the usage frequency. A mix of register items is kept in the south chests of the crafting assembler.

pit 1.png
pit 1.png (3.44 MiB) Viewed 11829 times
Zoomed out a bit the labs and the fishbit state machine shows. The item register is linked to the computer to decide what is needed via a green wire.

fishbit state machinestripped.png
fishbit state machinestripped.png (787.74 KiB) Viewed 11828 times
The program loops through the items, by the fish on a belt. each loop the intermediates are checked before more advanced parts get ordered on the red wire. When a order is done the fish passes a speaker to play a little happy tune. By using a belt contraption it is easy to filter a single signal, and make different states in a visual way imo. The purple inserters have items in their filter so the show on the alt mode what the combinator below it is set to. All they do is pick the fish from the box when the specific order is done.

Blueprint:
BPfishbitstatemachine.txt
(6.73 KiB) Downloaded 164 times
100k items unlocked purple.png
100k items unlocked purple.png (329.95 KiB) Viewed 11829 times
The nano system is fed by multiple smelter and refineries to keep up production. You do not want to have your single assembler stalling for even a split second during crafting cycles. *the fishbit belt gives some "latency" when the fish is cycled to select next task*.

rail assembler.png
rail assembler.png (341.72 KiB) Viewed 11829 times
I find the "vanilla" crafting combinator single assembler a really inspiring challenge. Because your factory does not need to grow as much as a regular run, there is way more time to optimize and be creative. The game is more of a idle game. (note i am handcrafting in each pic). This last pic is where i mothballed the project. I wasn't able to get the situation to function as intended. By having a wagon for each item mix, i hoped to reach ultimate item troughput for a single assembler. End game situation will probably be a bot based system, since it is the only way to hit 12 beacons and still have enough inserters to keep up. Another option would be a car belt based system like Allaizn.

Re: Nano factory with push down automata

Posted: Fri Oct 22, 2021 1:38 am
by mrvn
gridstop wrote:
Mon Mar 20, 2017 10:33 pm
Ratzap wrote:Very nice. The first question that springs to mind is this: how easy would it be (or is it even possible) to fetch open logistics requests from the player which cannot be satisfied from storage and then build them for delivery.

Eg: request 3 pumpjacks, 1 in storage then the nano factory builds the last two and places them in storage.
Thanks!

I was trying to figure out a way to see if you could get a 'unsatisfied requests' count from the network. I know when bots are in flight sometimes you can see negative numbers in the logistics network's contents, but I'm not sure what that represents precisely, and it doesn't show you simply 'amount of requests'. For instance a network with a requester box asking for 50 copper, but no actual copper in the network just shows no signal from the roboport.
A negative number happens when a bot is on the way to pick up an item and you remove it from the chest. The signal shown is number available in the network - number the bots are on the way to pick up. There is no count for things the bots would like to pick up.

To see unsatisfied requests you have to put an item in a chest so a bot comes to pick it up. So you have to produce one of everything ahead of time.

Re: Nano factory with push down automata

Posted: Fri Oct 22, 2021 4:10 am
by Khagan
mrvn wrote:
Fri Oct 22, 2021 1:38 am
There is no count for things the bots would like to pick up.

To see unsatisfied requests you have to put an item in a chest so a bot comes to pick it up. So you have to produce one of everything ahead of time.
Which is a great pity for low-volume high-cost items like rocket silos or spidertrons. Not only do you have to produce at least one that you don't (yet) need, but you have to work quite hard to stop the assembler loading the raw materials for another couple of them.

Re: Nano factory with push down automata

Posted: Fri Oct 22, 2021 10:44 am
by mrvn
Khagan wrote:
Fri Oct 22, 2021 4:10 am
mrvn wrote:
Fri Oct 22, 2021 1:38 am
There is no count for things the bots would like to pick up.

To see unsatisfied requests you have to put an item in a chest so a bot comes to pick it up. So you have to produce one of everything ahead of time.
Which is a great pity for low-volume high-cost items like rocket silos or spidertrons. Not only do you have to produce at least one that you don't (yet) need, but you have to work quite hard to stop the assembler loading the raw materials for another couple of them.
I don't feel that is really something to worry about. Because you either

a) only need one rocket silo so just fill the assembler manually once.

or

b) you are planning to build many and one extra becomes a fraction of material spend on rocket silos.

The spidertron kind of falls in the middle in a (public) multiplayer game if you don't use it as defense bot. Each player probably wants one. So you might need a bunch and in a public game you need another when a new player joins.

One thing you can do is use trains as signal/switch. Make a pair of stations with a train. It idles at one stop (some impossible condition) and waits for a circuit condition "spidertron > 0" at the other and that station having a train starts the spidertron assembly. So a player can click on the train on the map and send it to the other station and a spidertron is made.

And yes, ordering and counting the ingredients for one spidertron takes a bit of work. Worth it? Your choice.