aritchie05 / EcoCraftingTool

Crafting calculator for Eco.
https://eco-calc.com
MIT License
24 stars 12 forks source link

Improve performance of recalculateOutputPrices() function #51

Closed aritchie05 closed 1 year ago

aritchie05 commented 2 years ago

Right now this method just recalculates all output prices 10 times in a row (horribly inefficient). This is done to ensure dependent prices are guaranteed to be correct for other output recipes.

For example, if the output list has Iron Bar and Iron Pickaxe, we need to make sure the output price of Iron Bar is correct before using that price for the Iron Bar ingredient in the Iron Pickaxe recipe. Right now it is just brute forced. The goal should be an "OutputPriceCorrect" flag on each output recipe that is set to false when we need to recalculate prices, and is set to true if the price is calculated with only ingredients that are in the Inputs section, OR with ingredients in the Outputs section that have their OutputPriceCorrect flag already true.