PriceAdvisor: Maximize your profits

coolbartek

New member
What about this?

mallsell 1 asbestos ore: 465.0 meat
autosell 1 asbestos ore: 50.0 meat
acquire 1 dense meat stack; make 1 asbestos meat stack; mallsell 1 asbestos meat stack: -141600.0 meat

why -14k?
 

icon315

Member
here is the same print out on mine

asbestos ore:
mallsell 1 asbestos ore: 540.0 meat
autosell 1 asbestos ore: 50.0 meat

i think you should look a few posts up
 

slyz

Developer
I think this is the reason:
Code:
[B]dense meat stack[/B]:
acquire 1 sturdy sword hilt; make 1 dense meat sword; mallsell 1 dense meat sword: 143500.0 meat
The opportunity cost of the dense meat stack is over-estimated.
 

Ferdawoon

Member
Maybe I completly missunderstood how this script work, but I thought I could just run the script and after a (possibly long) while I would have a HTML page in my Data folder with the results?
Because.. Well.. Nothing happens when I run the script.
> call D:\Bengt\scripts\PriceAdvisor.ash
and after that, 1-2 min later, nothing have happened.

This is new though, before at least it would mention when some mall_price_food.txt or something was last updated, but now nothing (and yes that name is probably not corrcet but I cant remember the real name).
I tried restarting Mafia completely, no change.

Trying to edit the PriceAdvisor.ash in Notepad it is all a mess, as it is all in one long line of text with no rowbreaks at all, so trying to find any notes on what to do in the code is a bit tricky.

Also, I tried to do just one item at a time-search using the aliases mentioned at the top post.
Code:
> alias

pa => ash import <PriceAdvisor.ash> print(price_advisor($items[%%], true))

pam => ash import <PriceAdvisor.ash> foreach itm in $items[] if(contains_text(to_string(itm),"%%")) print(price_advisor(itm, true))
I just copy-pasted the lines from the first post.

Now, testing it out, I get the void-error.
Code:
> pa bar skin

bar skin:
Returned: void
As a little sidenote here, is it possible to add a little something to make the script look like it actually responded? Because mafias charpane to the left stay green when the script is actually reacting, so I think nothing is happening as that is what I'm used to it doing.

Anyway. I know there was a post and reply to this, where I needed to change
Code:
pa => ash import <PriceAdvisor.ash> print(price_advisor($items[%%], true))
into
Code:
pa => ash[B]q[/B] import <PriceAdvisor.ash> print(price_advisor($items[%%], true))
the result to that is
Code:
> pa => ashq import <PriceAdvisor.ash> print(price_advisor($items[%%], true))

Bad item value: "=> ashq import  print(price_advisor($items[%%" ()
Returned: void

So, any ideas on why this is not working?
I have zlib 21 and whatever version of SmashLib was downloadable 10min ago.
 

slyz

Developer
First of all, simply executing PriceAdvisor.ash doesn't do anything, it's more a library of functions that can be used in other scripts. If you want to have advice on every item in your inventory, try this out.

So, any ideas on why this is not working?
The command to create or change an alias is:
Code:
[B]alias[/B] pa => ashq import <PriceAdvisor.ash> print(price_advisor($items[%%], true))
By the way, ashq is simply the 'quiet' form of ash, so you won't have the "Returned: void".

As for not having any advice for bar skin, my guess is that your zlib verbosity setting is set to 0. Try typing "zlib verbosity = 4" in the gCLI and try again.
 

Ferdawoon

Member
First of all, simply executing PriceAdvisor.ash doesn't do anything, it's more a library of functions that can be used in other scripts. If you want to have advice on every item in your inventory, try this out.
Well, I admit that this might be a big no-no when it comes to what is considered good moral regarding what is ok to script and what is not, but I'm hoping there is some way to get a script or a combination of scripts to go through my inventory and decide what is best to do with my stuff: Smash it, autosell it, sell it in the mall or craft it into something that sell better in the Mall and, after allowing for a manual check by me, to do that.
I've been looking at Bale's OCD item script, and in my wildest dreams I am hoping I could make PriceAdvicor go through my entire inventory and set bales script automagically, instead of me having to go through every item in the list, and what they can be crafted into, which seem to be what PA is actually doing.
Yes I know I would still have to go through the list to check for bugs and errors, as well as memento-items and items that I want to keep, but not having to check every item against everything it can be crafted into as well as not having to check the prices for all the mats would be a sweet relief when setting Bale's OCD script.

