Background
Dynamic MP calculation wants to find out the most cost-efficient way to do all those organelle updates. It saves time for the player to arrange their changes so that they can make more and focus on surviving. It was first implemented and merged by https://github.com/Revolutionary-Games/Thrive/pull/2445.
However, even after Cleaning up and improving dynamic MP by hhyyrylainen · Pull Request #3322 · Revolutionary-Games/Thrive · GitHub, Fix broken resulting MP calculation in cell editor by Kasterisk · Pull Request #3437 · Revolutionary-Games/Thrive · GitHub, Fix dynamic MP logic a bit by 84634E1A607A · Pull Request #3641 · Revolutionary-Games/Thrive · GitHub and Corrected dynamic MP logic to prioritize ReplacesOther action by 84634E1A607A · Pull Request #4082 · Revolutionary-Games/Thrive · GitHub, I am still able to produce calculation bugs.
We first tried to compare between the initial cell layout and the current layout in https://github.com/Revolutionary-Games/Thrive/pull/2365 but seems to have failed because of the difficulty to compare between graphs (maybe?) and all the bugs.
Then we tried to combine actions to achieve lower cost in https://github.com/Revolutionary-Games/Thrive/pull/2445, in a manner lake bubble sort. This soon proves to be buggy because some combinations are not the best.
Later I turned it to always do the most rewarding way #3641, but still in a sequential manner. (i.e. the combination is performed from the earliest to the latest action. I have proved that this isn’t perfect, still.
Status
The caching system in the algorithm may not work
Think of this seneraio:
- You place a Thylacoid to replace the initial cytoplasm ← This should be the only action
- You add a Cytoplasm at (0,1)
- You remove that Cytoplasm
Pretty simple and clear, but after step 1 and 2, you get this in the cache:
- Cytoplasm moved from (0,0) to (0,1)
- Thylacoid placed at (0,0)
Then with this cache, step 3 results in:
- Cytoplasm removed at (0,0)
- Thylacoid placed at (0,0)
Writing to here, I realized that this is because removing a cytoplasm is not combined with placing a Thylacoid. (But a remove action doesn’t know what is removed!)
We may need to try every possibility to get the best result
To avoid local optimal situations. With organelle update implemented, action combining can be more of a headache. So just searching through anything may be the best algorithm?
CellTypes make ActionData need more information
With multicellular set up, ActionData now needs an identity to not to combine actions made to different cell type.