EatDrink.ash: Optimize your daily diet (and see how your old diet stacks up).

This is probably quite a useless feature request, and when I use EatDrink myself I dont really need this feature anyway, but tossing he idea out there.

When eating and drinking mid-run, I find myself cooking stuff without the Chef and Bartender.
The issue I have is that EatDrink use Milk of Magnesium before it start cooking, meaning the adventures it spend cooking is "wasting" my Milk and when I have Impetuous Sauciness I get exactly 15 turns of Got Milk. Using those turns to cook means I have to use another one to get bonus from all the food.
When I do it manually, I queue stuff up, cook them, drink the Milk and then re-queue everything to eat it.

So, to the feature: Have EatDrink cook everything before it use Milk of Magnesium. I remember talk about it not casting Ode, but I guess the same thing apply there if the script cast Ode on its own.
 
The new version I'm working on does that already... the two exceptions will be key lime pies and TPS drinks. Currently. Unless we come up with more items where ingredients come back to you.

That doesn't happen yet (multiple TPS/key lime pies). But the milk/ode first is happening already.
 
I MIGHT have this fixed... won't know until I actually remember to farm/buy a lime. :) It's remarkably easier to make key lime pies if you have limes. Weird.

It's possible that simulating key lime pies and TPS drinks may never work, due to the partial (but not full) ingredient clearing. Alternatively, I could make it significantly more complicated... have it save the item causing it to break instead of having it as a boolean. It's kludge, but would probably allow for better simulation.

Do you, the (eventual) users have a preference? Cleaner (looking) code that just makes it recalculate as if you're trying the iteration again (with consumption down to whatever level you've done), or kludged code that should realize that your TPS/key isn't consumed when you drink/eat and remove that ingredient from the crafting list when it moves on? I'm tempted by the kludge atm, just because it'll be more accurate to what you'll really get.
 
Good question. I would like SIM to be as accurate as possible in predicting the resources I need and/or will consume. But I don't want it to offer me two different answers in case boxen break during creation since dealing with that seems too fiddly to be worth the effort. Stuff Happens.

In theory if a player has one TPS or one key then they have an infinite number of the item and so creation would be driven/limited by the other ingredients. So, before I consume I would consider having all the necessary ingredients on hand as the closest action possible short of actually creating everything. If I do that then the only fiddling will be managing the effects if creation will consume turns. Am I making sense?
 
If I'm understanding you properly, accuracy of results > elegancy/readability in backend. Yes?

If the script does what I want it to then I will never know how unreadable it is.

In the days of my youth, Jon Bentley convinced me that it was easier to make a working program fast than it was to make a fast program work. So I am almost always going to favor getting something to work and then worrying about readability, efficiency, speed or any of the other characteristics that will make it better code but not necessarily make it better working code.
 
Sounds good. I'm merely thinking about how much people talk about being confused looking at the code [currently in 'official' EatDrink], but then again, that generally happens when they're trying to change something. If I can make it work properly, that should be moderately irrelevant... the only times it will need tweaks is when new challenge paths and other such KoL changes happen. Mafia will track creatable_amount and those, but that doesn't mean that [the released 'official'] EatDrink won't try to buy invalid items from the mall in SC or other such cases.

My current plan is to farm 1-2 limes at rollover, validate that they do indeed allow the proper amount of pies... if I remember, I'm going to simulate at 1, tweak the script, farm another, and simulate again. On the above work in progress, it would allow for 1 total pie per key. In the script as it currently exists, it will either try to keep reusing the ingredients (1 lime == infinite limes) or believe that the key is being consumed. Once I can test it, I'll try to have it remove the key from the 'consumed ingredients' listing, but retain the lime and pie tray and dough and all of those as being used... :) Should work; I've planned how to do it and all... it's just much better working when you can actually see the results, as opposed to hoping that it'll go.

Sidenote: If it decides to hit a reusable ingredient, that completely stops the queue and speculative stack, makes/consumes up to that point, and then restarts that step (with the new appetite/inebriety rating)... I need to do this because I don't know how many pies it will make total, so if I didn't do that it might think that key lime pies are only worth 16 total adventures for the whole stack instead of something worse that ends up at a higher total, but achieves total fullness... if that makes sense. My coherency isn't at its best currently, and I'm aware of it. Ah well. Example: it might think that it was only consuming 4 total appetite total instead of going for 15, and eating 15 caviar would give more adventures than 1 KLP, which is true... but not an accurate 'best consumption' stack.
 
Okay... here's the script. Should work, though I did end up having it get stuck on star key lime pie for some reason.

This does also require using the updated zlib with the be_good function, or adding it in manually, but because of it does also work properly with bee-core. For those who might care, here are the aliases I use with this, for testing and actual execution:eatdrink = full
eatdrinkn(o)e(ating) = full drink/spleen
eatdrinkn(o)d(rinking) = full appetite/spleen
eatdrinko(ver)d(rink) = full, with overdrink.
Put a 's' on front to simulate, so seatdrink should simulate a full execution using your current doneness and other such states...

Something went screwy when I ran this version today (my zlib IS up to date, I'm running r9340, I'm in bees hate you soft core post Ronin in case any of that impacts what went wrong). First it couldn't obtain a pumpkin pie for some reason so it skipped eating entirely. The only error message given in CLI or my log was "Something went wrong with getting pumpkin pie for 18500. Skipping." It sounds like it tried to buy the pie instead of making it with my pumpkin. I thought the new zlib's be_good function was interfering and wouldn't let me put on the Bug Bear outfit to buy the pie pan and dough but the command make pumpkin pie still works. It drank alright (although I think it might have been able to do better than Rockin' Wagons and Supernova Champagne even without a bartender in a box) but when it got to spleen it attempted to buy 2 prismatic wads (I already had three in inventory having cast rainbow gravitation) resulting in the following message in my CLI and a failure to consume my spleen items either.

Code:
Purchasing prismatic wad (1 @ 180)...
You acquire an item: prismatic wad
Purchasing prismatic wad (1 @ 5,000)...
You acquire an item: prismatic wad
Purchases complete.
You now have a total of 5
Purchased 2 prismatic wad for 5180 meat.
Failed to get prismatic wad for a max price of 1.25*5100=6375.0
Something went wrong with getting prismatic wad for 5100. Skipping.
Something went wrong with position 0 in the stack and it's a null item. Ending stack.

Taking a closer look I see why it bought the first, it found a nice sale, but I'm pretty sure I don't have my meat per adventure set high enough that a fifth wad at 5000 meat is something the script should have bought. Edit: Did the math and was surprised that the 5000 meat wad still came out at a profit. However the profit was only about 17 meat per adventure, a non-prismatic wad would have given me a lot less adventures (one adventure in fact) but hundreds of meat of profit for that one adventure.

Edit: Ran it again hoping that having the pie in my inventory would help. No dice, it tries to buy two more at mall prices fails to do so and refuses to eat anything. It then attempts to use the prismatic wads in my inventory and fails to do so with no other information than "Using 1 prismatic wad...
Finished using 1 prismatic wad.
FAIL: prismatic wad lev:7 gain:3.0 adv:6.0 musc:55.0 myst:55.0 mox:55.0 meat:5165 own:1 value:1956".
 
Last edited:
The way it works, it queues up everything, obtains everything, and then consumes it. If something goes wrong with it... for example, prismatic wads being incredibly expensive, it aborts that stack, on the basis that it's sort of screwed. Nothing we can do to predict prismatic availability out... what I might end up doing is force a recalculation, similar to what I'm planning with reusable ingredients, if the stack fails. But that's for after we get that working... one step at a time. Unless we leapfrog.
 
The way it works, it queues up everything, obtains everything, and then consumes it. If something goes wrong with it... for example, prismatic wads being incredibly expensive, it aborts that stack, on the basis that it's sort of screwed. Nothing we can do to predict prismatic availability out... what I might end up doing is force a recalculation, similar to what I'm planning with reusable ingredients, if the stack fails. But that's for after we get that working... one step at a time. Unless we leapfrog.

Well, one of the questions though is why it tried to buy pumpkin pies at all instead of making one from the pumpkin I had and then moving on to something else like older versions of the script would. Or why it bought a 5000 meat prismatic wad when three much cheaper elemental wads would have been a better choice (it didn't try and fail to buy that 5000 meat wad, it did buy it and then failed to consume). It does look to be avoiding B items but it seems to have lost functionality on the way there.
 
Well, one of the questions though is why it tried to buy pumpkin pies at all instead of making one from the pumpkin I had and then moving on to something else like older versions of the script would. Or why it bought a 5000 meat prismatic wad when three much cheaper elemental wads would have been a better choice (it didn't try and fail to buy that 5000 meat wad, it did buy it and then failed to consume). It does look to be avoiding B items but it seems to have lost functionality on the way there.

Presuming there are no undocumented features in Theraze's beta version...

As a general rule KoLmafia will acquire an item from the mall if it believes the cost of the item is less than the mall price of the ingredients. In this case mafia apparently believes that if you sell your pumpkin and buy a pie you will have more meat than if you just buy a pie. This concept bedevils users and would be optimizers and there is really no good solution. The best one has been to treat items in inventory as if they had a sale price of zero. That usually means the inventory will be consumed. I can't remember whether EatDrink has a similar option or not. I personally find it too dangerous to consider enabling so have not even looked to see whether one is there in EatDrink. YMMV.

The purchase and failure to consume is part of Theraze's new feature set. Thank you for helping to test it. I can't explain the choice of wads without more data but since EatDrink is not computing an optimal solution in the Linear/Integer Programming sense, I have seen cases in the current official version where it grabs the best item and is left with consuming a bunch of crappy items and the yield is worse than if it just went for multiples of the second best item. So you may be seeing something that is an artifact of the fact that what EatDrink computes is "good enough" and not mathematically optimal.

All that being the case, if the current and beta versions give different consumption plans there may be something for Theraze to look at.
 
Basically, regarding the prismatic wads thing, what it's trying to do is generate the most 'value' for you. Value is based on whatever you've set your VALUE_OF_ADVENTURE as, using Mafia preferences. If you've set this (too) high, it will decide that some crazy food will best generate value for you. If you set your value of stats too high, then something else may actually become preferred over something which gives more adventures, as opposed to just redirecting based on best-stat for your decision. And after all of your calculation is done, if the mall is available to you, it starts comparing your price to create to the mall, and generally finds it cheaper to just buy. Apparently mallprice doesn't (currently) update when you purchase (despite what the command and wiki say), which causes problems if your flexibility is turned too low.

Checking the mall right now, there's 30+ entries on prismatic wads for under 6000 meat... the 30th one is at 5999. No clue why your purchase at 6125 failed...
Looking at the mall, pumpkins go for ~10k, pies go for ~17k... No clue on that one. Would really have needed to see the gCLI output saying what it was trying to do, and maybe more.

Anyways, time for me to start to prep my day. Still haven't gotten to take my turns for this rollover, so hopefully I'll get to start cleaning up the KLP and TPS bits soonish, and consider the best way to do the iteration bits... maybe give it a failure-count and give it up to 5 or 10 potential runs per iteration before it quits.
 
Only managed to get one lime with two zaps, but it's now working like this...
Now, to recap...
******************************************
Starting EatDrink.ash (version 3.1.3).
Consuming up to 15 food, 19 booze, and 15 spleen
Considering food from inventory Hagnk's NPCs . Per-item budget cap is 12500.0.
Price will be a factor if you own it already. Hagnk's pulls (if enabled) will cost 3000 meat each.
An adventure has the value of 500 meat. Muscle subpoint is 10.0. Nonprime stat subpoint is 2.0. Hagnk pulls are limited and their 'cost' is incorporated.
food: At 2, consuming to 15.
1: spaghetti with Skullheads lev:6 gain:6.0 adv:25.0 musc:49.5 myst:0.0 mox:0.0 meat:3300 own:0 value:1615
2: Genalen™ Bottle lev:10 gain:1.0 adv:3.0 musc:22.5 myst:22.5 mox:0.0 meat:170 own:0 value:1600
3: Jarlsberg's key lime pie lev:6 gain:4.0 adv:15.0 musc:0.0 myst:30.5 mox:0.0 meat:1255 own:1 value:1576
food: At 13, consuming to 15.
1: handful of walnuts lev:10 gain:1.0 adv:3.0 musc:0.0 myst:0.0 mox:25.0 meat:146 own:3 value:1404
2: handful of walnuts lev:10 gain:1.0 adv:3.0 musc:0.0 myst:0.0 mox:25.0 meat:146 own:3 value:1404
spleen: At 1, consuming to 15.
Best find was none with a value of 0. That's no good, so not consuming and moving on.
Finished.
Spent 80 meat. Gained Fullness: 13. Inebriety: 0. Spleen: 0.
Adventures: 47. Muscle: 74. Moxie: 44. Mysticality: 48.
Eating, drinking, and spleening complete. Commence merrymaking (at your own discretion).
Repeat sims aren't accurate yet... it was expecting to use the Genalen bottle twice, but at least it's better about actual use now. :) I'll repost either when people want to be testing wildly, or when I fix the simulation. I know what the problem is there... it's wiping the used item listing and starting over... but I'm not sure what the best way is of avoiding that, and still allowing for a full consideration of possibilities. Maybe keeping the consumption stack if it's the same iteration and we're simulating.

Edit: For those interested: Guess it's time to add TPS and Key detection to the have_ingredient bit to tell it that it can keep making more and more. Shame... I wanted it to be portable for people who wanted to check ingredients for other things. Ah well. Current problem is that it thinks it can use the limes for each of the pies... it does properly detect one usage per, but fails in the multi-usage side...

Edit2: Horrendously messy in the lines, but here's what we've got:
Now, to recap...
******************************************
Starting EatDrink.ash (version 3.1.3).
Consuming up to 30 food, 0 booze, and 15 spleen
Considering food from inventory Hagnk's NPCs . Per-item budget cap is 12500.0.
Price will be a factor if you own it already. Hagnk's pulls (if enabled) will cost 3000 meat each.
An adventure has the value of 500 meat. Moxie subpoint is 10.0. Nonprime stat subpoint is 2.0.
Simulating only; no purchases or food/drink/spleen consumption.
food: At 0, consuming to 30.
1: Sneaky Pete's key lime pie lev:6 gain:4.0 adv:15.0 musc:0.0 myst:0.0 mox:30.5 meat:1255 own:1 value:1637
food: At 4, consuming to 30.
1: Sneaky Pete's key lime pie lev:6 gain:4.0 adv:15.0 musc:0.0 myst:0.0 mox:30.5 meat:1255 own:1 value:1637
food: At 8, consuming to 30.
1: Sneaky Pete's key lime pie lev:6 gain:4.0 adv:15.0 musc:0.0 myst:0.0 mox:30.5 meat:1255 own:1 value:1637
food: At 12, consuming to 30.
1: handful of walnuts lev:10 gain:1.0 adv:3.0 musc:0.0 myst:0.0 mox:25.0 meat:146 own:0 value:1604
2: handful of walnuts lev:10 gain:1.0 adv:3.0 musc:0.0 myst:0.0 mox:25.0 meat:146 own:0 value:1604
3: handful of walnuts lev:10 gain:1.0 adv:3.0 musc:0.0 myst:0.0 mox:25.0 meat:146 own:0 value:1604
4: nutty organic salad lev:11 gain:3.0 adv:13.5 musc:0.0 myst:35.5 mox:0.0 meat:2300 own:0 value:1507
5: nutty organic salad lev:11 gain:3.0 adv:13.5 musc:0.0 myst:35.5 mox:0.0 meat:2300 own:0 value:1507
6: nutty organic salad lev:11 gain:3.0 adv:13.5 musc:0.0 myst:35.5 mox:0.0 meat:2300 own:0 value:1507
7: Genalen™ Bottle lev:10 gain:1.0 adv:3.0 musc:22.5 myst:22.5 mox:0.0 meat:170 own:15 value:1420
8: Genalen™ Bottle lev:10 gain:1.0 adv:3.0 musc:22.5 myst:22.5 mox:0.0 meat:170 own:15 value:1420
9: Genalen™ Bottle lev:10 gain:1.0 adv:3.0 musc:22.5 myst:22.5 mox:0.0 meat:170 own:15 value:1420
10: Genalen™ Bottle lev:10 gain:1.0 adv:3.0 musc:22.5 myst:22.5 mox:0.0 meat:170 own:15 value:1420
11: Genalen™ Bottle lev:10 gain:1.0 adv:3.0 musc:22.5 myst:22.5 mox:0.0 meat:170 own:15 value:1420
12: Genalen™ Bottle lev:10 gain:1.0 adv:3.0 musc:22.5 myst:22.5 mox:0.0 meat:170 own:15 value:1420
spleen: At 0, consuming to 15.
Best find was none with a value of 0. That's no good, so not consuming and moving on.
Finished.
Spent 230 meat for a value of 12123 meat. Gained Fullness: 30. Inebriety: 0. Spleen: 0.
Adventures: 112. Muscle: 132. Moxie: 165. Mysticality: 237.
Eating, drinking, and spleening complete. Commence merrymaking (at your own discretion).


> inv lime

lime (3)
...and... proper counting. Don't mind the fact that it's trying to go to 30 consumption... I was just trying to validate that it wasn't sneaking a Boris's KLP in there somewhere. :) So, the attached version here should properly allow for KLP and TPS, as well as being a bit smarter regarding ingredients and creation in general.

