Bug - Fixed autoBuyLimit issue with acquire creation

Rinn

Developer
I was making marbles for the trophy and I was telling mafia to acquire them since acquire will use creation instead of outright buying the item if it's cheaper to do so. What ended up happening is mafia decided to not buy some cheaper marbles because the price was above the autoBuyLimit, but then continued on to buy the marble I requested.

Should individual creation items be bought during an acquire if they cost more then autoBuyLimit if it's economical to do so? Am I understanding the acquire logic correctly?

autoBuyLimit was set at 20000

Code:
> acquire black catseye marble

Searching for "black catseye marble"...
Searching for "beach ball marble"...
Searching for "steely marble"...
Searching for "beige clambroth marble"...
Searching for "jet bennie marble"...
Searching for "bumblebee marble"...
Searching for "lemonade marble"...
Searching for "red china marble"...
Searching for "brown crock marble"...
Searching for "green peawee marble"...
Verifying ingredients for black catseye marble (1)...
Verifying ingredients for beach ball marble (1)...
Verifying ingredients for steely marble (2)...
Verifying ingredients for beige clambroth marble (4)...
Verifying ingredients for jet bennie marble (1)...
Verifying ingredients for bumblebee marble (2)...
Verifying ingredients for lemonade marble (1)...
Verifying ingredients for red China marble (1)...
Verifying ingredients for brown crock marble (1)...
Creating brown crock marble (1)...
You acquire an item: brown crock marble
Successfully created brown crock marble (1)
Creating red China marble (1)...
You acquire an item: red China marble
Successfully created red China marble (1)
Creating lemonade marble (1)...
You acquire an item: lemonade marble
Successfully created lemonade marble (1)
Creating bumblebee marble (2)...
You acquire bumblebee marble (2)
Successfully created bumblebee marble (2)
Creating jet bennie marble (1)...
You acquire an item: jet bennie marble
Successfully created jet bennie marble (1)
Verifying ingredients for jet bennie marble (7)...
Verifying ingredients for bumblebee marble (14)...
Verifying ingredients for lemonade marble (28)...
Verifying ingredients for red China marble (1)...
Verifying ingredients for brown crock marble (2)...
Creating brown crock marble (2)...
You acquire brown crock marble (2)
Successfully created brown crock marble (2)
Creating red China marble (1)...
You acquire an item: red China marble
Successfully created red China marble (1)
Verifying ingredients for red China marble (55)...
Using cached search results for brown crock marble...
Purchasing brown crock marble (39 @ 1,300)...
You acquire brown crock marble (39)
Purchasing brown crock marble (8 @ 1,300)...
You acquire brown crock marble (8)
Purchasing brown crock marble (3 @ 1,400)...
You acquire brown crock marble (3)
Purchasing brown crock marble (1 @ 1,500)...
You acquire an item: brown crock marble
Purchasing brown crock marble (2 @ 1,500)...
You acquire brown crock marble (2)
Purchasing brown crock marble (21 @ 1,843)...
You acquire brown crock marble (21)
Purchasing brown crock marble (1 @ 1,890)...
You acquire an item: brown crock marble
Purchasing brown crock marble (35 @ 2,000)...
You acquire brown crock marble (35)
Purchases complete.
Creating red China marble (55)...
You acquire red China marble (55)
Successfully created red China marble (55)
Creating lemonade marble (28)...
You acquire lemonade marble (28)
Successfully created lemonade marble (28)
Creating bumblebee marble (14)...
You acquire bumblebee marble (14)
Successfully created bumblebee marble (14)
Creating jet bennie marble (7)...
You acquire jet bennie marble (7)
Successfully created jet bennie marble (7)
Creating beige clambroth marble (4)...
You acquire beige clambroth marble (4)
Successfully created beige clambroth marble (4)
Creating steely marble (2)...
You acquire steely marble (2)
Successfully created steely marble (2)
Creating beach ball marble (1)...
You acquire an item: beach ball marble
Successfully created beach ball marble (1)
Creating black catseye marble (1)...
You acquire an item: black catseye marble
Successfully created black catseye marble (1)

> acquire beach ball marble

Verifying ingredients for beach ball marble (1)...
Verifying ingredients for steely marble (2)...
Verifying ingredients for beige clambroth marble (4)...
Searching for "jet bennie marble"...
[COLOR=red]Stopped purchasing jet bennie marble @ 21,000.
You need 8 more jet bennie marble to continue.[/COLOR]
Searching for "beach ball marble"...
Purchasing beach ball marble (1 @ 172,500)...
You acquire an item: beach ball marble
Purchases complete.

> acquire steely marble

Verifying ingredients for steely marble (1)...
Verifying ingredients for beige clambroth marble (2)...
Using cached search results for jet bennie marble...
[COLOR=red]Stopped purchasing jet bennie marble @ 21,000.
You need 4 more jet bennie marble to continue.[/COLOR]
Searching for "steely marble"...
Purchasing steely marble (1 @ 110,000)...
You acquire an item: steely marble
Purchases complete.

> prefref buy

debugBuy (global, now 'false', default false)
autoBuyPriceLimit (user, now '20000', default 20000)
buyScript (user, now '', default )
Returned: void

> set autoBuyPriceLimit=50000

autoBuyPriceLimit => 50000

