mall_price Questions

fronobulax

Developer
Staff member
I use mall_price when managing Alice cards and credits. The first time I run the script during a session it clearly is updating prices because it generates lots of "Searching for" and "Search complete' messages. The second time I run the script it appears to be using cached values because the messages are not there and prices displayed by the script do not change even though I have made mall purchases between script invocations which as far as I can tell should change the "fifth lowest price". The wiki description says
This function runs a new check each time it is called, so if you call this function and then purchase some of shop_for in the mall, calling this function again will return the new price of the item
which does not seem to be what is happening for me.

If I log out of KoLmafia and then log back in then I get new prices.

Is the wiki correct? If so then this query will probably lead to a Bug Report.

If the wiki is not correct is there a way to force a refresh/reprice/cache invalidation for one or more items? My preference would be something I could script although I understand that doing so could result in unnecessary server hits. In this particular case I do a manual buy from the Purchases tab. The act of buying does not invalidate the cache, but maybe it should? I would also be glad to buy the items and then refresh the Search after purchases is that would clear the cache.

My hypothesis is that the prices are cached and the cache is not being invalidated and updated after an item is purchased but maybe something else is going on? I also understand that a deliberate decision not to refresh the cache during a session might have been made to prevent mall botting, and I can live with that if it is the case.

I have "Share recent mall price data with other users" checked. Perhaps there is an interaction that I am not grasping?

Bottom line - how can I force mall_price to update for a single item the second time it is called for that item in a session?

Thanks.
 
I see an array being initialized, the mall search function only running if there's no price stored for the item being searched for (as it stores the price in that array), and no place where it might be trying to clear the price from that array. It really looks like it was meant to only search once per session.
 
I see an array being initialized, the mall search function only running if there's no price stored for the item being searched for (as it stores the price in that array), and no place where it might be trying to clear the price from that array. It really looks like it was meant to only search once per session.

Are you looking at Java or at my script? If the former then you would seem to be saying that the wiki is wrong. If the latter then I don't see where StoreCredit or Alice are doing what you have observed. Thanks.
 
As stated by JasonHarper when he added the mall_price() ASH function in r6989:
Adds ASH mall_price(item) function, which returns the approximate price at
which the item can be bought. To prevent abuse, this will only perform an
actual Mall search once per item per session; subsequent calls for the same
item will return a cached value. The cache will be updated after a
successful purchase of the item, but not in any other conditions.
So I guess it's by design.

and no place where it might be trying to clear the price from that array.
There is StoreManager.flushCache(), which seems to remove values of mallSearches. Of course, mallPrices is used to return a value for mall_price(), so that's not really helpful.

EDIT: I updated the Wiki.
 
Last edited:
The cache will be updated after a successful purchase of the item, but not in any other conditions.

Thanks. That does not seem to be happening. Further archeology seems to be warranted.
 
I added the info on the wiki, but I didn't mention r7590, which states:
Cached Mall prices are now updated on purchase attempts even if they are
unsuccessful, so that you can determine the new price after someone has
bought out all the cheap items.
That doesn't really explain why the cache isn't updating after a successful purchase for you. It seems to work for me:
Code:
> ash mall_price( $item[ rave whistle ] );

Returned: 120

> buy 5 rave whistle

Searching for "rave whistle"...
Search complete.
Purchasing rave whistle (3 @ 120)...
You acquire rave whistle (3)
Purchasing rave whistle (2 @ 183)...
You acquire rave whistle (2)
Purchases complete.

> ash mall_price( $item[ rave whistle ] );

Returned: 184
 
Here's an excerpt from my session log. I ran Alice, bought Shieldmaiden and ran Alice again. I used the Purchase tab to buy and know I bought all of the cards available for less than 2501, so the fifth price should be at least that much. There were no sales with limits.
> Cards by meat per credit.
> Alice's Army Shieldmaiden 2250 2250 1
...
buy 1 Alice's Army Shieldmaiden for 2199 each from 2213360 on 20110524
You acquire an item: Alice's Army Shieldmaiden

buy 2 Alice's Army Shieldmaiden for 2200 each from 2188968 on 20110524
You acquire Alice's Army Shieldmaiden (2)

buy 1 Alice's Army Shieldmaiden for 2200 each from 465585 on 20110524
You acquire an item: Alice's Army Shieldmaiden

buy 1 Alice's Army Shieldmaiden for 2250 each from 2181185 on 20110524
You acquire an item: Alice's Army Shieldmaiden

buy 1 Alice's Army Shieldmaiden for 2500 each from 708872 on 20110524
You acquire an item: Alice's Army Shieldmaiden

buy 1 Alice's Army Shieldmaiden for 2500 each from 204867 on 20110524
You acquire an item: Alice's Army Shieldmaiden

buy 1 Alice's Army Shieldmaiden for 2500 each from 2001236 on 20110524
You acquire an item: Alice's Army Shieldmaiden

buy 1 Alice's Army Shieldmaiden for 2500 each from 2114360 on 20110524
You acquire an item: Alice's Army Shieldmaiden
...

> Cards by meat per credit.
> Alice's Army Shieldmaiden 2250 2250 1

I can start stripping the script to see if I can isolate this because it doesn't seem as if this is a general problem. Perhaps it is a difference between the gCLI buy command and the Purchases tab?
 
I used the Purchase tab to buy
The update of cached prices only occurs when you use the CLI or ASH 'buy' command. It can't reliably learn anything from Purchase tab activity, since you aren't necessarily viewing all of the lowest-priced sources of an item - you might be looking at the contents of a particular player's store, for example.
 
The update of cached prices only occurs when you use the CLI or ASH 'buy' command. It can't reliably learn anything from Purchase tab activity, since you aren't necessarily viewing all of the lowest-priced sources of an item - you might be looking at the contents of a particular player's store, for example.

Thanks. To get the effect I want then, I need to use the gCLI and "buy" rather than the Purchase tab. I think I can be trained to do that :-)
 
Confirmed. Prices update when I use "buy" at the gCLI. Distinction between buy and Purchases tab might be worth making on the wiki but...

Thanks.
 
Thank you for asking these questions so that the answers can be well known and reported. As users of KoLmafia we have grown.
 
Back
Top