Two circuit operations: STACKIFY and reverse

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Post Reply
Claudius1729
Long Handed Inserter
Long Handed Inserter
Posts: 54
Joined: Mon Apr 03, 2017 5:47 pm
Contact:

Two circuit operations: STACKIFY and reverse

Post by Claudius1729 »

Summary: currently in the game it's easy to know *QUANTITY* of items, but we lack an easy way to compute *SPACE* of items (the number of stacks of blue belts in your logical system for instance). SPACE is usually important in a factory, but it's even more important in a train-centered Factorio.

Given the developers intention to make trains really attractive, I believe a way to compute space through combinators would be useful and desirable. The general powerful application would be to know how much space you need, or how much space you're already using, whether it's in chests, or trains. I can already see it making mixing trains and logistic way easier than it is right now.


This is why I propose two new circuit operations:

STACKIFY (WEIGHT): Count the stacks of a signal of items.
For instance, if the input is 134 yellow belt and 7 boiler, and STACKIFY is applied to EACH, it would return 2 yellow belt and 1 boiler, the number of stacks respectively those items would take up in a chest.

In a way, this is what we could define as the weight of a pile of item from a practical point of view.
DESTACKIFY: Convert stacks in number of items
The reverse of STACKIFY (not quite, but almost).
Input: number of stacks of items. Output: Quantity of items corresponding those to stacks.
For instance, if the input is 4 blue splitter and 1 space science and DESTACKIFY is applied to EACH, it returns 200 blue splitters and 2k space science.

Bonus: STACKIFY in a contraption
I know that my suggestion is possible to make with actual signals, I actually made STACKIFY myself but it takes a lot of space. Especially because you have to split items per stack size, and read stack sizes from combinators, a step that can't be compressed it seems. From it, I could easily made ANTI-WEIGHT/ANTI-STACKIFY.

Here is the contraption for those curious, I'm sure it can be simplified (I'm a circuit beginner) but I'd be surprised it could be simplified to a "portable" extent:

Image

Under I is the input, under O is the output. The W part of the circuit is just a small thing that compares the input weight with a wagon's weight, to see if the input is too big to fit in a wagon.
SuperStack

edit: this contraption looks unwieldy and ugly, but programming STACKIFY would not be a performance issue (would not be surprised if the devs already got the function in the game actually)

JohnyDL
Filter Inserter
Filter Inserter
Posts: 533
Joined: Fri May 16, 2014 3:44 pm
Contact:

Re: Two circuit operations: STACKIFY and reverse

Post by JohnyDL »

principle seems interesting, problem though I'm thinking about is if you're trying to assess your entire logistics network to see if you need more storage and say you have 100 items in stacks of 1 spread out over multiple chests does that return 100 stacks cause I'm trying to count how many stacks I have empty and just one item blocks it, and yet if I wanted to know the number of items I have converting that signal into 100 stacks tells me I have 10,000 items not 100 items.

Proposal: more signals

I really thing the circuit network should have a bunch of extra signals anyway (even user configurable ones) but I'm sure that's been suggested and is coming. so...

More signals each item sends a signal with it's item number and how many stacks that is, math on the signals treats them as independent signals so signal A=100 items in 3 stacks, signal B = 20 items in 1 stack A+B= 120 items in 4 stacks, A-B=80 items in 2 stacks, A*B=2,000 items in 3 stacks, and A/B=5 items in 3 stacks. All the combinator logic treats the pair of signals as a unit and the top one is the one considered for things like comparisons. You're stackify and reverse could then just switch the stack and items values. You'd have to be a lot more careful about using the couplet maths once you've switched stack and item for item and stack but by default you'd never notice it. This also basically doubles the signals available if you use them carefully you can probably manufacture signals with N stacks and 0 items to add to a signal to use the second number, ect, ect. This would allow you to send 2 things through a decider combinator or to some degree use one half of the signal as name and the other as data or a bunch of other things

Claudius1729
Long Handed Inserter
Long Handed Inserter
Posts: 54
Joined: Mon Apr 03, 2017 5:47 pm
Contact:

Re: Two circuit operations: STACKIFY and reverse