Sidenote - script hasn't changed since 2 hours ago: Recreated the add_ingredients function to make it more properly consider the effects of ingredients. With this function in its current form, it actually started realizing that it needs to consider the effects of the added item properly. Which is odd, as it was supposed to consider it already... Anyways, so it goes.
 
Last edited:
Here's a version I whipped together that should restart the stack if it fails to acquire, instead of forcing you to run it again. Updated to also restart the stack if it fails to consume... and an example from today:
Now, to recap...
******************************************
Starting EatDrink.ash (version 3.1.3).
Consuming up to 15 food, 19 booze, and 15 spleen
Considering food from inventory Hagnk's NPCs . Per-item budget cap is 12500.0.
Price will be a factor if you own it already. Hagnk's pulls (if enabled) will cost 3000 meat each.
An adventure has the value of 500 meat. Muscle subpoint is 10.0. Nonprime stat subpoint is 2.0. Hagnk pulls are limited and their 'cost' is incorporated.
food: At 1, consuming to 15.
1: Sneaky Pete's key lime pie lev:6 gain:4.0 adv:15.0 musc:0.0 myst:0.0 mox:30.5 meat:1255 own:1 value:1576
food: At 5, consuming to 15.
1: Sneaky Pete's key lime pie lev:6 gain:4.0 adv:15.0 musc:0.0 myst:0.0 mox:30.5 meat:1255 own:1 value:1576
food: At 9, consuming to 15.
1: Sneaky Pete's key lime pie lev:6 gain:4.0 adv:15.0 musc:0.0 myst:0.0 mox:30.5 meat:1255 own:1 value:1576
food: At 13, consuming to 15.
1: unidentified jerky lev:9 gain:2.0 adv:6.0 musc:12.5 myst:12.5 mox:12.5 meat:180 own:3 value:1497
Finished.
Spent 240 meat. Gained Fullness: 14. Inebriety: 0. Spleen: 0.
Adventures: 51. Muscle: 14. Moxie: 108. Mysticality: 13.
Eating, drinking, and spleening complete. Commence merrymaking (at your own discretion).
 
