-
Notifications
You must be signed in to change notification settings - Fork 34
feat: percentage based ingredient consumption #511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: percentage based ingredient consumption #511
Conversation
| if (!hasPercentageConstraint) { | ||
| // Show button to set percentage constraint | ||
| if (gui.BuildButton("Set consumption %") && gui.CloseDropdown()) { | ||
| recipe.RecordUndo().ingredientConsumptionPercentages[goods] = 0.5f; // Default to 50% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on a little poking around, it appears that a non-zero recipe.fixedBuildings conflicts with percentage constraints. That seems reasonable, so recipe.fixedBuildings should be zeroed here, and the fixedBuildings setter should clear ingredientConsumptionPercentages when given a non-zero value. (Ideally, adding a value to ingredientConsumptionPercentages would zero fixedBuildings, but that will be complicated.)
I'm not sure what should happen with this sort of a table, but "could not solve" is probably not right.

Share string
inR0c+YKKMrPSk0uCUhMT+Uy0jM00TPQM+Di4gIAAAD//9WVTW/bMAyGf0t5dgyn+UDq44oF6KFYNuQyDD3QEu0IkSVPltoGgf/76I+kCVAga4YdepMo6uUrPpK9B2GNJ+PXu4oghZ+Yi/jRStIx75BBeGXNGjNNEEERlOQcHNNsPr8bL26n+ZQyWozxdj6bTATdzZPJXHCmYlVITdA6AoNlq7ym2vPKUA7SPdBrhUYSS3oXKAKtzLaG9NceCmslj/bg0RXEybDUXDvOlA8lGZb5HVArv+OV7/0oNtaVqKGJAEsb2gqjSZLwTBfWKb8pIR1HUFecvCIn2AO3ovfYPEXgSKiK+vL9+Kz+jy50MDBylCujTHHBCRfplk6EvnahWKraK43eugsSeSB9JrCyL+Ri0gzTKdFuuyCgXkl+CUpL9lt3TehCy044R13TEHkwhSOpOjo9ui483INDLGMpf6LXR+uNfVlbj/rh21GUTHtvjni535AyEHUsc29NHcqqvWJvSFrubLvkopre9ENWOBuqw/wZnULjW15PTfQ3yAqsVa4EttWuxiYcii25UblNpteB2xD6DxJLPgExuDl7oTfDadIknv0PmN6O6qDz4K4mGarCofwnlNe/wc9A9IPY+BN6TN+zaa0flSHHs8EJBm+XHF7hLuNHNDRBa3L8u+F9x7MRnvw8+tl7GTXbPbQA0kUE9pmcU5LuHeae1/qs9iRN0/wB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you only add a single recipe as a %, then the expected behavior is actually 50% to residual mixture, and 50% to "extra products". Dirty syngas should have 0, as it doesn't take part in the % calculation. Only once you set the other recipe to be a % consumption, does it take it into account. This is the only "good" behavior I could come up with that still allows you to have some "excess" for storage, and doesn't break the solver too badly. That said, it should have calculated the values properly even with what you provided there. I'll check it. Edit: It looks like forced consumption has issues... which kind of makes sense. The % calculation only takes into account those recipes set to have it. If only 1 is using a %, then "where does the other half go?" is a great question... |
… when setting percentage constraints


This PR introduces the ability to set a consumption % on items.
Given the above, we want 40% of the bitumen to go to Residual mixture, and 60% to dirty syngas.
This PR introduces a new button on the production item dropdown to "Set consumption %"
Clicking this immediately sets that item to 50% consumption as shown here:
Note: Due to how yafc handles things in the solver, we need to forcefully enable overproduction for the linked item, to ensure the "remaining" product goes to the "extra products". (Eg; send 50% to residual mixture, but save/buffer the other 50% somewhere else)
If you can think of a better way to handle this specifically, let me know. Short of adding a lot of new solver parameters and states/types, I couldn't think of a better solution.
Adding consumption % to dirty syngas, we get this:
It now consumes 50% for each (currently have to manually remove the overproduction flag when a 2nd recipe is introduced)
And for 60/40: