Page 1 of 1

Combinator Build Code Factory

Posted: Sun Aug 09, 2015 4:23 am
by -root
Video Here

Malkasphia released a factory design approximately a year ago. It was a factory based upon logic gates. I remember commenting at the time saying that it would be cool if you could just give a factory some orders and it would make whatever you requested with no further input. Alas, the tools did not exist at the time to actually implement something like that.

However, with combinators, the game has now changed. This factory is a proof to concept showing the power of the Combinator. This factory shows that it is possible to give a factory a specific set of instructions and for it to produce exactly what we asked for with zero waste. The logic is completely dynamic, so does not rely on a set order. You can give it whatever order you want. As this is just a proof of concept, we've only implemented two items. The theory however is sound and using a repeatable logic build of an RS latch plus a couple of other combinators, you can implement as many items as you care to.

Credit to /u/gopheratl from /r/factorio for the huge amount of help he gave me on this. I wouldn't have been able to get it done without him. He wrote an excellent tutorial a couple of days ago. He understands logic gates at a level I can't even fathom. The broad idea of the factory is mine, inspired by Malkasphia but Gopher really did the majority of the grunt work in actually getting it to do what it should.

I look forward to what comes next :)

Re: Combinator Build Code Factory

Posted: Sun Aug 09, 2015 4:47 am
by GopherAtl
Much room for growing from this basis. We need to play with ways to effectively ramp up supplies on raw materials - it would become a major bottleneck very quickly. Same idea could hopefully be applied to intermediates as well, which will also become a bottleneck later.

Had a thought that I'm gonna play with a bit tomorrow that, if it pans out, will let us eliminate the need to fill our supply chest completely before we start consuming from it at each factory as well as at the supply points, too. That alone would be a huge boon to the system's performance, especially as the number of steps of intermediates required grows, but also for the raw material end.

Re: Combinator Build Code Factory

Posted: Sun Aug 09, 2015 6:39 am
by ray4ever
It's a realy nice concept! But you don't need to put aside the number of iron or copper first before you put them on the belt (it just inserts a time delay). Instead you can count the number of items you put on the belt directly.

Re: Combinator Build Code Factory

Posted: Sun Aug 09, 2015 9:18 am
by -root
GopherAtl wrote:Much room for growing from this basis. We need to play with ways to effectively ramp up supplies on raw materials - it would become a major bottleneck very quickly. Same idea could hopefully be applied to intermediates as well, which will also become a bottleneck later.

Had a thought that I'm gonna play with a bit tomorrow that, if it pans out, will let us eliminate the need to fill our supply chest completely before we start consuming from it at each factory as well as at the supply points, too. That alone would be a huge boon to the system's performance, especially as the number of steps of intermediates required grows, but also for the raw material end.
Oh definitely. I think adding additional products so you can order different things would be the first step. Making a few of the operations parallel and dropping some of the steps would improve things hugely. This, being a proof of concept it is definitely a bit clunky. For example, ray4ever's item counter could be applied to the input on the assemblers. They then could just pull direct from the line.
ray4ever wrote:It's a realy nice concept! But you don't need to put aside the number of iron or copper first before you put them on the belt (it just inserts a time delay). Instead you can count the number of items you put on the belt directly.
That is a very, very nice feature.

Re: Combinator Build Code Factory

Posted: Sun Aug 09, 2015 1:29 pm
by GopherAtl
something to count as it goes was what I had in mind, not tried your set up ray4ever but hade one of my own a while back that was similar, took a bit of fiddling to get one that passed a prolonged test of letting it run for 5-10 minutes and verifying the count was exact. This was my design for a counting remover

Image

the top decider is not part of the circuit, it is just comparing chest count to the counter and turning the lamp on if it is exactly correct.

