Bug - Fixed Many stores with limits, can't find items to buy in the mall

heeheehee

Developer
Staff member
Lots of people have scrumptious reagents with limits (11, in fact). I've reached all of these limits. I can't buy scrumptious reagents through Mafia unless I use the relay browser.

Code:
Searching for "scrumptious reagent"...
Search complete.
Desired purchase quantity not reached (wanted 1, got 0)
 

Veracity

Developer
Staff member
This is interesting.

When we buy from the mall with a "buy" command (which is what I assume you did; you did not say how you generated the result you did include), we first search the mall with a "maximumResults" parameter of 10. If you have already bought your limit of 10 stores, that's all you get.

The Mall Purchase frame has the same issue; if you say that you want 10 results but have already bought out the first 10 limited stores, you see nothing new.

This is definitely a problem for the "buy" command; if you say "buy 100 x", it should search Y at a time, buy as many as it can - and search again, Y at a time, skipping over the already-limited stores, to, eventually, buy the 100 items you said you wanted.

The Mall Purchase Frame is not automated - but if I want to show the next 10 stores which will sell to me, I'd like it to filter out the stores that I have already bought the limit from.

I approve the fix for this for both cases. Whoever does it. Which might be me. Or not. ;)
 

heeheehee

Developer
Staff member
It's tough to actually reproduce the included result, seeing as you need to buy 153 reagents (currently, anyhow).

But yeah, both buy and acquire failed.
 

xKiv

Active member
It's tough to actually reproduce the included result, seeing as you need to buy 153 reagents (currently, anyhow)

Can you (temporarily) change your requested maximumResults to 1 or 2, and check with other items? I think lots of stuff will have more than 1 limited store, with limit (close to) 1 and reasonably low price.
 

heeheehee

Developer
Staff member
I can only change this by modifying the source code, but yeah, you'd want to look at L466 or so of kolmafia.session.StoreManager (looks something like StoreManager.searchMall( "\"" + name + "\"", results, 10, false );)

I tried changing the maximum results in the Mafia Purchases frame, didn't do a thing.
 
too many "limit 1" mall stores breaks mall buying

My daily script buys fifteen twinkly wads. Currently there are eleven cheapest prices in the mall for twinkly wads are "limit 1". KoLMafia fails to buy more than ten twinkly wads. A sample from the log file (the first three twinkly wads were purchased earlier):

Purchasing twinkly wad (1 @ 180)...
Purchasing twinkly wad (1 @ 180)...
Purchasing twinkly wad (1 @ 181)...
Purchasing twinkly wad (1 @ 181)...
Purchasing twinkly wad (1 @ 181)...
Purchasing twinkly wad (1 @ 181)...
Purchasing twinkly wad (1 @ 181)...
Desired purchase quantity not reached (wanted 12, got 7)
Using cached search results for twinkly wad...
Desired purchase quantity not reached (wanted 5, got 0)
You need 5 more twinkly wad to continue.

The eleventh store has a price of 183, so I know KoLMafia didn't attempt to purchase past the tenth store. Using the "buy" command from the CLI gives the same behavior. If I manually highlight the first twenty stores and use the purchase button, I can buy as many as I want. If on a given day any store up to and including the tenth isn't limited, I have no problem. It's only when the first ten stores are "limit 1" that this error happens. Since I can buy as many as I want if I manually specify the stores, this behavior seems like a bug.
 
buy 15 twinkly wad --- in CLI does not work currently

So there are so many stores with a limit of 1 right now, that this command is now failing. It looks like it searches the first 10 stores but does not go beyond that even though it could and it would
work ok.

Searching for "twinkly wad"...
Search complete.
Purchasing twinkly wad (1 @ 180)...
Purchasing twinkly wad (1 @ 180)...
Purchasing twinkly wad (1 @ 180)...
Purchasing twinkly wad (1 @ 180)...
Purchasing twinkly wad (1 @ 180)...
Purchasing twinkly wad (1 @ 181)...
Purchasing twinkly wad (1 @ 181)...
Purchasing twinkly wad (1 @ 181)...
Purchasing twinkly wad (1 @ 181)...
Purchasing twinkly wad (1 @ 181)...
Desired purchase quantity not reached (wanted 15, got 10)
 

