scottmsul / FactorioQualityOptimizer

Optimizes prod/quality module ratios for creating high-quality products in Factorio
MIT License
12 stars 4 forks source link

verification #1

Closed Sopel97 closed 2 weeks ago

Sopel97 commented 2 weeks ago

I was confused by the output always giving 0 quality modules for q4, because it should only be the case for q5 (i.e. crafting the legendary item directly). In my belief that the results are completely wrong I made my own calculator, based on rough simulation of individual steps. I get vastly different results. The script I used https://pastebin.com/pipEF4u3, based on your CLI setup, only handles max_quality==5 and ending_quality==5

sample:

# legendary modules in EMP
...>python main.py -pt 3 -qt 3 -q 5 -r -ms 5 -p 50
Setup:
Starting quality: Common
Module slots: 5
Productivity modules: Legendary Productivity Module 3; 25.0% bonus
Quality modules: Legendary Quality Module 3; 6.2% bonus
Base productivity: 50.0%
Recycler quality bonus: 24.8%
Best solutions:

Common   -> Uncommon  : 5 productivity modules, 0 quality modules (175.0% productivity, 0.0% quality)
Uncommon -> Rare      : 5 productivity modules, 0 quality modules (175.0% productivity, 0.0% quality)
Rare     -> Epic      : 5 productivity modules, 0 quality modules (175.0% productivity, 0.0% quality)
Epic     -> Legendary : 4 productivity modules, 1 quality modules (150.0% productivity, 6.2% quality)
0.10725614561926426 results per 1 input; 9.323475071999885 inputs per 1 result

Common   -> Uncommon  : 5 productivity modules, 0 quality modules (175.0% productivity, 0.0% quality)
Uncommon -> Rare      : 5 productivity modules, 0 quality modules (175.0% productivity, 0.0% quality)
Rare     -> Epic      : 5 productivity modules, 0 quality modules (175.0% productivity, 0.0% quality)
Epic     -> Legendary : 3 productivity modules, 2 quality modules (125.0% productivity, 12.4% quality)
0.10641672418163424 results per 1 input; 9.397019196843342 inputs per 1 result

Common   -> Uncommon  : 5 productivity modules, 0 quality modules (175.0% productivity, 0.0% quality)
Uncommon -> Rare      : 5 productivity modules, 0 quality modules (175.0% productivity, 0.0% quality)
Rare     -> Epic      : 4 productivity modules, 1 quality modules (150.0% productivity, 6.2% quality)
Epic     -> Legendary : 4 productivity modules, 1 quality modules (150.0% productivity, 6.2% quality)
0.1051781756035146 results per 1 input; 9.50767584873933 inputs per 1 result

master output for comparison

...>python main.py -pt 3 -qt 3 -q 5 -sq 1 -eq 5 -mq 5 -r -ms 5 -p 50 

optimizing production of output quality 5 from input quality 1

q1 input per q5 output: 13.23390993143569
recipe q1 uses 1 quality modules and 4 prod modules
recipe q2 uses 1 quality modules and 4 prod modules
recipe q3 uses 1 quality modules and 4 prod modules
recipe q4 uses 0 quality modules and 5 prod modules
Sopel97 commented 2 weeks ago

Dump from my script for every step of the simulation for 8 legendary modules (-pt 3 -qt 3 -q 5 -r -ms 8 -p 0). Looks correct to me at least

Setup:
Module slots: 8
Productivity modules: Legendary Productivity Module 3; 25.0% bonus
Quality modules: Legendary Quality Module 3; 6.2% bonus
Base productivity: 0.0%
Recycler quality bonus: 24.8%
Best solution:

Common   -> Uncommon  : 8 productivity modules, 0 quality modules (200.0% productivity, 0.0% quality)
Uncommon -> Rare      : 8 productivity modules, 0 quality modules (200.0% productivity, 0.0% quality)
Rare     -> Epic      : 8 productivity modules, 0 quality modules (200.0% productivity, 0.0% quality)
Epic     -> Legendary : 7 productivity modules, 1 quality modules (175.0% productivity, 6.2% quality)
0.1892653042294558 results per 1 input; 5.283588579910293 inputs per 1 result

---------------------------

                Ingredients                                             Results
