Factorio

Factorio

View Stats:
Bellatrix Dec 29, 2024 @ 4:38am
Is there a single-combinator memory cell for symbols?
Basically, what I need is for a combinator to hold onto a recipe, but for that recipe to change if the memory cell receives any kind of input.
Presumably something where the cell loops onto itself with a green wire and takes external input from a red wire, outputting the red wire's contents if they exist and otherwise outputting the green wire's contents.

Since the external input will last more than 1 tick, it's fine if the solution is to wipe the cell if the input is different from the stored memory.
< >
Showing 1-9 of 9 comments
Fel Dec 29, 2024 @ 4:54am 
The simplest "memory cell" is an arythmetic combinator doing "each + 0 output each" or a decider combinator doing "each != 0 output each", with a wire connecting the output to the input.

Keep in mind that sending a constant signal to such setup will multiply the value stored, it only works properly with pulses.
They also do not have a proper "reset" mechanism, but that can be achieved by using the decider combinator variant and adding a separate condition.
For example:
Each != 0 AND Deny (the red cross) = 0
That way, you just need to send the "deny" signal (positive or negative) when you want it to reset.

Since your goal is to hold a recipe, you don't really care about the amount on that signal, so you can make it output 1 instead of source and you won't need to worry about incrementing even with a non-pulse input.
Bellatrix Dec 29, 2024 @ 1:42pm 
This setup doesn't allow for sending a deny signal, it has to work through only recipe signals.
So, sending a new recipe has to automatically replace the old recipe.

There is one janky 1-combinator solution I can think of (selector combinator randomly outputs one of two inputs to itself, should almost instantly settle on the new input) but I dunno how good for TPS that'd be if I end up having hundreds of them.
Chindraba Dec 29, 2024 @ 1:59pm 
I'm not offering a solution, because I can't picture one which will fit the needs.

The biggest problem is I can't picture the need. Perhaps, since nothing has been of use yet, you can take the "problem" up a level and describe what it's supposed to do, not how it's supposed to do it.
  • What's the output recipe signal used for?
  • Where's the origninal recipe signal come from?
  • Where does the other signal come from?
  • Why does it need to change?
  • What does it change to?
  • Is the new signal now the 'held' signal, or just wipes out the old one?
  • And why does the signal have to "latch" in the first place?
That information might help others figure out how to help you.
Bellatrix Dec 29, 2024 @ 2:37pm 
The idea here is an adaptive assembly system where a control system outputs a random recipe from a "shopping list" every tick, and assemblers will latch onto a recipe if the ingredients are available. Otherwise, the ingredients will become part of the shopping list.

The idea is that on a planet like Gleba, where almost everything can be crafted from only a few inputs but you don't wanna leave intermediate ingredients hanging around, I can put in a request for an item and have a whole block of biochambers optimize themselves to produce it with minimal time and wastage.

Honestly, it's not the control system for all this that's the problem, it's getting the assembler to actually stick to one of these one-tick recipes. I want to limit myself to 3 combinators per assembler for it, and I'm already using two to make it only pass through recipes to the memory cell under certain conditions.

Decider #1 checks if all conditions are met and outputs a checkmark if the recipe *shouldn't* be changed, looking at assembler state and comparing required ingredients with available ingredients.
Decider #2 looks for a checkmark and if none exists it outputs one of the rapid-broadcast recipes it's receiving to the memory cell. Since it can only output the recipe as an "anything" the checkmark is on a separate wire.
So #3 needs to a memory cell that swaps to any new recipe it receives.

I did make a crude memory cell of that type, but it was too janky for my tastes, since it'd differentiate between stored and new input by outputting with a value of 2 (duplicated output) and expecting new input to have a value of 1. That way I could tell if the stored and new input held different symbols.
Fel Dec 29, 2024 @ 2:46pm 
Wanting to do it in a single combinator makes things much harder than it needs to be in the first place.

Depending on what you need from your machine (in terms of signals), you could opt to check "read recipe finished" and set it to the signal you want to use as the reset (the "deny" in my previous example).
It isn't perfect since it would mean changing the recipe after every crafting cycle, unless you make an even more complex system as your control that sends the recipe and the amount of times to craft it, but you then get the issue where you need to turn it into a pulse signal for the memory cell to not quickly add it up many times.

There is probably a way to do what you want, but at the very least I am not taking potentially hours of my time to figure it out for you, sorry.
Chindraba Dec 29, 2024 @ 3:50pm 
There's a weird 'trick' with the decider combinator, which I cannot completely describe in the abstract, which uses the signals on both wires to make the list of signals to check when using "Each" such that a signal on one wire and not on the other can be detected and sent out.
I can attempt to describe it better, if that is a feature which might be helpful. Otherwise it's not worth the wall of text it's likely to create.
Bellatrix Dec 29, 2024 @ 5:04pm 
Originally posted by Chindraba:
There's a weird 'trick' with the decider combinator, which I cannot completely describe in the abstract, which uses the signals on both wires to make the list of signals to check when using "Each" such that a signal on one wire and not on the other can be detected and sent out.
I can attempt to describe it better, if that is a feature which might be helpful. Otherwise it's not worth the wall of text it's likely to create.
A XOR gate essentially?
It'd be useful if it works on two different symbols, since then it'd wipe both on one tick and accept the new symbol on the next tick. But it needs to still pass through the signal if it's receiving the same symbol through both wires, otherwise it'll oscillate every tick.
Bellatrix Dec 29, 2024 @ 9:41pm 
I did it! Finally, an elegant solution to the one-combinator symbol memory cell!

First, make a decider combinator that loops back on itself and also takes external input both using wires of the *same* colour, it won't work if the input colours are different.
Then:

Input:
EVERYTHING != 1
OR
EVERYTHING = 1

Output:
ANYTHING, 1
ANYTHING, 1

With this you can input a symbol of any value except 0, and it will remember that symbol over the previous one, though always with a value of 2.
malogoss Dec 29, 2024 @ 10:36pm 
I don't see why it would not work with different color wires. I tested it in game and it looks like it works just fine.

If for some reason the "new" input has a value of -2, it goes brrrrr, different color or not. That should never be a problem in practice though.

Nice.
< >
Showing 1-9 of 9 comments
Per page: 1530 50

Date Posted: Dec 29, 2024 @ 4:38am
Posts: 9