Feature - Implemented int retrieve_cost(item) function to get the meat required to acquire the supplied item

Malibu Stacey

Active member
Currently if you use acquire on the cli or the retrive_item/retrieveItem functions they do a bunch of mall checks and calculate the cheapest way to acquire the supplied item e.g.


Code:
ash retrieve_item(20, $item[moreltini])

Searching for "bottle of gin"...
Search complete.
Searching for "fermenting powder"...
Search complete.
Searching for "juniper berries"...
Search complete.
Searching for "shroomtini"...
Search complete.
Searching for "bottle of gin"...
Search complete.
Searching for "fermenting powder"...
Search complete.
Searching for "juniper berries"...
Search complete.
Searching for "cocktail mushroom"...
Search complete.
Searching for "moreltini"...
Search complete.
Searching for "shroomtini"...
Search complete.
Searching for "bottle of gin"...
Search complete.
Searching for "fermenting powder"...
Search complete.
Searching for "juniper berries"...
Search complete.
Searching for "cocktail mushroom"...
Search complete.
Searching for "olive"...
Search complete.
Using cached search results for moreltini...
Purchasing moreltini (20 @ 750 = 15,000) from #892618...
Purchases complete.

It's calculated that buying at 750 meat from @reverkiller 's store is currently cheaper than crafting from shroomtini's or cocktail mushrooms ([edit] I should say this is not always the case as Rever intentionally dumped a bunch of low priced ones in his store today, most days when I do this it will craft them depending on the price of the ingredients to get them as cheaply as possible). As a person who writes scripts which care about item costs it would be very useful if that calculated value was accessible as it's a much more accurate value for the cost to acquire the item in question than the value returned by mall_price/mallPrice or historical_price/historicalPrice.

Thanks.
 
Last edited:

Veracity

Developer
Staff member
mall_price() gives you the cost to acquire the fifth cheapest item. In order to make mallbots less effective (without customizing KoLmafia code for yourself), we intentionally do not allow access to the cheapest price of an item in the mall.

Your proposal provides exactly that functionality, if given an item that does not require crafting.

Nope.
 
Would it be possible to reveal the 5th cheapest price to needed to create the item? I feel like there must be a way to provide a separate retrieval price from mall price without opening the floodgates to mallbots.
 
The problem I am interested in solving is how Mafia decides if it is going to craft an item vs. buy one at an arbitrary, not what price point it would use to do it cheaply right now. I would be more than happy with a solution that used the mall_price of the components so I didn't have to implement something to search through crafting recipes. If that is out of the question, I can write my own version of "retrieve_item_cost" that does what I describe, with mall_cost as the price for each component, but it seemed a bit wasteful to try and do this when mafia is already doing the legwork.
 

Rinn

Developer
I think this is just what InventoryManager.priceToAcquire() returns already and could be exposed as an ash func?
 

Rinn

Developer
Yeah I think this is fine, it's using the mall value from StoreManager.getMallPrice() internally just like the mall_price ash function is. I can make a PR. The only thing that might be a little confusing is the interaction with items being in your inventory already and also it considers valueOfInventory property when calculating the value of things you already have.


Code:
> ash retrieve_price($item[perfect cosmopolitan])

Searching    for "perfect cosmopolitan"...
Search complete.
Searching    for "perfect ice cube"...
Search complete.
Searching for    "bottle of vodka"...
Search complete.
Searching for "bowl    of rye sprouts"...
Search complete.
Returned: 3400

>    ash mall_price($item[perfect cosmopolitan])

Returned: 3400

>    ash (mall_price($item[perfect ice cube]) + mall_price($item[bottle of vodka]))

Returned: 3425

> ash (mall_price($item[perfect ice cube]) +    retrieve_price($item[bottle of vodka]))

Returned: 3425

> ash (mall_price($item[perfect ice cube]) + mall_price($item[bowl of rye sprouts]) + npc_price($item[fermenting powder]))

Returned:    6816

>    ash retrieve_price($item[bottle of vodka])

Returned: 175

>    ash mall_price($item[bottle of vodka])

Returned: 175

>    ashref retrieve_price

int retrieve_price(    item )
int retrieve_price(    item, int )
int retrieve_price(    int, item )
 

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
It sounds like this feature is being reconsidered? I'll unmark it as rejected in any case.
 

Rinn

Developer
r26205. Implemented as retrieve_price, takes the same args as retrieve_item. I recommend setting valueOfInventory to 1.0 so it treats your inventory items as having the same value as buying them.
 

Veracity

Developer
Staff member
Code:
> ash mall_price( $item[ space wine ] )

Searching for "space wine"...
Search complete.
Returned: 4000

> ash retrieve_price( $item[ space wine ] )

Returned: 50
You can buy space wine from Cosmic Ray's Bazaar for 5 rare Meat isotopes. Those are quest items which you can buy from that same Coinmaster for 1000 Meat each. That Coinmaster is available ONLY if you you are in a Kingdom of Exploathing run.

So, you options are to spend 4,000 Meat in the mall, or create the item using 5 quest items, which you either have in inventory or buy for 1,000 each.

How is it possible that the cost to acquire (the fifth of this item) would be 50?
Especially when not in Kingdom of Exploathing, so the Coinmaster (i.e., the creation method) is not available?

Edit: I notice that the autosell price for space wine is 50 Meat. Huh.
Edit 2: And I have 2 in inventory.
 
Last edited:

Rinn

Developer
I was wrong about valueOfInventory, if it's 1.0 or less it uses the autosell price, it only checks the mall if it's greater than 1 and then subtracts 1 from valueOfInventory before using it as a multiplier, so unintuitively it has to be set to 2.0 to match the mall price. I'm not sure why the code was written that way but it's very confusing.
 

Veracity

Developer
Staff member
Whoah. And there is a bug in priceToAcquire.

If you ask for 5 and it has three in inventory, it will check mall price and make price for the remaining two - and then, if too close, will return priceToAcquire for 2 of the items. In other words, it munges the passed-in "quantity" and then passes in the munged quantity.

I'm working on all of this. Thanks for the valueOfInventory comment. As it turns out, that defaults to 1.8.
 
Top