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

fronobulax

Developer
Staff member
Yeah... let me know what it thought it could make and failed on. If we can hunt down why it has an incorrect belief, that will help.

Code:
> Starting EatDrink.ash (version 3.1.5).<br>Consuming up to 15 food, 19 booze, and 15 spleen and then finishing off with the stiffest drink we can find.<br>Considering food from inventory Coinmasters NPCs. Per-item budget cap is 25000.0.<br>Retrieval cap is 20000. Price will be a factor if you own it already.<br>An adventure has the value of <b>500 meat</b>. Muscle subpoint is 10.0. Nonprime stat subpoint is 2.0.<br>spleen: At 11, consuming to 15 with 10000 meat.<br>At drunkenness of 19. Overdrinking with 10000 meat.<br>EatDrink encountered an error: You don't have 1 Gordon Bennett and you're not able to shop.<br>Finished. <br>Spent 0 meat. Gained Fullness: 0. Inebriety: 0. Spleen: 0.Adventures: 0. Muscle: 0. Moxie: 0. Mysticality: 0.<br>Eating, drinking, and spleening complete. Commence merrymaking (at your own discretion).<br>
 > Skipping favorites.
 > You're in ronin, so no shopping for you.
> Starting EatDrink.ash (version 3.1.5).
> Consuming up to 15 food, 19 booze, and 15 spleen and then finishing off with the stiffest drink we can find.
> Considering food from inventory Coinmasters NPCs. Per-item budget cap is 25000.0.
> Retrieval cap is 20000. Price will be a factor if you own it already.
> An adventure has the value of <b>500 meat</b>. Muscle subpoint is 10.0. Nonprime stat subpoint is 2.0.
 > Pass 1: food.
 > Skipping food.
 > Pass 2: drink.
 > Skipping drink.
 > Pass 3: spleen.
> spleen: At 11, consuming to 15 with 10000 meat.
 > No spleen available that's good enough. Found 0 items first. Moving on.
 > Pass 4: drink.
> At drunkenness of 19. Overdrinking with 10000 meat.
 > Getting 1 Gordon Bennett in 3 seconds
> EatDrink encountered an error: You don't have 1 Gordon Bennett and you're not able to shop.
 > Something went wrong with getting Gordon Bennett for 160. Recalculating.
> Finished. 
> Spent 0 meat. Gained Fullness: 0. Inebriety: 0. Spleen: 0.Adventures: 0. Muscle: 0. Moxie: 0. Mysticality: 0.
> Eating, drinking, and spleening complete. Commence merrymaking (at your own discretion).
> ******************************************
> Now, to recap...
> ******************************************

I would have expected it to try something else when it couldn't get a Gordon Bennett. I manually made and consumed an ocean motion and I certainly hope my settings are not set so that it thinks those are too inefficient to consume.
 

Theraze

Active member
Hmm... I think overdrinking, uniquely, stops when it fails, because it's already the last step. I'll look into that.

Also, for some reason, we're now having EatDrink suggest impossible items. It suggested a fuzzbump yesterday when I was in run, didn't have any available, nor the mixer... it failed and moved on in that case, but it shouldn't have suggested it. It shouldn't have suggested the Gordon Bennett if you couldn't make it.

Both issues need to be resolved... overdrinking aborting and incorrect item suggesting.
 

Theraze

Active member
Okay, think I have both of the problems fixed. The reason it suggested the Gordon Bennett is that the current daily special was the mimosette, which is what mixes to make the GB. However, you can't mix daily specials, so it shouldn't have been considering them. This is fixed in the current attached version.
Second problem, with not trying another overdrink option is because the loop was only set for iteration < 4. The new check is iteration < 4 && !repeatingstep. So if you're in overdrink and it fails for some reason, it should give it another shot. This MIGHT make it attempt to overdrink twice if your OD is a TPS drink. Should be fast in eliminating everything though, since you're already above the limit, so nothing will fit into your liver. Anyways, both fixes in the attached version.
One more tweak, for speed. Instead of comparing VOA to /20 (as it originally was) causing 10 or 11 comparisons, or VOA / 10 (as it was in 1333 and before) which does 5-6 comparisons, trying VOA /9, which should only do 5 comparisons and not need to think about randomness too much. Not sure if this is needed, since with the daily special bug fixed, it's been significantly better for execution time, but... we'll see what we want to do eventually. :)
Anyways, it's changelogging time!