fronobulax

Developer
Staff member
Any correlation between this and the value that shows up as Search Limit in the GUI? I think this is the Global preference defaultLimit.
 

guyy

Member
Probably obvious, but this doesn't seem to have anything to do with store limits. This has been happening to me with old candy wrappers, because the first 10 stores just didn't have enough of them:

Code:
[ buy(45, $item[old candy wrapper]) ]
buy 2 old candy wrapper for 1595 each from 1391947 on 20140729
buy 2 old candy wrapper for 1595 each from 1452368 on 20140729
buy 1 old candy wrapper for 1599 each from 2332690 on 20140729
buy 1 old candy wrapper for 1600 each from 76767 on 20140729
buy 15 old candy wrapper for 1600 each from 1852498 on 20140729
buy 3 old candy wrapper for 1661 each from 375718 on 20140729
buy 1 old candy wrapper for 1770 each from 2194984 on 20140729
buy 6 old candy wrapper for 1776 each from 2312062 on 20140729
buy 3 old candy wrapper for 1776 each from 2390919 on 20140729
buy 1 old candy wrapper for 1776 each from 2063428 on 20140729
["desired purchase quantity not reached", buy() returns false]
 

Darzil

Developer
No, it's to do with only looking at ten stores. It's worse with limits as you can get more by running buy again if they aren't limited, whereas if you already have bought from 10 limited stores you are out of luck.
 

Veracity

Developer
Staff member
I just went to the mall in the Relay Browser and searched for twinkly wads. The browser submitted this URL:

Requesting: http://www.kingdomofloathing.com/mall.php?didadv=0&pudnuggler=twinkly+wad&category=allitems&food_sortitemsby=name&booze_sortitemsby=name&othercon_sortitemsby=name&consumable_byme=0&hats_sortitemsby=name&shirts_sortitemsby=name&pants_sortitemsby=name&weapons_sortitemsby=name&weaponattribute=3&weaponhands=3&acc_sortitemsby=name&offhand_sortitemsby=name&wearable_byme=0&famequip_sortitemsby=name&nolimits=0&justitems=0&sortresultsby=price&max_price=0&x_cheapest=0&consumable_tier_1=0&consumable_tier_2=0&consumable_tier_3=0&consumable_tier_4=0&consumable_tier_5=0

I noticed that was a "Show More Stores" link at the bottom. When I clicked it, it submitted the same URL with the following at the end:

&moreitems=1&page=1

And what came back was just the new stores; apparently KoL inserts them into the search results with Ajax, or something.

When I clicked the new "Show More Stores" link, it submitted the most recently submitted URL with the following at the end:

&moreitems=1&page=2

And we got back yet another page of results.

I think we can use this mechanism to, at least, make sure we have enough pages of stores in our search results to potentially satisfy the total number of items the user is trying to buy.
 
Thanks for the merge. For what it's worth, my script uses the acquire command to buy twinkly wads. I don't know whether its internal logic differs from the buy CLI command, once it's determined that it'll buy from the mall, but the similar failure from both suggests they're the same. I did try both acquire and buy after I'd searched the mall manually for twinkly wads with a limit of 20 stores, and the behavior was the same.
 

Veracity

Developer
Staff member
Well, try revision 14295.

We already had code to fetch and concatenate all of the multiple pages from a search; that is why you can search for "a" and it will do 485 searches or so. But StoreManager.searchMall( item) had a hardcoded limit of 10, as lost noted. I changed it to 0 - and also had to fix SearchMallRequest to set x_cheapest=0 in that case, rather than omitting x_cheapest entirely, because KoL itself will limit you to 10 if you do that.
 

Veracity

Developer
Staff member
I was waiting for somebody else to say "it works for me", but no joy. I'm marking this fixed.
 
Delayed joy, then. I saw the daily build update that noted this issue had been resolved, but I couldn't check it right away. That day, and the next one or two, there was a store with a huge number of twinkly wads available at the minimum price. Eventually I did see a say with more than ten "limit 1" stores at minimum price, and my scripts bought 15 with no errors. Thanks for the fix!
 
Top