Nano factory with push down automata

This board is to show, discuss and archive useful combinator- and logic-creations.
Smart triggering, counters and sensors, useful circuitry, switching as an art :), computers.
Please provide if possible always a blueprint of your creation.

Nano factory with push down automata

Postby gridstop » Sun Mar 19, 2017 2:40 pm

So ever since I saw Case's original nano factory https://forums.factorio.com/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 https://forums.factorio.com/viewtopic.php?f=93&t=34405 is used to switch recipes and compute intermediate products.

The state machine
state.png
state.png (706.47 KiB) Viewed 5757 times

The state of the PDA is in these two registers. The temp register isn't technically required (you could use the top of stack) but it simplified some things. There are more compact register constructions, but this one transitions glitch-free from any signal to any signal on a rising edge, which ended up making a lot of the other logic much simpler. It made the state machine rules really easy to understand and construct.


The stack
stack.png
stack.png (1.28 MiB) Viewed 5757 times

This is the stack, a chain of similar registers that move signals up & down with push and pop commands. Here you can see (starting at the bottom of the stack) I've requested it to build 20 stack filter inserters, which are made of 100 green circuits and 20 stack inserters, then to build those 20 stack inserters it needs 300 gears, 300 green circuits, 20 red circuits, 20 blue inserters, and so on. I used filter inserters to show what signal is in a memory cell since that's the only way I could find to display an arbitrary signal to the player. At the top you can see the temp register is holding gears at the moment, so that's whats currently being built.


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
idle.png
idle.png (765.01 KiB) Viewed 5757 times

These are the rules for transitioning out of idle. The upper one is for when the stack is not empty, we transition to the start of parsing (P0). The lower one is for when the stack is empty and there is a request present, we transition to parsing and push the request onto the stack. On the left the red & green wires are for the temp register and the state, the right red & green is for the top of stack input & output, and then the rightmost red wire is for stack operations push and pop.


The assembler
assembler.png
assembler.png (1.38 MiB) Viewed 5757 times

This is probably the most boring part of the factory. Just a regular old assembler with a crafting combinator. I still occasionally get jams on the input inserters, still working on the right way to guarantee it. You can see the pipe meter right at the fluid entry point, that's used by the part below to verify when the pipe is empty.


Fluid handling
fluid_management.png
fluid_management.png (1.16 MiB) Viewed 5757 times

I use barreling (up to you whether you consider more assembly machines 'cheating'). I was not able to get regular pumps to ever completely drain a pipe, so they would always jam on fluid changes. Using an assembler for whatever reason is able to completely empty the pipe, so it's possible to change between water,acid, and lube. You can see here it's allowed to stay full of the previous fluid, and only enters the flush state before building if there is a mismatch. You can also see the recipe combinator to the far right from the crafting combinator mod, it determines the sub-components.


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.
gridstop
Inserter
Inserter
 
Posts: 31
Joined: Sun Jul 17, 2016 1:46 am

Re: Nano factory with push down automata

Postby Ratzap » Mon Mar 20, 2017 5:24 pm

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.
Ratzap
Filter Inserter
Filter Inserter
 
Posts: 359
Joined: Sun Aug 16, 2015 11:15 pm

Re: Nano factory with push down automata

Postby gridstop » 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.
gridstop
Inserter
Inserter
 
Posts: 31
Joined: Sun Jul 17, 2016 1:46 am

Re: Nano factory with push down automata

Postby Case » Tue Mar 21, 2017 9:09 am

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
Case
Long Handed Inserter
Long Handed Inserter
 
Posts: 57
Joined: Tue Jun 28, 2016 9:25 am

Re: Nano factory with push down automata

Postby gridstop » Tue Mar 21, 2017 9:51 pm

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.
gridstop
Inserter
Inserter
 
Posts: 31
Joined: Sun Jul 17, 2016 1:46 am

Re: Nano factory with push down automata

Postby gridstop » Thu May 11, 2017 10:49 pm

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 4541 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 4541 times
gridstop
Inserter
Inserter
 
Posts: 31
Joined: Sun Jul 17, 2016 1:46 am

Re: Nano factory with push down automata

Postby kann_ » Mon Jul 31, 2017 11:43 am

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. -.-
kann_
Inserter
Inserter
 
Posts: 44
Joined: Fri Apr 15, 2016 4:36 pm

Re: Nano factory with push down automata

Postby kleopi » Tue Nov 21, 2017 4:31 pm

Is there a save somewhere, or a blueprint? I'd like to learn some stuff (splitting signals, the stack system, etc).
Awesome work!
Creator of the [TKN] Mods.
Check out our Discord for further information:
http://discord.gg/G9QwJWA
kleopi
Burner Inserter
Burner Inserter
 
Posts: 5
Joined: Sun Apr 23, 2017 9:01 pm
Location: Germany :D


Return to Combinator Creations

Who is online

Users browsing this forum: No registered users and 3 guests