OptimaUPS Mod
Posted: Tue Jan 05, 2021 3:47 pm
Ok, not sure about the name, but it's based on the discussions here
viewtopic.php?f=6&t=91587&p=530292#p530292
viewtopic.php?f=6&t=82060
viewtopic.php?f=5&t=88414
The idea being that factorio redundantly processes a lot of duped factories and if you start bumping up against UPS issues, you can squeeze out a few more KSPM via some factory hacking but that's it.
A mod which reduces redundant processing would allow for a much larger and more sophisticated train network while still being able to tweak your core factories. At some point of course, you will hit the limits, but the mod should extend things out quite a bit.
I have done a forked proof of concept using factorissimo for my base and it was fairly easy to implement. I use simple estimation techniques of input/output based on the parent factory. It works sufficiently for my personal purposes in reducing UPS consumption which I'm running into rather heavily.
It also has an intriguing and very useful side benefit of being able to make updates to core factory designs without having to redundantly replicate them everywhere.
However, if there is broader interest, I would create a new mod for this, as factorissimo isn't really about this problem (so I've been told) and I don't believe the mod owner wishes to be forked.
The new mod would be MIT licensed and anyone can fork or even take over ownership if they are particularly interested and can do a better job. It should, imho, just be about optimizing UPS.
The mod would also ideally work for nuclear factories, so you don't have to resort to fields of solar panels. No guarantees there just yet.
Ssilk has a suggestion regarding a deterministic approach that doesn't require estimation of inputs and outputs I discuss here - viewtopic.php?p=530292#p530292
It's an interesting idea and I just wanted to see if folks would want something like this, or even just the mod itself. It basically involves syncing up all factories (parent and child clones) that start from total empty state.
The implications of the idea is that as long as a synced child has enough supply to match the input of the parent, it can continue to produce whatever the parent is producing. If children get desynced by not having enough supply, they have to wait for a full wipe of the parent to rejoin production. Adding new children factories requires a full wipe of parent/children factories.
Broadly speaking, this would be fairly easy to implement, though I don't know if it can be done with the level of determinism he's hoping to achieve and still be UPS efficient.
My thought is just to support cargo / fluid wagons. Basically, a train stop would be adjacent to the factory and that would be your input. Similarly, a train stop would be adjacent for output.
Factories could be of arbitrary size. Even interior train systems could be allowed as long as they don't go outside of the factory. I was thinking about requiring a 'factory floor' to be installed before a child factory is allowed, but those sort of extra game features are subjective and this really is just meant to be about optimizing UPS.
Another thought is that you have to pre-print down a copy of the parent factory and the mod does a match of all the entities to see if it qualifies as a child. It would list any mismatches. This is the preferred approach in my eyes.
Changing parent factory entities would force a full reset and would have inventory implications respective to the full set of parent/child factories. Eg, if you remove an assembler, you get assemblers into your inventory from all factories. If you add one, you need to have enough for all factories. How this turns out in practice will depend on the APIs and what they can do here.
It may require an external surface to avoid logistics networks from being abused, though honestly, exploits like that aren't really a huge concern. It's more about accidental input that the player is unaware of that is a concern. /editor is always a console command away for those determined to subvert default game play.
Mining operations, pumpjacks and labs would probably not be done inside of these factories. Not totally sure about labs. The other two can theoretically be done, but not sure how fun that would be.
I'm not really concerned about biters but willing to take input on that. Biters have been eradicated from my core map due to artillery on islands with logistics and a very long artillery range.
I will try to see if I can dupe the tiles used for the parent factory, they'd just be cosmetic in the child factories. Not sure if that's possible though, so art is something to think about here.
Like I said above, I have this working as a POC already for my own use, but interested in doing the above if other folks would seriously use this.
In particular, looking for detailed feedback on implications to game play, especially from those familiar with the factorio lua apis. Certain things I know how to do and are quite simple, others not so much.
Some specific lua questions for experienced mod developers:
- how best to track changes a user makes to a parent factory in real time.
- I am assuming the selection-tool-item will provide anything required for the mod, though I have yet to play with that. I may end up using some aspect of blueprints here if customized / tailored blueprint like functionality is not possible.
- Factorrisimo uses belts, chests and pipes, but I'm assuming something analogous exists for cargo / fluid wagons and you can manipulate as required. If not, chests and pipes should be fine. F2 has some useful ideas around UPS efficiency here to borrow from.
- How to re-use factorio tiles but only for cosmetic purposes
- thoughts on monitoring input/output in a UPS efficient manner, for factories and power suppliers.
Surfaces, inventory management, chest manipulation I'm familiar with from the above POC.
Ideally, the syncing talked about above and measuring input / output costs would be done in a highly efficient UPS manner. Logically speaking, tight loops around measuring input/output would have to be avoided. I'm less concerned about absolute correctness than I am about optimizing UPS, however there are multiplayer implications when it comes to absolute correctness.
At megabase scale where UPS is an issue, these type of details seem less important than being able to extend the game significantly.
TBH, just using simple estimation techniques in my POC above results in about 0.1% error rates (if that) compared to deterministic production. The determinism is not that super relevant to me, but others have said its relevant to them as this is what is cool about Factorio, so I am considering the factory syncing approach which should theoretically be exact, at least from this syncing perspective.
I've read there are deterministic aspects that multiplayer relies on. If multiplayer mode can't be done without full determinism and if full determinism can't be done without seriously harming UPS, than I'd argue in favor of not supporting MP.
However, I am assuming there must be ways of syncing up clients other than having a fully deterministic play loop. I haven't really tackled MP just yet and input appreciated.
I haven't thought through all the issues, and there's really only so many minutes in the day you can devote to factorio.
Please chime in with your two cents if you know more about something I've missed above. Bonus points for elegant, fun ideas that are easy to implement.
viewtopic.php?f=6&t=91587&p=530292#p530292
viewtopic.php?f=6&t=82060
viewtopic.php?f=5&t=88414
The idea being that factorio redundantly processes a lot of duped factories and if you start bumping up against UPS issues, you can squeeze out a few more KSPM via some factory hacking but that's it.
A mod which reduces redundant processing would allow for a much larger and more sophisticated train network while still being able to tweak your core factories. At some point of course, you will hit the limits, but the mod should extend things out quite a bit.
I have done a forked proof of concept using factorissimo for my base and it was fairly easy to implement. I use simple estimation techniques of input/output based on the parent factory. It works sufficiently for my personal purposes in reducing UPS consumption which I'm running into rather heavily.
It also has an intriguing and very useful side benefit of being able to make updates to core factory designs without having to redundantly replicate them everywhere.
However, if there is broader interest, I would create a new mod for this, as factorissimo isn't really about this problem (so I've been told) and I don't believe the mod owner wishes to be forked.
The new mod would be MIT licensed and anyone can fork or even take over ownership if they are particularly interested and can do a better job. It should, imho, just be about optimizing UPS.
The mod would also ideally work for nuclear factories, so you don't have to resort to fields of solar panels. No guarantees there just yet.
Ssilk has a suggestion regarding a deterministic approach that doesn't require estimation of inputs and outputs I discuss here - viewtopic.php?p=530292#p530292
It's an interesting idea and I just wanted to see if folks would want something like this, or even just the mod itself. It basically involves syncing up all factories (parent and child clones) that start from total empty state.
The implications of the idea is that as long as a synced child has enough supply to match the input of the parent, it can continue to produce whatever the parent is producing. If children get desynced by not having enough supply, they have to wait for a full wipe of the parent to rejoin production. Adding new children factories requires a full wipe of parent/children factories.
Broadly speaking, this would be fairly easy to implement, though I don't know if it can be done with the level of determinism he's hoping to achieve and still be UPS efficient.
My thought is just to support cargo / fluid wagons. Basically, a train stop would be adjacent to the factory and that would be your input. Similarly, a train stop would be adjacent for output.
Factories could be of arbitrary size. Even interior train systems could be allowed as long as they don't go outside of the factory. I was thinking about requiring a 'factory floor' to be installed before a child factory is allowed, but those sort of extra game features are subjective and this really is just meant to be about optimizing UPS.
Another thought is that you have to pre-print down a copy of the parent factory and the mod does a match of all the entities to see if it qualifies as a child. It would list any mismatches. This is the preferred approach in my eyes.
Changing parent factory entities would force a full reset and would have inventory implications respective to the full set of parent/child factories. Eg, if you remove an assembler, you get assemblers into your inventory from all factories. If you add one, you need to have enough for all factories. How this turns out in practice will depend on the APIs and what they can do here.
It may require an external surface to avoid logistics networks from being abused, though honestly, exploits like that aren't really a huge concern. It's more about accidental input that the player is unaware of that is a concern. /editor is always a console command away for those determined to subvert default game play.
Mining operations, pumpjacks and labs would probably not be done inside of these factories. Not totally sure about labs. The other two can theoretically be done, but not sure how fun that would be.
I'm not really concerned about biters but willing to take input on that. Biters have been eradicated from my core map due to artillery on islands with logistics and a very long artillery range.
I will try to see if I can dupe the tiles used for the parent factory, they'd just be cosmetic in the child factories. Not sure if that's possible though, so art is something to think about here.
Like I said above, I have this working as a POC already for my own use, but interested in doing the above if other folks would seriously use this.
In particular, looking for detailed feedback on implications to game play, especially from those familiar with the factorio lua apis. Certain things I know how to do and are quite simple, others not so much.
Some specific lua questions for experienced mod developers:
- how best to track changes a user makes to a parent factory in real time.
- I am assuming the selection-tool-item will provide anything required for the mod, though I have yet to play with that. I may end up using some aspect of blueprints here if customized / tailored blueprint like functionality is not possible.
- Factorrisimo uses belts, chests and pipes, but I'm assuming something analogous exists for cargo / fluid wagons and you can manipulate as required. If not, chests and pipes should be fine. F2 has some useful ideas around UPS efficiency here to borrow from.
- How to re-use factorio tiles but only for cosmetic purposes
- thoughts on monitoring input/output in a UPS efficient manner, for factories and power suppliers.
Surfaces, inventory management, chest manipulation I'm familiar with from the above POC.
Ideally, the syncing talked about above and measuring input / output costs would be done in a highly efficient UPS manner. Logically speaking, tight loops around measuring input/output would have to be avoided. I'm less concerned about absolute correctness than I am about optimizing UPS, however there are multiplayer implications when it comes to absolute correctness.
At megabase scale where UPS is an issue, these type of details seem less important than being able to extend the game significantly.
TBH, just using simple estimation techniques in my POC above results in about 0.1% error rates (if that) compared to deterministic production. The determinism is not that super relevant to me, but others have said its relevant to them as this is what is cool about Factorio, so I am considering the factory syncing approach which should theoretically be exact, at least from this syncing perspective.
I've read there are deterministic aspects that multiplayer relies on. If multiplayer mode can't be done without full determinism and if full determinism can't be done without seriously harming UPS, than I'd argue in favor of not supporting MP.
However, I am assuming there must be ways of syncing up clients other than having a fully deterministic play loop. I haven't really tackled MP just yet and input appreciated.
I haven't thought through all the issues, and there's really only so many minutes in the day you can devote to factorio.
Please chime in with your two cents if you know more about something I've missed above. Bonus points for elegant, fun ideas that are easy to implement.