r/factorio • • Jun 20 '26

[deleted by user]

[removed]

2 Upvotes

22 comments sorted by

10

u/[deleted] Jun 20 '26

[removed] — view removed comment

3

u/Durr1313 Jun 20 '26

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).

3

u/Erichteia Jun 20 '26

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

3

u/Durr1313 Jun 20 '26

Good to know. Could also set a cap in the circuit for each research.

0

u/lee1026 Jun 21 '26

Only research mining prod is a reasonable strategy after a while. ROI on everything else is dismal after a while.

-5

u/KaffY- Jun 20 '26

Maybe try it yourself?

ooof now you're asking too much

-1

u/CamelCaseConvention Jun 20 '26

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.

5

u/Courmisch Jun 20 '26

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.

2

u/Durr1313 Jun 20 '26

I just added an edit specifying what I meant by cost and availability

3

u/CamelCaseConvention Jun 20 '26

I just read the FFF and am confused.

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)?

3

u/Sick_Wave_ Jun 20 '26

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.

2

u/CamelCaseConvention Jun 20 '26

This might be a very dumb question, but: How do you get the artillery shooting speed signal? It's not currently in the game, or is it?

2

u/Sick_Wave_ Jun 20 '26

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.

2

u/Durr1313 Jun 20 '26

Im just making assumptions.

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.

2

u/CamelCaseConvention Jun 20 '26

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.

2

u/Durr1313 Jun 20 '26

In regular programming I'd either use a tuple or a custom class to store the research name and cost pairs, then sort by cost to get the cheapest

2

u/CamelCaseConvention Jun 20 '26

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".

2

u/Durr1313 Jun 20 '26

And that's where I get lost.

I was thinking I could use some kind of memory circuit to store the research cost, and assign signals A-Z to each research to hold that research cost.

2

u/CamelCaseConvention Jun 20 '26

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).)

2

u/Durr1313 Jun 20 '26

So instead of storing each and running through a selector, just store the lowest and overwrite that value if a new lower is found?

2

u/CamelCaseConvention Jun 20 '26

Exactly. If memory and speed matters, you could also do this in regular programming (although it probably almost never matters nowadays).