Started some initial work in this... currently have done the following:
1) New internal variable, USE_STACK. Currently forced to true on my copy, because I don't want to dump in a lot of useless preferences I'll just be scrapping, but will eventually be removed once the stack is fully successful.
2) New map named consuming.
Items are currently added to this map as the consumeone function runs. If USE_STACK is on, it runs a check to see if consuming contains con.it already. If so, it adds one to the value. If not, it makes consuming[con.it] = 1. Items in here should be able to be considered at any time following their addition.
3) New int value added to the con_rec record type, using. This is so we have easy checking for how many items are still available after our usage, since once we have stacks working properly, it should try to plan everything before the first item is used, whether ConsumeLast is configured and it will go through the whole stack, or if it plans another stack following the first item. If we're not using ConsumeLast, it should wipe this when a new consumption stack is begun, but for now it sets this to 0 when the item is loaded (in update_from_mafia), is incremented by 1 when an item is planned to be used in consumeone, and decremented by 1 after consumption happens in consumeone - after ateone in both the SIM_CONSUME false and true segments. In the functions effective_price, set_prices, inbudget, and filter_final, it checks for con.having - con.using as its usable amount. In availability, after it does all of the other additions, it runs con.have = con.have - con.using, so that used items count against the availability.
These changes shouldn't actually affect the way EatDrink runs for me tonight, yet. If I have it express the consuming map, it should give me a result similar to the summarized food, but simply telling me which items it ate and how many of them were eaten total in that script execution. Though con.using is counted against availability and those, it's only incremented and decremented inside USE_STACK inside the consumeone function, and it should always (currently) return 0 if checked outside of that function.
Any thoughts or caveats I should keep in mind? My plan is to have it run like this for a bit, then split the stacking and consumption into a minimum of two functions - stack and consume - or possibly three - stack, obtain (have/pull/buy/create), consume. Once it properly runs in a multiple-stage process, I can begin speculating against stacks.
Working through the above sentences, I think the 3 function process should work better... with the ConsumeLast preference set it would just stack fully, obtain fully, and then consume fully. The normal behaviour would be stack fully, obtain one, consume one, clear stack, stack fully, obtain one, consume one, repeat. Takes more time, but should provide better overall results, since it's giving you the best result based on the fullness you have left and your current situtation.
One strong possibility as well would be changing the map (consuming) to a record type. Position in the stack matters, so I've been somewhat torn in terms of whether it would best be served as an array, but the problem is that with mojo filters and other items, I can't just have the array max size be conmax (the desired full/drunk/spleen) because it might be significantly larger by the time it's done... *ponders*
If I just make a map like this...
then I can do position[0] = con.it, position[1] = next con.it, etc, right? That should skip out of the record issue, give me position of consumption, etc...
Okay, set a new int, maxposition, which is reset to 0 on each iteration of the consumption series. This ties into the item [int] position above, and should let me plan a stack and repeat it (in order).
Excellent... currently it displays the items as it's adding onto the stacks, which is rather spammy as it goes, but shows that it's working properly. Though it also shows me that I need to have it wipe the stacks once they're done, so I don't get this:
simulating consumption of one chocolate seal-clubbing club.
In position 0 is chocolate seal-clubbing club
In position 1 is slip 'n' slide
In position 2 is slip 'n' slide
In position 3 is slip 'n' slide
In position 4 is fine wine
In position 5 is fine wine
In position 6 is fine wine
Had it remove each entry in the position table between iterations, and it now works...
simulating consumption of one chocolate seal-clubbing club.
In position 0 is chocolate seal-clubbing club
1: chocolate seal-clubbing club lev:0 gain:1.0 adv:3.0 musc:0.0 myst:0.0 mox:0.0 meat:2400 own:0 value:600
Anyways, it runs, it stacks in order, it clears... I'll spam myself a few days and ponder splitting the functions out. As I said above before I came up with the position map, yell if you have caveats for me. Otherwise, I'll try to split things together and post the split-function version so it can be validated to run the same for other people as well as myself... odd how things run differently when they get out into the wild.
Part of this would be that the milk/ode could be compared against the full stack, so it would have milk still work with a VoA as low as 100 or less, depending on mall prices...
Once it's validated to have proper base-code, my plan for the next step is 2 stacks... configured VoA, speculative VoA if lower, and automatically use whichever of the two is best... If you can save some meat and still end up with more total adventures, that counts as a win/win in my book.
After we have speculative VoA working properly, my next plan is to start messing with the decision of what makes the best last item. If it wants 2 +5 adventure 3 fullness items with 8 current fullness (10 total gain, 6 fullness, 1.66 adv/full), but we can use 7 items that provide +1.5 adventure at 1 fullness (10.5 total gain, 7 fullness, 1.5 adv/full), we've ended up a TINY bit better. Not much, but every adventure helps. We'd likely want this to be another preference though, because what we're doing is (potentially) reducing our efficiency for the day because of wanting immediate gains. This would be most useful early on in low-skill HC or BM ascensions when you're moderately likely to end a day or two with 13/15 fullness or to go into your overdrink with 12 or 13/14. After you start getting access to more locations and crafting, it's less likely to end up bringing extra adventures. Additionally, this would help in cases (beginning using the example above) where you have 2 items that are +3 adventure, +3 fullness as well as 4 that are +2 adventure, +2 fullness. Instead of eating to 14 fullness for 6 adventures, it would eat to 15 fullness with 7 adventures (begins with one of the +3 fullness items before eating 2 of the +2 fullness items) giving a bit of benefit...
We can skip that last step if the collective thought is that it won't be useful or used. I just noticed early on in ascensions that my fullness often ended up missing a bit, and would be curious if it could be utilized more efficiently. Personally after level 3 or so, I'd just as soon disable that though...