Comm    Unco    Rare    Epic    Lege            Comm    Unco    Rare    Epic    Lege
1.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.000
Assembling
0.000   0.000   0.000   0.000   0.000           3.000   0.000   0.000   0.000   0.000
Recycling
0.564   0.140   0.035   0.009   0.002           0.000   0.000   0.000   0.000   0.000
Assembling
0.000   0.000   0.000   0.000   0.000           1.692   0.420   0.104   0.022   0.008
Recycling
0.318   0.158   0.059   0.019   0.005           0.000   0.000   0.000   0.000   0.008
Assembling
0.000   0.000   0.000   0.000   0.000           0.954   0.474   0.176   0.049   0.025
Recycling
0.179   0.134   0.066   0.026   0.007           0.000   0.000   0.000   0.000   0.025
Assembling
0.000   0.000   0.000   0.000   0.000           0.538   0.401   0.199   0.066   0.049
Recycling
0.101   0.100   0.062   0.028   0.007           0.000   0.000   0.000   0.000   0.049
Assembling
0.000   0.000   0.000   0.000   0.000           0.304   0.301   0.187   0.072   0.075
Recycling
0.057   0.071   0.053   0.027   0.007           0.000   0.000   0.000   0.000   0.075
Assembling
0.000   0.000   0.000   0.000   0.000           0.171   0.212   0.158   0.069   0.100
Recycling
0.032   0.048   0.042   0.023   0.006           0.000   0.000   0.000   0.000   0.100
Assembling
0.000   0.000   0.000   0.000   0.000           0.097   0.144   0.125   0.061   0.122
Recycling
0.018   0.032   0.031   0.019   0.005           0.000   0.000   0.000   0.000   0.122
Assembling
0.000   0.000   0.000   0.000   0.000           0.054   0.095   0.094   0.050   0.140
Recycling
0.010   0.020   0.023   0.015   0.004           0.000   0.000   0.000   0.000   0.140
Assembling
0.000   0.000   0.000   0.000   0.000           0.031   0.061   0.068   0.039   0.154
Recycling
0.006   0.013   0.016   0.011   0.003           0.000   0.000   0.000   0.000   0.154
Assembling
0.000   0.000   0.000   0.000   0.000           0.017   0.039   0.048   0.029   0.164
Recycling
0.003   0.008   0.011   0.008   0.002           0.000   0.000   0.000   0.000   0.164
Assembling
0.000   0.000   0.000   0.000   0.000           0.010   0.024   0.033   0.021   0.172
Recycling
0.002   0.005   0.007   0.006   0.002           0.000   0.000   0.000   0.000   0.172
Assembling
0.000   0.000   0.000   0.000   0.000           0.006   0.015   0.022   0.015   0.178
Recycling
0.001   0.003   0.005   0.004   0.001           0.000   0.000   0.000   0.000   0.178
Assembling
0.000   0.000   0.000   0.000   0.000           0.003   0.009   0.015   0.011   0.181
Recycling
0.001   0.002   0.003   0.003   0.001           0.000   0.000   0.000   0.000   0.181
Assembling
0.000   0.000   0.000   0.000   0.000           0.002   0.006   0.010   0.007   0.184
Recycling
0.000   0.001   0.002   0.002   0.000           0.000   0.000   0.000   0.000   0.184
Assembling
0.000   0.000   0.000   0.000   0.000           0.001   0.003   0.006   0.005   0.186
Recycling
0.000   0.001   0.001   0.001   0.000           0.000   0.000   0.000   0.000   0.186
Assembling
0.000   0.000   0.000   0.000   0.000           0.001   0.002   0.004   0.003   0.187
Recycling
0.000   0.000   0.001   0.001   0.000           0.000   0.000   0.000   0.000   0.187
Assembling
0.000   0.000   0.000   0.000   0.000           0.000   0.001   0.003   0.002   0.188
Recycling
0.000   0.000   0.001   0.001   0.000           0.000   0.000   0.000   0.000   0.188
Assembling
0.000   0.000   0.000   0.000   0.000           0.000   0.001   0.002   0.001   0.188
Recycling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.188
Assembling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.001   0.001   0.189
Recycling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Assembling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.001   0.001   0.189
Recycling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Assembling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Recycling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Assembling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Recycling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Assembling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Recycling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Assembling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Recycling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Assembling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Recycling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Assembling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Recycling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Assembling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Recycling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Assembling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Recycling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Assembling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Recycling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Assembling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Recycling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Assembling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Recycling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Assembling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Recycling
0.000   0.000   0.000   0.000   0.000           0.000   0.000   0.000   0.000   0.189
Converged in 32 iterations
scottmsul commented 2 weeks ago

Not that this is proof one way or the other yet, but one thing I'll note is that there was a small group of people in the discord back when quality was first announced, and the 79.9 number was verified by several people, but it looks like your code is giving 47.21, so I suspect it may be incorrect. This is for all default settings.

Sopel97 commented 2 weeks ago

After a lot of back and forth on discord it was discovered that my code had wrong assumptions about how quality works. The updated code can be found here https://pastebin.com/HLhAHxh5 and matches the master results.