[1.1.42] Wrong Raw Ingredients for non-heavy-oil products in chemical plant

Bugs that are actually features.
rlm
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Oct 01, 2021 7:52 pm
Contact:

[1.1.42] Wrong Raw Ingredients for non-heavy-oil products in chemical plant

Post by rlm »

Factorio Version: Factorio 1.1.42 (build 59009, win64, steam)

Steps to reproduce: hover over batteries, sulfuric acid, sulfur, plastic, light oil cracking, petroleum gas or light oil -> solid fuel, or explosives in a chemical plant.

I have included the save "chemical-plant-problems.zip" that has one chemical plant with each recipe available for testing.
chemical-plant-problems.zip
(1.09 MiB) Downloaded 129 times
I see previous posts have mentioned this problem: see viewtopic.php?f=23&t=87716&p=505449&hil ... il#p505449 and viewtopic.php?f=23&t=87716&p=505447&hil ... il#p505447, and were closed as "not vanilla behavior", but I can confirm that this is happening in vanilla.

It looks to me like the common problem in these cases is that the game is not treating petroleum gas or light oil as a "terminal" raw ingredient and is instead trying to calculate the raw resources based on cracking these liquids from heavy oil.

I think that it would be better to calculate raw ingredients considering light oil and petroleum gas as "terminal" raw ingredients that are not further expended, because this is how these products are made in most cases. As it is these raw ingredient calculations are not really useful for planning appropriate ratios.
pics
Attachments
factorio-current.log
(6.49 KiB) Downloaded 132 times
Loewchen
Global Moderator
Global Moderator
Posts: 9307
Joined: Wed Jan 07, 2015 5:53 pm
Contact:

Re: [1.1.42] Wrong Raw Ingredients for non-heavy-oil products in chemical plant

Post by Loewchen »

For total raw the lowest recipe that this specific machine is able to perform is relevant. Chemical plants can produce sulfur so sulfur is not the lowest ingredient and since they can perform cracking as well, petroleum gas is non either so it goes down from light to heavy oil.
Why I thought the other report was not vanilla behavior I don't know, maybe I looked at the recipe in hand crafting, which uses a different approach to calculating total raw :roll:
UkcsAlias
Inserter
Inserter
Posts: 22
Joined: Mon Oct 04, 2021 11:07 am
Contact:

Re: [1.1.42] Wrong Raw Ingredients for non-heavy-oil products in chemical plant

Post by UkcsAlias »

Heavy oil, light oil and petrolium gas have several extra issues regarding calculating raw values, because there are multiple ways to produce it. Most resources that are shown have only 1 way to produce those, so values are static in calculation. But with oil resources it varies a lot whether you used advanced oil processing or coal liquefaction.

For assemblers, we do see a produced part as a raw ingredient (iron plate). But lets say that the oil resources are handled as a simlar product. In this case all 3 are normaly a raw resource. This to me gives me more reason to avoid the cracking recipes from influencing the raw resources, as they essentialy are using a raw resource to produce another raw resource.

There at the same time are reasons to use the heavy oil as potential ingredient though, because coal liquefaction does convert that oil. But even here, its not a 100% true value either as there are still lower products being added which cannot be excluded from being produced at all.

Although it might not be a bug, i think this would definitely be a major QoL improvement if its altered.
rlm
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Oct 01, 2021 7:52 pm
Contact:

Re: [1.1.42] Wrong Raw Ingredients for non-heavy-oil products in chemical plant

Post by rlm »

