yafc icon indicating copy to clipboard operation
yafc copied to clipboard

[Feature request] Optimize modules for specific goal

Open Saklad5 opened this issue 4 years ago • 9 comments

In vanilla Factorio and especially in Space Exploration, balancing modules can be both important and fairly difficult. The current payback-based system seems entirely broken in SE, but it doesn’t quite accomplish what I want anyway.

What I’d like to see is the ability to set certain priorities from amongst the various effects of modules, and have YAFC choose the cheapest set (using cost per item as a tiebreaker and keeping slot limits in mind) that accomplishes that task across both internal slots and beacons.

For instance, a common set of priorities I have is:

  1. Maximize productivity bonus.
  2. Minimize energy usage.

The latter is where things get interesting: depending on the amount of output demanded, speed modules may reduce actual energy consumption more than capping the energy usage reduction at -80%.

While this would be impossible to automatically calculate (due to not knowing how many machines are affected by a single beacon), I’d also be able to use such a system to determine whether using beacons can reduce energy more than their own power draw by simply adding a beacon and letting the analysis run again.

Given the information already available to and calculated by YAFC, this should be within the realm of possibility to calculate.

Saklad5 avatar Apr 15 '21 22:04 Saklad5

Note that when I say “energy usage” in that example, I am referring to the energy draw that YAFC already calculates for each recipe. I do not mean determining whether productivity modules could reduce energy demand across the entire production sheet or nested table, because that would be an utter nightmare to calculate.

Saklad5 avatar Apr 15 '21 22:04 Saklad5

Payback feature is there for the case when you don't have infinite modules and want the best use for those you have. It works well for vanilla and pyanodon mid-game.

Anything involving beacons is hard to set up because there are so many variables that should be put in. To the point that the feature is likely to cause more confusion than be useful.

I can add some more info to the module customization screen, like resulted energy usage, or output result to energy ratio, but I don't think I will add compilcated autofiller.

ShadowTheAge avatar Apr 15 '21 22:04 ShadowTheAge

Anything involving beacons is hard to set up because there are so many variables that should be put in. To the point that the feature is likely to cause more confusion than be useful.

I’m saying you should ignore beacons for that reason. The user would manually specify the number and type of beacons in the same manner you do right now, but that would not be touched by this proposed analysis tool. They’d be used if they are present, but never added or removed. To determine whether beacons are helpful, the user would change the beacon settings and run the analysis again.

Saklad5 avatar Apr 15 '21 22:04 Saklad5

You could conceivably implement this feature by brute-forcing every module combination and selecting the best one. That’s obviously not ideal, but my point is that everything necessary to do this is already handled by YAFC. As far as this tool need be concerned, beacons are just half-strength module slots with the cost per module multiplied by the number of beacons rather than the number of machines.

Saklad5 avatar Apr 15 '21 22:04 Saklad5

Sorry for bugging you about this, by the way. If you don’t want to implement something like this, that is your choice. I am tempted to throw together a script to brute-force it for my own use if that’s your decision, though.

Saklad5 avatar Apr 15 '21 22:04 Saklad5

I have added two more lines at module customization screen:

  • Crafting speed in products per second (including productivity)
  • Energy cost per product

As for optimizer, at least not now. It is very easy to optimize productivity, and for optimizing "energy per product" - if that was trivial thing - sure, but it isn't unfortunately.

ShadowTheAge avatar Apr 25 '21 19:04 ShadowTheAge

I wrote a Python script that does more or less what I was asking for. If you ever decide to implement this functionality in YAFC (which could do it much more elegantly, as it knows things like crafting duration, energy usage, and a more accurate module cost), it may help.

Module Optimizer.txt

Saklad5 avatar May 02 '21 23:05 Saklad5

11 parameters is a fair amount, but I wouldn’t call it unusable. Then again, I made the thing. And I didn’t add a method of adjusting which priorities come first, among other shortcomings.

Saklad5 avatar May 02 '21 23:05 Saklad5

It wouldn’t complicate the rest of the model, at least: the idea is that you run it once then use the results, so the parameters don’t even need to be retained.

Saklad5 avatar May 02 '21 23:05 Saklad5