Feature - Rejected Mall search/buy results are ordered by quantity & name, ignores advertising budget completely.

Irrat

Member
When there are 50 shops all listing the same item for 100 meat. The shop with the most items purchasable will always be purchased from by mafia.

I don't think this is intended behavior, as it effectively removes advertising budget from play.

Checking mafia's internals, the PriceComparator is first comparing the limit, then the quantity.

Which brings another issue into play. The "limit" is not what you think it is.
To the playerbase, it's a player set limit on how many items can be purchased that is sometimes used for funsies when they set it higher than the amount they're selling.
In mafia, it's the amount of items mafia can purchase from the store.
So mafia's limit is basically Math.min(quantity, limit == null ? quantity : limit)
Which is then subtracted from with every purchase of course.
[Link] [Link]

This doesn't look like too big a deal, but it breaks two areas.
The first is display, the second is the PriceComparator again!
Because remember, that limit will never be 0, always the remaining items you can buy in said store. It's effectively another quantity alias.
Heck, it might be more useful to rename quantity to "cosmetic amount left" for all it seems to matter.

That is to say, with this limit logic:
Joe has 400 items in his store. Steve has 500 items in his store. Steve is the #1 seller.
Steve puts a limit of 350 in his store, Steve still has the most items in his store. Joe is now the #1 seller.

That same limit is also used for display purposes. So if I put a limit of 50 on an item with 40 remaining. Then mafia will set the limit to 40, because it always does Math.min(limit, quantity). And as the "limit" is equal to the quantity, mafia will not render the player's limit. This is generally a cosmetic thing, but still unintended(?) behavior.
[Link]

Lets put all of this into a 'real world' context.

If you have mall min items: You're never going to be purchased from by mafia unless you have the most items, no matter how much meat you throw at the advertising budget.

If you have the same quantities of items for sale; mafia will list your store by alphabetical order instead.
Your store "ZZZZ Sleepy Joes" is the last place mafia will ever go to for its shopping.

YZlWqoz.png
 
Last edited:

fronobulax

Developer
Staff member
I don't think this is intended behavior, as it effectively removes advertising budget from play.
Actually, I seem to recall from a very long time ago that it was deliberate.

Jick (in)famously said that "The Mall is not the Game" and mafia's implementation choices were focused on purchasing the desired amount at the lowest price.

Until someone with a better memory contradicts me (which is likely :) ) I'm thinking this is a Feature Request, not a bug.
 

Veracity

Developer
Staff member
It is completely intentional. I wrote it.

1) It attempts to minimize the number of requests to fulfill your order. Good!
2) if it can do it by buying from a limit free store at the same price as a limited store at the same price, it does so. That may even buy out the unlimited stock. Surely that is good?
3) I could not care less about advertising.

Literally everything you describe is a design decision, not a bug.

The Mall is not the Game.
 

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
If they would like us to respect those sorts of things, some sort of mall API would be a good sign. Have marked this as Feature: Rejected.
 

Veracity

Developer
Staff member
When there are 50 shops all listing the same item for 100 meat. The shop with the most items purchasable will always be purchased from by mafia.

I don't think this is intended behavior, as it effectively removes advertising budget from play.

It is intentional, favoring those with larger stock, minimizing requests needed for bulk purchasing.

Checking mafia's internals, the PriceComparator is first comparing the limit, then the quantity.

It is intentional, favoring those who are willing to sell more of their stock at a given price, rather than artificially throttling purchases.

In mafia, it's the amount of items mafia can purchase from the store.

Bingo.

Joe has 400 items in his store. Steve has 500 items in his store. Steve is the #1 seller.

Steve puts a limit of 350 in his store, Steve still has the most items in his store. Joe is now the #1 seller.

Right. You can buy 400 from Joe but only 350 from Steve. If I want 400, I can do it in one request from Joe.

Joe lost a sale by setting a limit.

If you have mall min items: You're never going to be purchased from by mafia unless you have the most items, no matter how much meat you throw at the advertising budget.

If KoLmafia can fulfill a bulk purchase in one request rather than potentially multiple, that is to the advantage of the buyer - which is our sole focus.

Advertising is an attempt to skew purchases to a the seller - regardless of inconvenience to the buyer.

If you have the same quantities of items for sale; mafia will list your store by alphabetical order instead.
Your store "ZZZZ Sleepy Joes" is the last place mafia will ever go to for its shopping.

We could eliminate the final alphabetical sort. Assuming the sort is stable, it would retain the order presented by KoL. I have no objection to that.
 

Irrat

Member
It is intentional, favoring those with larger stock, minimizing requests needed for bulk purchasing.



It is intentional, favoring those who are willing to sell more of their stock at a given price, rather than artificially throttling purchases.



Bingo.



Right. You can buy 400 from Joe but only 350 from Steve. If I want 400, I can do it in one request from Joe.

Joe lost a sale by setting a limit.



If KoLmafia can fulfill a bulk purchase in one request rather than potentially multiple, that is to the advantage of the buyer - which is our sole focus.

Advertising is an attempt to skew purchases to a the seller - regardless of inconvenience to the buyer.



We could eliminate the final alphabetical sort. Assuming the sort is stable, it would retain the order presented by KoL. I have no objection to that.

A serious question.

Would you be opposed to a change where mafia still performs the same number of overall purchase requests, but respecting the mall order?

For the mall search GUI, we leave that untouched. It still sorts by quantity. But the internals of mall purchases by mafia's API are changed. (We're not changing purchases from the GUI)

For example, if there are three stores. 5, 6, 9 in each store.
Purchase 3 items = Store 5
Purchase 7 items = Store 9
Purchase 10 items = Store 5, then Store 6

This sounds like it would accomplish what you want, while giving some respect to mall order.
The same amount of requests are performed, but store 9 is not given priority when a smaller store will do the job.
 

Veracity

Developer
Staff member
I do not oppose that.

It was more complicated than I was willing to consider, but in our new regime of robust unit testing, if someone other than me wants to take it on, sure.
 

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
For example, if there are three stores. 5, 6, 9 in each store.
Purchase 3 items = Store 5
Purchase 7 items = Store 9
Purchase 10 items = Store 5, then Store 6
I would have these order from Store 9, Store 9 and Store 5 then 9. Just to avoid numbers changing under our feet. By which I mean, these need to have significant buffers if possible. I really don't like this change.
 
Top