> acquire beige clambroth marble

Verifying ingredients for beige clambroth marble (1)...
Searching for "jet bennie marble"...
Purchasing jet bennie marble (2 @ 21,000)...
You acquire jet bennie marble (2)
Purchases complete.
Creating beige clambroth marble (1)...
You acquire an item: beige clambroth marble
Successfully created beige clambroth marble (1)
 
Last edited:

slyz

Developer
This is an old report, but a clanny recently had the same kind of problem when trying to acquire a clockwork pirate skull.

Meatpasting a clockwork sphere with an enchanted eyepatch yields a clockwork pirate skull

Mall prices:

clockwork pirate skull - 98,000 meat
clockwork sphere - 24,140 meat
enchanted eyepatch - 500 meat

When using "acquire 1 clockwork pirate skull", we expect Mafia to buy a clockwork sphere and an enchanted eyepatch to create a clockwork pirate skull.

But with the default autoBuyPriceLimit value of 20000, the option of creating the clockwork pirate skull is rejected because one of the ingredients costs more than autoBuyPriceLimit. Naturally, Mafia then goes on to its next option, buying the 98k clockwork pirate skull.

I think the behavior should be consistent: either apply autoBuyPriceLimit to every option available to "acquire", either go with the cheapest option and always disregard autoBuyPriceLimit for "acquire" (just like with "buy").

I'm in favor of the latter, any other opinions?
 

Theraze

Active member
I'd suggest the first, since that's the behaviour for retrieve_item, and that keeps the gCLI command and ASH command consistent...

Unless I really missed something the last time I tried it. :)
 

slyz

Developer
I didn't think to check retrieve_item(), since both the ASH and the CLI command call InventoryManager.retrieveItem(). It turns out that "acquire" calls it with isAutomated = false, whereas retrieve_item() calls it with isAutomated = true.

isAutomated is the flag that tells KoLmafia.makePurchases() whether to respect autoBuyPriceLimit (it is respected when isAutomated is true) or not. When InventoryManager.retrieveItem() decides to create the item instead of buying it, the ingredients are retrieved with isAutomated = true, instead of using the original call's isAutomated. Making this happen shouldn't be too difficult.

The difference between "acquire" and retrieve_item() is another inconsistent behavior, and the fix would be to simply change this line in AcquireCommand.java:
PHP:
InventoryManager.retrieveItem( item, false );
to
PHP:
InventoryManager.retrieveItem( item, true );
It would prevent "acquire" from buying anything that costs more than autoBuyPriceLimit, but I think it avoids the problem instead of fixing it.

I'm OK with "acquire" and retrieve_item() being slightly different. "acquire" is mostly used by users who type it in the gCLI, so I feel that the autoBuyPriceLimit should be disregarded. retrieve_item() is used mostly in scripts, and autoBuyPriceLimit adds a way for the user to control what scripts spend. For me, this justifies the difference between the two commands.

Thoughts? :)
 
Last edited:

Winterbay

Active member
What should I use in the CLI instead of acquire if I want to get one but not pay more than my price limit if acquire doesn't? (I mainly use acquire because it appears to be a combination of "create" and "buy" which I find convenient)
 

slyz

Developer
If "acquire" is changed to always respect autoBuyPriceLimit, you will have to acquire, see what Mafia tries to do first, and then use either "create" or "buy".

That is another reason why I wanted to keep the current behavior for acquire.
 
Last edited:

Theraze

Active member
Personally, I use this:
getone => ashq string originalabpl = get_property("autoBuyPriceLimit"); try { set_property("autoBuyPriceLimit", mall_price(to_item("%%"))); retrieve_item(1, to_item("%%")); } finally { set_property("autoBuyPriceLimit", originalabpl); }
 

Winterbay

Active member
If "acquire" is changed to always respect autoBuyPriceLimit, you will have to acquire, see what Mafia tries to do first, and then use either "create" or "buy".

That is another reason why I wanted to keep the current behavior for acquire.

If acquire is changed to always respect autoBuyPriceLImit I think I would be even more happy with its function actually so that would be great. I think it is sort of implied by the name of the preference that any automatic buying over that limit won't go through, but you can still od it manually. As such I feel it would be good if all CLI-commands were equal in that regard.
 

slyz

Developer
I already see "acquire" as doing something manually. It's just a command that happens to be smart and decide whether to buy, craft, pull etc...

I think I will up my autoBuyPriceLImit by a lot if we change "acquire" this way. I'd feel like I'm adding something annoying to Mafia :) . But users seem unanimous up to now.
 

slyz

Developer
As of r10240, "acquire" will always respect autoBuyPriceLimit.

This change makes the isAutomated parameter of InventoryManager.retrieveItem() irrelevant, since acquire was the only place in the code where it was used as false, along with a few requests to retrieve worthless items (which don't really benefit from isAutomated = false).

It seems that isAutomated was added specially for "acquire", to make it a command like "create" or "buy": since the user told Mafia to acquire, it should do so whatever the cost. But for the few users I talked to, Mafia respecting autoBuyPriceLimit is more important than what the devs had in mind for acquire, apparently.

I haven't removed isAutomated though, since I'm still not sure about this change. If enough people start complaining, we can always undo it.
 
Last edited:
Top