I guess the rule is that a recipe machine recursively follows dependencies only for what it can make and then treats whatever is left at the end of the recursion (if it terminates!) as "raw" ingredients. So raw ingredients are relative to a specific machine. This is why assemblers treat iron plates as "raw" ingredients, because they are made in smelters and not assemblers. It's also why the engines are treated as "raw" ingredients when hand-crafting, because engines can not be made by hand. So, I agree that this is technically not a bug per se according to the spec. However, I still think that for chemical plants the liquid inputs should be special-cased as "raw" ingredients, because:
  1. petroleum gas and friends are generally used as raw inputs
  2. assuming I properly understand the algorithm to determine raw ingredients, in general there may not actually be either a unique set of raw ingredients or even a proper termination to the recursion at all! Consider what would happen if the chemical plant could, say, crack lubricant into light oil (with some losses compared to cracking heavy oil directly). Then there is no longer any well defined amount of heavy oil that serves as a "raw" basis for recipes involving petroleum gas, since each unit of petroleum can come from one of two different routes with different amounts of costs in terms of heavy oil. Or, consider what would happen if the chemical plant could produce heavy oil from solid fuel. In that case the algorithm to determine raw ingredients will never even finish recursing because it's always possible to create endless cycles of heavy oil -> solid fuel -> heavy oil.
  3. You can think of assembling in factorio as a directed, acyclic graph (a "recipe graph") where paths along the graph represent increasing "refinement" or "complexity". (For example iron -> engines -> electric engines -> flying robot frame). As long as the graphs are acyclic AND traversing the graph represents actually building something and increasing "complexity" or "specialization" or whatever, then the algorithm to find raw ingredients by traversing the graph backwards makes sense and will agree with our intuitions. The reason "cracking" recipes are giving us trouble because they are some of the few recipes in factorio that DON'T really represent "refinement" or "building", so simply traversing those connections in the graph to find simpler ingredients is inappropriate in this case. Cracking heavy oil into light oil doesn't really mean that the heavy oil has been transformed into a more specialized or complex ingredient. In this sense, the "recipe" to crack oils is not actually a proper recipe in the sense that it doesn't belong in a graph showing increasing refinement/complexity. It's more of a transformation. You would run into similar problems if there was some way to turn iron ore into copper ore or something. So, I think there's a very reasonable justification to keep the current algorithm but only run it on a true "refinement graph" (which would exclude cracking and possibly also kovarex enrichment) and not the complete "recipe graph" that it's currently using.
mrvn
Smart Inserter
Smart Inserter
Posts: 5925
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: [1.1.42] Wrong Raw Ingredients for non-heavy-oil products in chemical plant

Post by mrvn »

Should be easy to change the cracking recipes with
allow_decomposition

Type: bool
Default: true
Optional. Whether this recipe is allowed to be broken down for the recipe tooltip "Total raw" calculations.
You can try that with a few lines of mod.

There are a lot of case in mods that have cyclic recipes and I think the algorithm simply has a hard limit on the recursion depth. If it doesn't find a raw material after N steps it aborts that path. Better for the mod to turn of decomposition though to made it go down the path most useful.

It's also fun to think what would happen in the SeaBlock mod if the algorithm would consider recipes for other buildings too. There are only two raw resource: Water and Air. So how much water and air does a rocket silo take?

SeaBlock also has loots of loops, several of them producing more than the input. So (made up example) you have to put in 2 water and 3 air and you get a rocket silo, 500 water and 23 air and a ton of other crap. So is the cost of a rocket silo -498 water and -20 air?
Loewchen
Global Moderator
Global Moderator
Posts: 9307
Joined: Wed Jan 07, 2015 5:53 pm
Contact:

Re: [1.1.42] Wrong Raw Ingredients for non-heavy-oil products in chemical plant

Post by Loewchen »

I get it now, I tested it in cheat mode so there were odd recipes for handcrafting available and therefore showing total raw when it doesn't make sense. NaB.
rlm
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Oct 01, 2021 7:52 pm
Contact:

Re: [1.1.42] Wrong Raw Ingredients for non-heavy-oil products in chemical plant

Post by rlm »

Loewchen, can you clarify what you mean here? Are you saying that the best and most intuitive raw ingredient decomposition for explosives should be 1 coal, 30 heavy oil, and 70 water as it is currently?
Post Reply

Return to “Not a bug”