Post by Claudius1729 »

JohnyDL wrote:principle seems interesting, problem though I'm thinking about is if you're trying to assess your entire logistics network to see if you need more storage and say you have 100 items in stacks of 1 spread out over multiple chests does that return 100 stacks cause I'm trying to count how many stacks I have empty and just one item blocks it, and yet if I wanted to know the number of items I have converting that signal into 100 stacks tells me I have 10,000 items not 100 items.
Assuming it's an item with a stack size of 100 (like iron plates):

That depends what you query. If you query your logistic network, it's going to say you have 100 stacks. If you query the total of items in the chest, it's going to say you have 1 stack.

But you can already know the total quantity of items you have by querying either one of them, you would not use STACKIFY for quantity, but for space. And indeed, if you have 100 items in stack of 1 spread over, that's taking the space of 100 stacks.

JohnyDL
Filter Inserter
Filter Inserter
Posts: 533
Joined: Fri May 16, 2014 3:44 pm
Contact:

Re: Two circuit operations: STACKIFY and reverse

Post by JohnyDL »

I kind of agree with you. Given the ways I can see your idea being used translating back and fourth in a single operation might be useful You know how many stacks are in train cars but you need to combine that with how many items are in chests at a train station as you say not all stacks are the same size so stackify lets you do the conversion inside the logistics network. But I don't have one train going to every station and combining the new answer with a second train means I might have to deal with a translation and everywhere I translate from Stacks to Items and back again in your system holes appear.

With finding out if I have enough storage I've got to consider not only the circuit network but the logistics one, how would you define stacks in terms of worker robot cargo? you could just take items in the air and divide by items per stack but that's not the number of extra stacks in the air if the storage system has a bunch of partial stacks. So you do the math and assume combinations between partial stacks and items in the air but not all logistics or circuit chests are storage or requesters you can't top up the stack in a provider.

On the other hand my suggestion would work both logistically and circuit wise because it's all handled in the simplest way and the same way. For each slot it reports 1 inventory space and X items and you can do math with either the stack count or the item count or both at the same time. By grouping those two variables together under the same logo item count and stack size never separate from one another and you don't need a bunch of new logos just a simple identifier on whether it's item count or stack size that's the primary for each use and you just flip a switch to show item count as now or stacks within combinators without a new entity. It also has a much wider application for it too, every signal gets 2 values doubling the number of potential signals on the circuit network and you get your functionality.

Claudius1729
Long Handed Inserter
Long Handed Inserter
Posts: 54
Joined: Mon Apr 03, 2017 5:47 pm
Contact:

Re: Two circuit operations: STACKIFY and reverse

Post by Claudius1729 »

The holes that would start to appear as you apply stackify and destackify would be a bit like reminders in integer divisions. I also don't see a use for computing number of items carried by bots through STACKIFY. It's actually a simple operation that's independent from item stack size, it just depends on quantity of items, so not space (as I defined it).

But anyway I feel it's normal to deal with those imperfect reminders and it actually encourages "optimal" thinking in terms of space (or stack).

Your suggestion is also a solution, basically making signals not be of type int but type (int,int) with the second int use for space/weight/stack value and the first one for quantity. The dream would just be more complex data-types as signals yet simple to handle.

I would love it if it was implemented but I have a feeling signals aren't getting to be more complicated than just a simple 32 bits int as data type.

JohnyDL
Filter Inserter
Filter Inserter
Posts: 533
Joined: Fri May 16, 2014 3:44 pm
Contact:

Re: Two circuit operations: STACKIFY and reverse

Post by JohnyDL »

Yeah I like tuples and I can already see nine or ten ways they could be used and combined from more complex light and sound displays (individually addressable pixels rather than say the side scrolling patterns) to directing traffic (because you effectively double the number of concurrent networks or the number of signals allowing for duplex communication), even allowing for some network building (compute Unit A sends data to compute unit B with signal iron ore and the reverse as iron plate, item count is the value and the destination address to override is the stack count, and they're guaranteed to arrive at the same time adding computers C, D, E, F could each have one to one signals to the others on the common network)

Post Reply

Return to “Ideas and Suggestions”