KirkMcDonald / kirkmcdonald.github.io

Simple web-based calculator for the game Factorio.
Apache License 2.0
540 stars 148 forks source link

Factory counts are not meaningful for oil product targets #154

Open ShadesOT opened 5 years ago

ShadesOT commented 5 years ago

Hi Kirk and all other readers!

Today I run accross a calculation case, which seems buggy to me. I am running Factorio v 0.17.48. I have 24 refineries running on advanced oil processing and I want to convert all the outputs to solid fuel. Preferable via light oil and then petroleum gas.

In a first step I used the calculator to find the output of lo an pg of 24 refineries when all the heavy oil is converted to lo. This is the result: https://kirkmcdonald.github.io/calc.html#data=0-17-1&rate=s&cp=3&furnace=stone-furnace&items=light-oil:r:252,petroleum-gas:r:264 24 refineries running on advanced (and including the ho cracking) make 252 lo and 264 pg. Which seems correct and according to the in-game recipe for advanced oil processing.

In a second step I tried to find out how many chem plants I need to convert all lo and pg into solid. There the calculator does not ouput any meaningful result. So I took pen and paper and calculated it myself. These are the in-game recipes: recipe for lo to solid: 1 solid = 10 lo/2s recipe for pg to solid: 1 solid = 20 pg/2s Here are my calculations for the numbers of chem plants:


              252 lo/s             2 x 252
 cp(lo) = --------------------- = ----------- = 50.4
               10 lo/2s                 10

              264 pg/s             2 x 264
 cp(pg) = --------------------- = ----------- = 26.4
               20 pg/2s                 20

But when I put these numbers into the calculator, it just returns bogus results. https://kirkmcdonald.github.io/calc.html#data=0-17-1&rate=s&cp=3&furnace=stone-furnace&items=solid-fuel:f:50.4;1,solid-fuel:f:26.4;2

It seems to stubbornly calculate something different and not to use the numbers of cp I put into the fields.

When inputing the correct numbers for solid into the fields (13.2 for pg and 25.2 for lo) it calculates the correct numbers of chem plants in the factory input field, but again uses some bogus numbers in the calculation spread sheet below.

https://kirkmcdonald.github.io/calc.html#data=0-17-1&rate=s&cp=3&furnace=stone-furnace&items=solid-fuel:r:66/5,solid-fuel:r:126/5

Can you shine some light on this case?

Thanks a lot!

ShadesOT commented 5 years ago

After fiddeling a bit more with the calculator I now see what the problem is. The calculator can not handle the case when the user selects more than one recipe for solid fuel production. In fact the calculator doesn't take the recipe for solid into account at all. It completely disregards it. If I put in the correct number for solid fuel (38.4) the calculation comes up correct, no matter what recipe is selected.

https://kirkmcdonald.github.io/calc.html#data=0-17-1&rate=s&cp=3&furnace=stone-furnace&items=solid-fuel:r:192/5

And one of the problems in my case was, that I tried to use the calculator for a case it was not made for: Having the input numbers and trying to figure out how many factories I need to process that input into something other and how much of that other would be the result.

That solves it for me. Cheers for the great calculator!

KirkMcDonald commented 4 years ago

This feature does something both non-obvious and very simple, and I should probably just remove it until I can re-work it into something closer to what a user might expect.

Say you want to make petroleum gas. You tell the calculator: Make one oil refinery's worth of petroleum gas, using the advanced oil processing recipe. The calculator happily takes your input, and gives a solution with 0.7 refineries:

https://kirkmcdonald.github.io/calc.html#data=0-17-1&items=petroleum-gas:f:1

This may be a surprising result: The user asked for one refinery, and got 0.7 refineries. But what the calculator is doing is actually very simple (too simple, perhaps): One refinery running advanced oil processing will make 660 petroleum gas per minute. So when you ask for one refinery's worth of petroleum gas, it solves for 660 petroleum gas per minute.

This works out to less than 1 refinery in the solution, because the other oil products in the advanced oil processing recipe get cracked and transformed into more petroleum gas.

Doing this so that the result does work out to one refinery is fairly hard. That difficulty is compounded as soon as you have multiple build targets: If you ask for 1 refinery's worth of petroleum gas, and also some quantity of solid fuel, what should the result be? There isn't a single answer to that question.