Changelog:
Implemented:
1069: Coinmaster (besides hermit) handling - Using lowest of the two prices, with a custom override for the hermit to set the value of his items at the price of a permit (if needed) and the cost of acquiring a worthless item - using retrieve_item on tokens, so it should decide if it's cheaper for buying directly from the mall or using the coinmaster.
1205: Fixed mojo filter infinite loop.
1226: Removed the verbose and verbose2 functions, replacing them with a vprint3 and vprint9. Items that were always printing before are still using logprint, print, or print_html as appropriate.
1259: Finally implemented the GET_BARTENDER and GET_CHEF bits. These have (of longstanding) been set by EatDrink to default to false, but never (that I could find) did anything. Now they will get you a bartender or chef and install them if have_bartender/chef returns false and you have them set to true, while the item retrieval happens.
1260: Fixed another mojo filter loop.
1281: Better torso awaregness. Explicitly check for the skill, since mafia doesn't (as of 10216). Note that mafia does check as of 10220, but the explicit check won't hurt and helps keep people using out of date mafia for some reason running properly.
1298: Skip items which fill multiple organs - while it may be optimal on one, it's unlikely to be optimal to both.
1303: Removed legacy hermit code, since the new coinmaster code properly purchases from him as well as potentially from other coinmasters.
1310: Implemented initial daily special code. Uses working special code now... should be fully working, but need someone to have this trigger again.
1314: Made "the mall" display the same whether simulating or actually consuming. This might speed up simulating executions for some people.
1316: Added the acquisition of chocolates to the chocolate consumption code, so it should properly use them if you're actually in that budget range.
1316: Made the script recalculate what to consume if either a consumption fails or mojo filters are used, since either is likely to affect how much room is left to fill.
1332: Changed which flag gets set when mojo filters are used, so that it will actually consume TPS drinks and KLP food.
1332: Made the script recalculate its nightcap if it fails for some reason.
1339: Fixed an issue caused by adding daily specials. They can't be used as ingredients in other items, so don't try.
 

Attachments

  • EatDrink.ash
    92 KB · Views: 72

Ioeth

Member
Drunki-bears? Really?

EatDrink is a great script, and most of the time it works really well for me. Usually it feeds me lo-meins and TPS drinks when I call it directly or when it's called from Harvest. Sometimes, though, it gets everything completely wrong, feeding me things like drunki-bears and lemons and drinking AC drinks. I've the session log of the last time this happened, which was today, for review. Please have a look and let me know if it's something I'm doing or a configuration setting that might be wrong.
 

Attachments

  • session_20120127.txt
    10 KB · Views: 50

Theraze

Active member
Not a problem. At some point soon, it'll get an official new release, but we're waiting for it to not do bad things to fronobulax first. :) But yes, the drunki-bears were first reported as a problem back on post 1298 and patched soon after. Though looking at them, it's not that bad for adventures... and if it actually gave bonuses based on both ode AND milk, would be better than most anything else you had in your log. Wonder if anyone's tried that. Heh.

Edit: Ah, wiki says that milk gives turns, ode doesn't. Shame... with those extra 4 adventures, it would be even more epic. Ah well. Though apparently it can be used for truly epic overdrinks, since it can be consumed while overdrunk already.
 

roippi

Developer
Using the above latest version, I've been stymied at making eatdrink conform to a budget in (post-prism) simulation.

