Feature - Rejected Mafia ignores advertising

Well, just it. Main point of advertising is to be higher in resulting query. But Mafia totally ignores it, so when I am making query, it sorts all same-priced offers by amount (biggest first). Can it be fixed, please?
 

Veracity

Developer
Staff member
Let's put it like this:

I tell KoLmafia to buy 100 limes
There are 12 stores with 5 limes each and then a store with 1000, all at the same price
Kolmafia will obtain the 100 limes with a single server request

Apparently, you would prefer that it buy 5 from each of the 12 stores and then 40 from the 13th one.

That is resource intensive for KoL - 13 server requests & database updates as opposed to just 1 - and substantially slower for the user.

Note that if you search in the browser, you can look at the search results and choose to go to any store. You can choose to go to the store with sufficient stock to sell you what you want all at once. You are not forced to go to multiple stores in the order that they are presented.

Neither is KoLmafia.
 

Crowther

Active member
Let's put it like this:

I tell KoLmafia to buy 100 limes
There are 12 stores with 5 limes each and then a store with 1000, all at the same price
Kolmafia will obtain the 100 limes with a single server request

Apparently, you would prefer that it buy 5 from each of the 12 stores and then 40 from the 13th one.
However, if there's 20 stores with 1000 items limit 1 and one store with 100 items, mafia will buy from the limit 1 stores before buying from the 100 item store. I added this to my code:
Code:
Index: src/net/sourceforge/kolmafia/request/PurchaseRequest.java
===================================================================
--- src/net/sourceforge/kolmafia/request/PurchaseRequest.java   (revision 12564)
+++ src/net/sourceforge/kolmafia/request/PurchaseRequest.java   (working copy)
@@ -332,6 +332,11 @@
                        return KoLCharacter.isHardcore() ? 1 : -1;
                }

+               /* improve sorting */
+               if ( this.limit != pr.limit ) {
+                       return pr.limit - this.limit;
+               }
+
                if ( this.quantity != pr.quantity )
                {
                        return pr.quantity - this.quantity;
 

Veracity

Developer
Staff member
I like that - except for the indentation style, which is not "KoLmafia standard" - but I have a further improvement.

Code:
		// limit is how many items you can actually buy
		// sort high to low on limit

		if ( this.limit != pr.limit )
		{
			return pr.limit - this.limit;
		}

		// If limits are equal but quantity is not, one or the other
		// stores has an artificial limit. Reward those that don't do
		// that by sorting low to high on quantity.

		if ( this.quantity != pr.quantity )
		{
			return this.quantity - pr.quantity;
		}
I will submit that. :)
 

Crowther

Active member
Yeah, I'm stuck on modified K&R. I usually try to match the code I'm editing, but I wasn't planning that as a patch. I figured you'd like the idea.
 
Top