Sure, I could manually enter every item into PA and edit Bale's script myself, but PA take a while to do its calculations, and trying to use Bale's script with my entire inventory out it put great pressure on my browser. When I tried it in Firefox i could wait 2-3 minutes just to get the dropdownbox for an item to appear. I am hoping that all this is be something that can be done while I'm asleep or at school.


The command to create or change an alias is:
Code:
[B]alias[/B] pa => ashq import <PriceAdvisor.ash> print(price_advisor($items[%%], true))
By the way, ashq is simply the 'quiet' form of ash, so you won't have the "Returned: void".

As for not having any advice for bar skin, my guess is that your zlib verbosity setting is set to 0. Try typing "zlib verbosity = 4" in the gCLI and try again.
Well it is typical me to manage to get something that simple completly wrong :eek:
Stealing this command and changing the verbositysetting made the script / library work!
 
Last edited:

slyz

Developer
I was hoping there was some way to get a script or a combination of scripts to go through my inventory and decide what is best to do with my stuff: Smash it, autosell it, sell it in the mall or craft it into something that sell better in the Mall.
That's what the script I linked to does: it uses priceadvisor to generate a .html with advice on everything in your inventory.

Zarqon mentioned he plugged PA into Bale's OCD Manager, maybe he would be kind enough to share?
 

Ferdawoon

Member
That's what the script I linked to does: it uses priceadvisor to generate a .html with advice on everything in your inventory.
Ahh yeh I was skimming through that post you linked to and didnt really see how it was different to PA, but now i know. This is also why I kept trying to run PA as a script, thinking that is what would happen, the creation of the HTML file you mention.
And yes, sometimes I really need to be spoonfed. When it comes to idiot-proofing scripts and information in posts, I am one of the reasons it is needed =S

Zarqon mentioned he plugged PA into Bale's OCD Manager, maybe he would be kind enough to share?
Ohhh, Zarqon..? *puppy eyes*
 

lostcalpolydude

Developer
Staff member
Sure, I could manually enter every item into PA and edit Bale's script myself, but PA take a while to do its calculations, and trying to use Bale's script with my entire inventory out it put great pressure on my browser. When I tried it in Firefox i could wait 2-3 minutes just to get the dropdownbox for an item to appear. I am hoping that all this is be something that can be done while I'm asleep or at school.

Bale's OCD loads great in every browser except Firefox, as far as I can tell. As in, under two seconds in other browsers when it kills my entire system when it loads in Firefox.
 

Winterbay

Active member
It works fine in my FF, but I think it might get cranky when I load the entire inventory and not just the stuff acquired during a run. I thin it runs out of memory and crashes.
 

zarqon

Well-known member
Ok, I took a few things from a few other scripts and whipped this up for you:

PHP:
import <zlib.ash>
import <priceadvisor.ash>

int keepgear = 2;                // keep equipment
int keepother = 5;               // keep non-equipment
int keepvalue = 100000;          // keep all of anything worth more than this

record ocd_data {
   string act;
   int keep;
   string info;
}[item] ocdata;
file_to_map("OCD_"+my_name()+"_Data.txt",ocdata);

price_advice course;
foreach it in get_inventory() {
   if (ocdata contains it) continue;
   if (to_slot(it) != $slot[none]) ocdata[it].keep = keepgear;
    else ocdata[it].keep = keepother;
   course = best_advice(it,true);
   if (mall_price(it) >= keepvalue) ocdata[it].act = "KEEP";
    else switch (excise(course.action,""," ")) {
      case "smash": ocdata[it].act = "PULV"; break;
      case "use": ocdata[it].act = "USE";  break;
      case "autosell": ocdata[it].act = "AUTO"; break;
      case "mallsell": ocdata[it].act = "MALL"; break;
      case "untinker": ocdata[it].act = "UNTN"; break;
      case "make":
      case "acquire": if (contains_text(course.action,"make ")) {
            item tomake = to_item(excise(course.action,"make ",";"));
            if (tomake == $item[none]) { ocdata[it].act = "KEEP"; break; }
            int[item] ings = get_ingredients(tomake);
            if (count(ings) == 0 || !(ings contains it)) { ocdata[it].act = "KEEP"; break; }
            ocdata[it].act = "MAKE"; ocdata[it].info = to_string(tomake); break;
         }
      default: ocdata[it].act = "KEEP"; break;
   }
   print("Added "+it+" ("+item_amount(it)+"): "+ocdata[it].act+" "+ocdata[it].info+" (keep "+rnum(ocdata[it].keep)+")");
}
if (map_to_file(ocdata,"OCD_"+my_name()+"_Data.txt")) print("OCD map updated for "+my_name()+". Please check the above output to make sure nothing stupid was done.");