Code:
******************************************
Now, to recap...
******************************************
Starting EatDrink.ash (version 3.1.5).
Consuming up to 15 food, 19 booze, and 15 spleen as if you were level 15.
Considering food from inventory Hagnk's Coinmasters NPCs the mall. Per-item budget cap is 50000.0.
Retrieval cap is 50000. Price will be a factor if you own it already.
An adventure has the value of 1200 meat. Moxie subpoint is 0.0. Nonprime stat subpoint is 0.0.
Simulating only; no purchases or food/drink/spleen consumption.
drink: At 0, consuming to 19 with 10000 meat.
0: Ode to Booze price: 0 value: 22800
1: Wrecked Generator lev:5 gain:5.0 adv:30.0 musc:25.0 myst:25.0 mox:25.0 meat:16900 own:103 value:3820
2: Wrecked Generator lev:5 gain:5.0 adv:30.0 musc:25.0 myst:25.0 mox:25.0 meat:16900 own:103 value:3820
3: Wrecked Generator lev:5 gain:5.0 adv:30.0 musc:25.0 myst:25.0 mox:25.0 meat:16900 own:103 value:3820
4: Go-Wassail lev:1 gain:1.0 adv:5.5 musc:5.5 myst:5.5 mox:5.5 meat:2823 own:5 value:3777
5: Go-Wassail lev:1 gain:1.0 adv:5.5 musc:5.5 myst:5.5 mox:5.5 meat:2823 own:5 value:3777
6: Go-Wassail lev:1 gain:1.0 adv:5.5 musc:5.5 myst:5.5 mox:5.5 meat:2823 own:5 value:3777
7: Go-Wassail lev:1 gain:1.0 adv:5.5 musc:5.5 myst:5.5 mox:5.5 meat:2823 own:5 value:3777
spleen: At 0, consuming to 15 with 10000 meat.
1: agua de vida lev:4 gain:4.0 adv:7.5 musc:0.0 myst:0.0 mox:0.0 meat:3700 own:68 value:1325
2: agua de vida lev:4 gain:4.0 adv:7.5 musc:0.0 myst:0.0 mox:0.0 meat:3700 own:68 value:1325
3: agua de vida lev:4 gain:4.0 adv:7.5 musc:0.0 myst:0.0 mox:0.0 meat:3700 own:68 value:1325
4: twinkly wad lev:6 gain:1.0 adv:1.0 musc:9.0 myst:9.0 mox:9.0 meat:398 own:0 value:802
5: twinkly wad lev:6 gain:1.0 adv:1.0 musc:9.0 myst:9.0 mox:9.0 meat:398 own:0 value:802
6: twinkly wad lev:6 gain:1.0 adv:1.0 musc:9.0 myst:9.0 mox:9.0 meat:398 own:0 value:802
choc: Checking non-filling crimbo chocolates - all 3 kinds
Best find was chocolate stolen accordion with a value of -500. That's no good, so not consuming and moving on.
Finished. You had Milk of Magnesium in effect. Adventures listed above does not reflect that, but this does:
Spent 1194 meat for a value of 74286 meat. Gained Fullness: 0. Inebriety: 19. Spleen: 15.
Adventures: 156. Muscle: 122. Moxie: 122. Mysticality: 122.
Eating, drinking, and spleening complete. Commence merrymaking (at your own discretion).

Wrecked Generators cost 17k meat, as above. eatdrink_stepMeat is only at 10k; I usually have it at 30k but bumped it down for demonstrative purposes.

Even after reducing eatdrink_budget down to 20k, eatdrink thinks it can go ahead and drink with no budget. Frustrating.

Also, If I reduce eatdrink_price_flexibility down to, say, 0.1, eatdrink will tell me that the "Per-item budget cap is 5000." It still tries to acquire wrecked generators. Now, here I know that I'm using price flexibility in a way it's not really supposed to be used, so I don't mind this one so much. It just seems like I have so many possible dials to turn to try to make eatdrink work on a budget, and few actually work. valueOfAdventure seems to be my only method of tweaking eatdrink's meat consumption, and it is a coarse one: VoA at 1100 suggests boilermakers, VoA at 1200 suggests wrecked generators. autoBuyPriceLimit is USUALLY a good safety valve, but in this case I had isotopes on hand, so no meat was expended, thus it went ahead and consumed ~50k worth of drinks.
 

Theraze

Active member
Well, budget is the highest value for a single item while stepMeat is the total allowed to be spent. What you should do is set budget to something less than the amount of the highest single item value... if it's in your inventory already, stepMeat doesn't come into it. The "own:103" means that after using 3 generators, you still have 103 of them left...

If that makes sense. You've valued adventures at 1200 meat, so 30*1200=36000 meat -16900 value in the mall = 19100 value, divided by 5 (how much it hits your liver), gives a 'value' of 3820. Which is exactly what it shows, and why it prefers that (with 6 adventures per liver) to go-wassail (with 5.5 adventures per liver).

I can math more if you like, but basically, if you don't want it to use them, either drop your value of adventure if it's inflated above what you're actually earning, set your single-item budget lower, or closet the items you'd like to protect. Any of those would help.
 

Theraze

Active member
Nope. Because stepMeat was initially my personal tweak to keep you from spending meat. It's similar to closetting your meat. Not similar to closetting your items. As I said, budget is how you protect expensive items.
 

roippi

Developer
I see now. It's just that.. well, okay, maybe I'm asking the wrong question here. In aftercore, I don't care about protecting my expensive items; I value items I possess at exactly their mall value in meat. How do I tell eatdrink not to consume more than x meat worth of items?

Setting a per-item budget is actually counterproductive - it just forces eatdrink to use 1- or 2- full/drunk items, which ends up being more net meat expenditure.
 

Theraze

Active member
Well, either you're telling the truth with your VOA or you aren't. If you REALLY want to claim you have a higher value than you actually have, and you don't want to avoid expensive items, then EatDrink might not be the best script for you. For example, heeheehee has consumption.ash which has always suggested cheaper items for me than EatDrink, though generally it's grabbed cheaper items. For example, with a 1200 VOA, it returns this:
> sconsume 1200

You should use milk of magnesium.
hot hi mein (3)
Ode is cheap. You should use it.
Crimbojito (7)
Wrecked Generator (1)
Mojo filters taken into account.
agua de vida (3)
twinkly wad (3)
~90 adventures from food, 129.5 adventures from drink, and 25.5 adventures from spleen. That gives a total of 245 adventures, of which 155 adventures match up with what you give above, instead of the 156 you got above. Compare value on alcohol, since spleen bits are the same:
7*crimbojito(4150)=29050
1*wrecked(100*166)=16600
Total: 45650

3*wrecked(3*100*166)=49800
3*go-wassail(3*2823)=8469
Total: 58269

The EatDrink averages to 131 adventures from drink. I'd hold that the adventure difference and value in the consumption script having some different check for value than EatDrink, but... it'd save you a bit of meat.
 
Last edited:

Theraze

Active member
Welcome. I think at the moment, it appears to be pretty much stable and able to consider most of the food in the world. Remaining on my to-do list are virtual items... the IPA, bouillabaise, and Crimbo offerings, mainly... Day one, the bouillabaise has a fair chance of being better than, well, mugcakes, at least. Since it's an average of 7 adventures for the same 100 meat instead of 5. How often would it get used otherwise? Not much. But during Crimbo shop time, maybe... anyways, that's what I know about for future goals. Anything else that's actually potentially scriptable?
 

roippi

Developer
Well, either you're telling the truth with your VOA or you aren't.

Well, here is probably the main issue. I understand how VOA works, I really do. I understand why it works as a straightforward parameter for optimization. But really it's one step abstracted from the question I want to be asking. VOA asks "if I value an adventure at x, tell me the most adventures I can get under that restraint." Or something close to that. But really in my mind the question is "here is a pile of y meat. Get the most adventures you can with that."

Now, that is a more difficult optimization to do, since there's an extra degree of freedom inherent in the problem. I wouldn't know how to go about solving that outside of writing some MATLAB code, so I don't begrudge eatdrink going the VOA route. But the VOA solution can be volatile: imagine a new drink is released that gives 20 adventures, fills 1 drunk, and costs 20k in the mall. Extreme example, but bear with me, it's for illustrative purposes. Eatdrink would readily consume 19 of those for any diet at 1000 VOA or above. Almost 400k out of pocket unless one of the safety valves (autoBuyPriceLimit, maybe stepMeat?) catches it in time. As we can see with wrecked generators, those safety valves aren't necessarily foolproof even if they're set properly.