Last edited:
Still would not make a pumpkin pie, instead it looped failing to purchase them and then trying again. Once I exited out and used the command "Make pumpkin pie" and ran it again it wasted meat buying four more pumpkin pies. I'm reverting back to the old version that often gave me similar amounts of adventures for far less meat.
 
Still would not make a pumpkin pie, instead it looped failing to purchase them and then trying again. Once I exited out and used the command "Make pumpkin pie" and ran it again it wasted meat buying four more pumpkin pies. I'm reverting back to the old version that often gave me similar amounts of adventures for far less meat.
In cases where it's not behaving right, we'd need to try to figure out why. If you feel like working through it, we can see what we can do. Otherwise, unless someone else has similar behaviour happen, fixing it will need to wait until someone else has it happen. There's the possibility that your EAT_MAKE is off or something similar, but... *shrugs*
 
Latest beta - no concerns with character #1. Character #2 consumed 15 fortune cookies but I think that was reasonable under the circumstances. It does make me want to investigate existing options to tell EatDrink not to do that but I'm not prepared to elevate the prevention of that into a special case. I aborted #3 when I was asked if I wanted to eat milk. 3.1.3 obtains and uses the milk as desired. I wasn't thinking and as a consequence missed the chance to use the beta with the same character, who has a TPS. I'll make a point of only drinking with the beta tomorrow. I was concerned that there was a message that it was trying to buy a cherry bomb when overdrinking but since it didn't actually succeed it is only the message that is a concern. Thanks.
 
Yeah... HC beecore is tending towards lots of fortune cookies for me so far. If you want to disable buying food from the npc stores, EAT_SHOP = false will make you only purchase from the mall instead of npcs... EAT_MALL is the *shock* mall preference now, defaults to on as EAT_SHOP does, etc.

Eat milk? If it happens again, could you post the log from that? There's little I can do without either information that lets me see what went on, or some way to replicate it myself... Thanks! :)

Best is if you have verbose (at least) on, and post the part above the summary where it's deciding/obtaining/using... that's the part where it says whether it's planning on using the closet, creating, storage, NPCs, or the mall...
 
Last edited:
Back
Top