Function to find the cheapest price on the mall

Heyas

I've recently realized that with the 16-20 turns it takes to generate the ingredients (wearing my +item and +food drop suit) to make 3 chow meins, it would be more cost efficient if I just moneyran in the castle for those 16-20 turns and bought the food I wanted from the mall. (And I thought I was so clever.. :p)

I've written most of a script that figures out my meat-per-adventure at the end of a run, multiplies the average mpa by 25 (as all chow meins and hi meins give 25 adventures) for the "budgeted_mein" cost.

But up until now I had been just attempting to buy 3 chow mein, the type of which was defined by what my mainstat was. But I figured it might be better if i could have it do a compare on the mall for, eg, for muscle classes, to look up knob sausage chow mein, cold hi mein, and hot hi mein - compare the cheapest price for each - and buy that one.

And then I thought, maybe it would be smarter to compare ALL meins and pick the cheapest one - they're all 25 adventures, and someone might be selling one type really cheap on a given day.

(I still need to think about the philosophy of whether I care about optimal stat gains or not by the time I'm moneyrunning, or just making as much money
(meaning saving as much also) as possible. But that will be easy to code with a switch (my_basestat()) sort of deal, so we'll keep this example simple..

Getting the price without actually buying something seems to be the hard bit. But since mafia will take your budget and then go find the cheapest one within that budget, surely it can just look up teh cheapest one (somehow) and just report that?

So, something like:

Code:
int get_cheapest_price (item x) {

	#uhh.. ok, i'm stuck here.
}


void main () {

int mpa = 500; #meat per adventure
int budget_per_mein = mpa * 25; #25 adventures * my mpa = how much I would earn in the adventures a mein would give
int price;
item cheapest_mein;
int  cheapest_mein_price=0;

#informational: what's the cheapest price for every mein on the market?
foreach x in $items[hot hi mein, cold hi mein, stinky hi mein, sleazy hi mein, spooky hi mein, knob sausage chow mein, bat wing chow mein, rat appendix chow 

mein]
{
	price = get_cheapest_price(x);
	print (x.to_string() + " costs " + price);

	if (cheapest_mein_price == 0)
	{
		cheapest_mein_price = price;
		cheapest_mein = x;
	}		
}

print (cheapest_mein.to_string() + " is the cheapest at " + cheapest_mein_price);



}


I will probably fill this out later to search all meins, find the cheapest within budget, buy it, eat it, and cycle through again until i have less than 5

spare fullness.

I will also do a similar price check for milk of magnesium (with 3 meins, milk gives 12 adventures, and therefore is worth taking if costs < 12*mpa

But taht's all pretty basic, and I don't want to waste anyone else's time doing it for me. I just want help with the price check



Thanks :)

Richo
 

heeheehee

Developer
Staff member
Uhh... there's mall_price(item it), an innate Mafia function. Technically this returns the fifth-cheapest price to deter mallbotting, but this has the pleasant (?) side-effect of bypassing those min-priced goodies. Probably not so pleasant, as you're trying to get some deals, no?

Also, unless you have some pretty crappy MPA (like 80?!), milk's just about always worth it.
 

heeheehee

Developer
Staff member
As always, ashref is your friend! Just try a bunch of variations (e.g. shop, mall, and store) -- you're bound to stumble upon it at some point!
 

heeheehee

Developer
Staff member
Also, profit_fx (Hmm... I wonder who wrote that script...) has an option to automatically set your MPA (false by default) when you run it. Just tossing that out there. Hopefully will have an update up soon.
 

Bale

Minion
In short, search the forum. You're not the first one to ever consider these issues so it is good to see what solutions others have considered before posting.
 
Top