I dunno, I realize my recent posts can come off as whiny or confrontational, and that's not what I'm going for at all. Anecdote: I'd been successfully running eatdrink for over a year, and took a two-month break from KoL sometime before crimbo. I'd found a sweet spot in VOA (somewhere around 1600 IIRC) that was allowing me to drink SHCs in aftercore. Now I come back to find that even if I drop VOA down to 1200, eatdrink is still spending 73k on drinks, which is over double my old budget. Dropping it to 1000 has it drinking boilermakers, spending 11.5k. This illustrates my frustration with VOA: the granularity between proximate VOAs can be quite enormous.

If the final answer is "well, eatdrink is not for you," I can live with that, I suppose. I still love to use it while ascending.
 

Theraze

Active member
Both safety valves would stop it, since by default EatDrink is only allowed to spend 10k total per step, so it wouldn't even buy one. If you purchased 19 yourself first, it would happily use them though, since 20000 is the default limit for a single item through the 'budget' variable.

However, your initial logic is (slightly) flawed. 20 adventures at 1000 VOA is worth 20000. If it costs 20000 to buy, it has a 'value' of 0. It wouldn't be used even if it were the only thing in your inventory, until the price of the fifth cheapest drops (at initial price-check time) below 20k.

Personally, I'm running EatDrink with a budget, stepMeat, and autoBuyPriceLimit of 10000. That means that no single item will be considered if it costs more than 10k, it can't spend more than 40k total (plus milk/ode) for the entire day, and mafia will allow it to buy a bucket of wine for overdrinking if it works out. With these settings, I have VOA currently set to 1250. During run, it happily makes SHC and drinks them. During aftercore, it usually goes for tuxedo drinks at a value of something over 4k, but its favourite item for me right now is Gin-Mint, at a value of over 5k at 5.75 adventures per liver and a cost of ~4710 each (peppermint twist, bottle of gin) for 2 liver.
Starting EatDrink.ash (version 3.1.6).
Consuming up to 15 food, 19 booze, and 15 spleen
Considering food from inventory Hagnk's Coinmasters NPCs the mall. Per-item budget cap is 12500.0.
Retrieval cap is 10000. Price will be a factor if you own it already.
An adventure has the value of 1250 meat. Moxie subpoint is 10.0. Nonprime stat subpoint is 2.0.
drink: At 0, consuming to 19 with 20000 meat.
0: Ode to Booze price: 0 value: 23750
1: Gin Mint lev:2 gain:2.0 adv:11.5 musc:15.0 myst:15.0 mox:37.5 meat:4175 own:0 value:5317
2: Gin Mint lev:2 gain:2.0 adv:11.5 musc:15.0 myst:15.0 mox:37.5 meat:4175 own:0 value:5317
3: Gin Mint lev:2 gain:2.0 adv:11.5 musc:15.0 myst:15.0 mox:37.5 meat:4175 own:0 value:5317
4: Gin Mint lev:2 gain:2.0 adv:11.5 musc:15.0 myst:15.0 mox:37.5 meat:4175 own:0 value:5317
5: Go-Wassail lev:1 gain:1.0 adv:5.5 musc:5.5 myst:5.5 mox:5.5 meat:2800 own:0 value:4152
6: rockin' wagon lev:4 gain:4.0 adv:12.0 musc:0.0 myst:0.0 mox:35.0 meat:1570 own:6 value:4070
7: rockin' wagon lev:4 gain:4.0 adv:12.0 musc:0.0 myst:0.0 mox:35.0 meat:1570 own:6 value:4070
8: shot of peach schnapps lev:8 gain:2.0 adv:6.0 musc:0.0 myst:0.0 mox:17.0 meat:370 own:17336 value:3650
choc: Checking non-filling crimbo chocolates - all 3 kinds
Best find was chocolate stolen accordion with a value of -600. That's no good, so not consuming and moving on.
Finished. You had -Ode to Booze in effect. Adventures listed above does not reflect that, but this does:
Spent 22010 meat. Gained Fullness: 0. Inebriety: 19. Spleen: 0.
Adventures: 106. Muscle: 63. Moxie: 268. Mysticality: 49.
Eating, drinking, and spleening complete. Commence merrymaking (at your own discretion).
This is after having eaten, spleened, and enjoyed my one chocolate so far today, which cost 26203 meat for 103 more adventures, but we were comparing the drinks not the other bits. So 209 adventures for under 50k... 36 adventures less than the consumption script would have given me, but at a similar cost for my entire diet to what it would have done for just alcohol.