The deciders, from left to right, are "if copper plates > 0 then A=1" (#1), "if A>0 then A=1"(#2) and "A>0 then A"(#3)
the arithmetic (#4) is "A * -1 => A"
the important wires are:
red connects middle smart chest, both inserters, and input to #1
red connects output #1 to input #4
green connects outputs of #1 and #4 to input of #2
red connects output of #2 to input #3
green connects output of #3 back to input of #3

doesn't have a reset circuit at present, so it would just keep counting up indefinitely, but not hard to add one by pulsing #4's output * -1 back in to #4 as input for one cycle.

Also put together this playing with ideas to address the other problem, scalability...
Image
Takes an input signal of copper plates, divides it by 4, then multiplies back and subtracts to generate the remainder of dividing the input by 4. The divided result goes to 4 of the inserters, and the remainder goes to the 5th. So, it generates counts for 5 inserters so that they add up, exactly, to the desired amount. 4 was just a test number, could be scaled up to any number of inserters workin in parallel. If you combined this with counter circuits like above for each inserter you could continuously feed at a fairly high rate while maintaining perfect final count.

also got an idea for dealing with leftovers, adding a set of logic that would basically remember what leftovers are on the belt at the end (ex, if you asked for 5 transport belts, it would have to make 6, leaving 1 on the loop just hanging out) and then subtracting those from production next time, so if you ask for 5 more, with the 1 still on the belt from last time, it will only craft 4, and deliver those plus the leftover.

Re: Combinator Build Code Factory

Posted: Sun Aug 09, 2015 5:09 pm
by bobucles
I don't think you can count things flying around a belt. But you can count things stored in chests no problem, and maybe work things that way.

Re: Combinator Build Code Factory

Posted: Mon Aug 10, 2015 5:03 am
by GopherAtl
bobucles wrote:I don't think you can count things flying around a belt. But you can count things stored in chests no problem, and maybe work things that way.
Yeah, the intention was just to know how many were left on the belt by doing some math, we know how many were needed and how many were made, if they're not equal, the difference is what's left on the belt. so we just store that, then subtract it from the need-to-make for the next cycle. unless I'm forgetting some recipes other than alien science that output more than 2 per craft, there should never be more than 1 of anything, and only of the things that craft 2 at a time - so potentially a transport belt, a copper wire, any of the paired, underground things (pipes+belts), probably a few other things I'm forgetting?

Re: Combinator Build Code Factory

Posted: Fri Aug 14, 2015 8:17 am
by vampiricdust
Wow, your solution was more elegant than mine. The only thing I could come up was calibrating the item detection to the speed of the inserter. using a -1 multiplication that comes back on a tick delay is so much better. I keep forgetting about the tick delays. Really starting to wish I paid more attention to my Uncle.

Re: Combinator Build Code Factory

Posted: Wed Apr 20, 2016 2:48 pm
by perkas9900
hey can you help me understand it. i can't get the iron and copper input to work. i have tried for 1 hour now. please. ps. sorry for my bad english. :D

Re: Combinator Build Code Factory

Posted: Tue Apr 26, 2016 9:24 pm
by DragonHeart996
i have managed to make my own modular smart factory, inspired by -root's video, and decided to make a forum account to show it. however, i can't get blueprint string to work (keeps giving errors), so i will be uploading my whole save! it is a very W.I.P. mega-factory (inspired by and striving to eventually equal -root's break the game factory). to get to the smart factory, go to the #PAX Smart Factory train station. there are two versions, the first on the left has a huge throughput issue, and the one on the right is my (semi) final version, with compensation for excess, progress bars, and infinitely expandable counting chests!
p.s. i still have to figure out the math to use more than one assembler for items requiring more than exactly one item as input.

as reference, there are 2 distinct modules, input (for raw resource collection and assembler feeding), and output (for outputting completed products and calculating amount of excess. feel free to poke around at my blueprints that are stored in the farl train at the #PAX Starter Engineering station. there should be blueprints for the modules (or at least semi-recent versions of them) there.

for a decent demonstration of performance, go to the constant combinator near the plate input and order... i don't know... say 751 red belts and 501 green circuits.