This will add any uncategorized items to your OCD data file, using PA's advice. That's it. It should be fairly easy to tweak this or make it more complicated if you want, perhaps doing a switch on item_type() to determine how many you want to keep.

Tested working on a character not already using OCD.

BE CAREFUL. PA may recommend something nonsensical due to mall_price() limitations. For example, perhaps for eyepatch it would recommend "create 1 pirate zombie robot head, sell 1 pirate zombie robot head", in which case if you had 10 eyepatches in inventory you might be out a LOT of meat buying pineal glands. I recommend watching the script as it runs and noting any crazy advice to fix in the relay browser. Anyway, enjoy!
 
Last edited:

Ferdawoon

Member
<3 Zarqon
However, a quick question. Is it possible to set it to use Mafia's "All but Usable" setting when deciding on what to keep rather than a maximum value? The setting in Item Filters, the "Number of items retained by "all but usable" option"? This because I dont want to end up without a Hippy outfit causing me to be locked out from the Hippy store, etc.
Hmm, re-reading this, i'm not sure I understand what I mean myself..

Also, I assume I run this and then go into Bale's OCD, check all the settings for bad suggestions and then run OCD? This script do not create or smash or sell anything but just set the settings for OCD? Don't want to end up with a complete mess just because I had no idea what was really going to happen =S

EDIT: Hmm, reading again, I assume the settings in your version are as such:
Any item that is equipable: keep 2
Any item that is not equippable: keep 5
Don't mess with items worth more than: 100 000 meat.
If so, then basing it on All But Usable is not really needed for me =)
 
Last edited:

roippi

Developer
That's awesome Zarqon, I need to try that out. I have literally been going between priceanalyzer and OCD by hand and updating things. I often quit out of frustration.

For a more permanent solution to the "keep one" thing - the handling used in FamiliarFeeder is fantastic, and probably a good starting point. It's significantly more than we need, of course, since OCD is designed to be run post-prism, whereas familiarfeeder works in ronin. I'll have a look at it if I get a chance.
 

zarqon

Well-known member
So far as I know, there's no easy way to get the usable amount of something in ASH, which is why I copped out and just kept 2 of anything equippable. Wouldn't be too hard to code but would make what I posted about twice as long, especially given the need to consider familiars that can use items (hatrack, hand, etc), and the fact that item_type() is still quite a ways from comprehensive.

And you're right, my script simply adds any missing items to your OCD file. You can fix any crazy advice using the OCD relay script, then run OCD.
 
Last edited:

jcowley

New member
I'm curious: I had a quick scan through the thread and I didn't notice any way to disable certain actions whilst keeping the rest active. For example, is there a way to allow the script to do all actions but cooking, mixing and smithing? And if not, is there any simple way to do this? Thanks in advance!
 

heeheehee

Developer
Staff member
PA doesn't actually do anything; it just advises you on what you can do. Although I suppose you could increase your valueOfAdventure until anything that consumes any number of adventures is no longer viable.
 

Ferdawoon

Member
Something I am curious about, as a feature for PA, is if it can set a little flag if the estimated profit from selling a crafted item where items needed to be bought, is lower than the cost of buying all the materials.
Example: Buying 3500 BRICKO bricks at 250:ish meat pet brick to craft an item, for a few thousand meat profit compared to if I just sold my own BRICKO bricks in the Mall, assuming I even manage to sell the item.

So, if script want to buy materials for X meat while the Profit of this in the end is less than X, set flag.
 
Top