If you can come up with a great way for me to limit in a way that works for you without causing problems for other people, let me know, but from my testing, it's possible to tweak the VOA, budget, aBPL, and stepMeat values to create a diet that will meet just about any need. I'd suggest dropping budget to 15000 and just seeing what happens, to start.
 

Theraze

Active member
Oops... the overdrink 'fix' actually was backwards, so it made it abort completely if anything failed, instead of making it continue if overdrink failed. Bah. Anyways, updated version of 3.1.6 attached.

Changelog:
Implemented:
1358: Fixed a bug caused trying to solve overdrinking unavailable items.
 

Attachments

  • EatDrink.ash
    92 KB · Views: 57

fronobulax

Developer
Staff member
Oops... the overdrink 'fix' actually was backwards, so it made it abort completely if anything failed, instead of making it continue if overdrink failed. Bah. Anyways, updated version of 3.1.6 attached.

Changelog:
Implemented:
1358: Fixed a bug caused trying to solve overdrinking unavailable items.

Released as 3.1.7 since we all know how I feel about changing code without changing version labels. I have not personally tested this so I'm sure hoping it works :)
 

fronobulax

Developer
Staff member
There have been ongoing discussions rooted in the difference between what people think ED should do and what it actually does. I have great difficulty describing the existing ED in mathematical terms but I would try and describe it in terms of maximizing profit when an adventure is valued at VOA. What this means is that if ED can spend VOA more and get one more adventure then it will do so. This is complicated and constrained by various attempts to restrict amounts being spent, valuing inventory and so on.

Mathematically, this is NOT the constrained optimization problem which can simplistically be stated as generate the maximum number of adventures possible subject to various constraints of which the meat budget is probably the most important. Note that problem could be solved without even referencing VOA.

So ED is what it is and it is not something that solves a constrained optimization problem no matter what people want, say or think.

I spent some time formulating the consumption problem as a real optimization problem. It can be done. To solve it requires Linear Programming, in general, and almost certainly Integer Programming in particular. There are libraries for solving such things but embedding one in KoLmafia, formatting the problem and submitting it to a URL or other external solver (and waiting for an answer) or writing one in ASH are all a lot of work and each has their drawbacks. If anyone is serious enough about this to commit at least 40 hours over a couple of months to collaborate with me, I'll be glad to revisit this and take it on. It will be easiest for my if collaborators have at least had college level Linear Algebra which was usually taken by sophomore engineering and math majors back when I took and taught it.

Someone here, I think heeheehee but I apologize in advance for not remembering the name or successfully finding relavent posts, has considered the consumption problem as a knapsack problem. Maximize the number of adventures generated by consuming to a particular fullness (fill the knapsack) and then swap out items for items that generate the same fullness and number of adventures but cost less than something already in the knapsack. Repeat until no swaps are possible and consume. But that is not the constrained optimization problem I have in mind either.

In the the absence of major effort spent on constrained optimization or the knapsack approach, there are two initiatives that might be considered. The first would be to document EDs parameters. I firmly believe that if an effort were made to do so, a number of them could be eliminated and the remainder could be explained so that people could have an intuitive understanding of what ED does. The second would be to make sure that simulation mode really was "good enough" and then do parametric analysis using VOA as one of the variables. The issue here is that I insisted (and I stand by my decision, for the moment anyway) that ED take advantage of KoLmafia features and parameters and as a result, it is difficult for ED to actually know what something is going to cost.
 
Top