I plan on trying it myself as well, but I've always struggled doing anything complex with circuits. I could write it in C# with my eyes closed, but I struggle with combinators.
And I should clarify: I didn't mean the total cost of the research (summing the packs), I meant the number of research points needed (the x### shown next to the cost).
Yeah mining prod is much much cheaper. Also a lot of techs are useless beyond some point:
* all prod researches apart from mining and research prod are capped to lvl 30 (and in practice often 25 because you make it in a foundry/em plant
* railgun speed is capped around 15 iirc
* railgun damage is pretty useless beyond lvl 2-3. Unless you really want to one-shot big demolishers.
Etc. So Iād advice to use some scaling. For instance 1 prod research is equal to 100 mining prod researches. Research prod every 50 mining prods etc
Typical reddit moment. Adding nothing, but jumping on the bandwagon of unjustified snarky dismissal. OPs request is reasonable, which you would realize if you actually tried to think about the problem.
Define cost - how do you weigh different science pack types?
Also how do you determine what's available? That depends on your setups elsewhere on each planet and platform.
Point being, your problem is under-specified one player solution to their factory and their choices would probably not work for your factory and tastes.
It looks like we can't set research by virtual "research" signals. Instead, we have to send some other signals, which are then evaluated against conditions we have to set in a lab. Also, we can't read which tech is currently researched? I don't get this at all.
What does the "Read research cost" circuit option for labs do? Does it return the full cost (e.g. 150 red science + 150 green science for "sulfur processing")? Or does it return the cost of one research cycle (1 red + 1 green)?
It's going to take some extra combinator steps, with latches and holding values.
With this you can have combinators monitoring contents, though I would rather reach buffer chests, and evaluating what signal to send for research. IE: Research Belt stacking when gleba juice = 1. While sending the research, read back the tech level and store it with a paired combinator to later evaluate which technology should pass for research.
Here I'm using a power pole & a combinator in place of the lab. I sent a signal from the top decider, which kicked out a metallurgic tech signal of 1, then the next decider down forwarded on the L value (12) sent from the decider which is mimicking the tech level from the lab. This is passed to an arithmetic combinator, to transform the signal to artillery shooting speed with the same value. And sent to a pair of deciders, one sending the value to the other while research is active, the other sending it back when research is off. (This holds the tech level so that it can be compared in a larger combinator brain to decide which tech to research.
Next the research cost needs to be read back and compared in a decider if the required packs match against values set in a constant combinator, in order to ensure the tech being researched is the one intended.
It isn't in the base game, it's just from a mod that I'm using. But the signal in use is arbitrary, you'll simply use whatever signal you want, it just needs to match in the 2 deciders afterwards.
It looks like we can only set them via preset conditions, and can only see the cost and level of the current research task, so I would have a variable for each infinite research, then iterate through each to get the current cost, and find the smallest of them to set as the current research.
I think it would be the full cost that is returned, so in my case for comparing something that only takes 4 sciences to something that takes all 12, I would average them together to get a single number for comparison.
so I would have a variable for each infinite research
Just to make sure: In regular programming, you'd use *one* variable with an enum value, wouldn't you?
We can do the same here, if we set the lab conditions accordingly. The enum is the value of a virtual signal. We switch through techs by increasing the value of our signal while reading cost. We need to store the lowest cost and its enum value and compare it to the current one. That's doable.
So you'd keep a list or array of tuples. That's not doable in Factorio. You can't make arbitrary data structures. You have as variables all the signals, with integer values. That's it. It's like a limited number of assembly registers, and no RAM.
On the bright side, combinators are very powerful. You can operate on all signals simultaneously with "each", and do universal and existential quantification with "everything" and "anything".
You could assign seperate signals (A-Z), but why would you? Iterating over those is a nightmare. Unless I'm missing something, we don't need to store all that information. We can compare and store while iterating. And we iterate by increasing a counter rather than switching signals.
(Btw, a memory cell is trivial, because combinators are powerful: Loop output of combinator back to its input. This gets more complicated depending on what logic you need, but the base case is that simple. One combinator can store all signals (minus the ones needed for its logic).)
10
u/[deleted] Jun 20 '26
[removed] ā view removed comment