Planning a What to Buy Script

philmasterplus

Active member
You've all seen these threads appear every now and then--threads asking about familiars, comparisons between off-hands, and purchase choices. I've been down the same road quite a few times, except I'd like to write a script to solve it.

Question: is there a script that, given a price range and the type of items that the person is looking for, searches for IOTMs and other powerful and rare familiars/items? Because I'm struggling to write one, and I really don't know where to start. I'm new to ASH scripting and all this stuff regarding maps and records confuses me, being used to the old C++ arrays and JavaScript objects.

Right now I'm trying to categorize the full list of IOTMs into several groups, such as familiars, squishables, clan furniture, etc. Helpful ideas, pretty please?

My goals:
  • Retrieve and compare the most recent prices of various expensive items that are frequently compared for purchase.
  • Categorize the items so that the user can search for them
  • Take the range of meat the user is willing to spend
  • Briefly describe the functions of each familiar/item/etc.

Basically, a customizable catalog of "expensive stuff" with up-to-date price information.
 
Last edited:

StDoodle

Minion
If you're already familiar with programming, but not the specifics of ASH, I highly recommend looking through the wiki. The Data Structures Page (and it's Talk Page; we really should combine the best of the two) do a pretty good job of explaining how to use maps. One function that may be of particular use is historical_price(); while mafia doesn't allow access to up-to-the-second mall info to prevent the creation of evil mallbots, IotM gear should be fine when checked over a slightly longer term.

As to how you should go about the script in general? I'd probably accept budget as a parameter, then take a pre-built map of IotM gear, tack on their prices in-function with historical_price(), then loop through and make a map of maps, each slice containing an array of items that could all be purchased without going over budget. If your pre-built maps included some kind of identifiers for softcore / HC usefulness, you could then sort the result maps by the combined totals. But getting that info would be the tricky part.
 
Last edited:

heeheehee

Developer
Staff member
By the way, the talk page link has an extraneous ; at the end.

But yeah, learning ASH probably would be a pretty good way to go about it. StD covered most of the core concept, though.
 

fronobulax

Developer
Staff member
What StD said. If you can handle C++ ASH should not be too much of a stretch. If I wanted to start out with a list of IToM's I might just run bumcheekcity's snapshot maker. The information in the snapshot, or for that matter, the data files it uses, would be a place to start.

As with any coding task, you might specify exactly what you are looking for because that will help you focus on the parts of ASH that are most immediately useful. For example, items in general or just IoTMs? Owned by the player or not owned? DC or closet checked for ownership or not? Would the modifier maximizer provide some pointers? Etc.

Good luck.
 

slyz

Developer
I didn't quite understand the concept of this script. The user would tell it he's looking for, say, a shield, and the script will list all the shield IoTMs?

It seems to me that the list of IoTMs is small enough, or their price is high enough, that either older players know them all or simply need a quick reference the the KoL Wiki's Mr Store page, or newer players are limited to the last few IoTMs, that don't cost 20+m meat.

Or are you thinking of a kind of maximizer that also looks at items you don't own, and weighs in their price?
 

philmasterplus

Active member
First, thanks for all the encouragement. I guess I was unclear at the first post, so here are my goals:
  • Retrieve and compare the most recent prices of various expensive items that are frequently compared for purchase.
  • Categorize the items so that the user can search for them
  • Take the range of meat the user is willing to spend
  • Briefly describe the functions of each familiar/item/etc.

Basically, a customizable catalog of "expensive stuff" with up-to-date price information.

I didn't quite understand the concept of this script. The user would tell it he's looking for, say, a shield, and the script will list all the shield IoTMs?

It seems to me that the list of IoTMs is small enough, or their price is high enough, that either older players know them all or simply need a quick reference the the KoL Wiki's Mr Store page, or newer players are limited to the last few IoTMs, that don't cost 20+m meat.

Or are you thinking of a kind of maximizer that also looks at items you don't own, and weighs in their price?

Considering the frequent appearance of What-To-Buy threads in the KoL Forums, I think my project is not entirely worthless. Also, good idea! I wasn't thinking about checking whether a player has any of the items.

Oh, and one question, please (boy I'm spewing a load of questions) : is there a method of quickly retrieving the number of values/sub-maps in a map? Perhaps like this?
Code:
//No push_back(), I have to use workaround...
my_map[ map_size( my_map ) + 1 ]  = next_var;
Right now I'm using global variables to count the size of maps (arrays).
 

slyz

Developer
There is count(), for en something[int] map. Remember the index starts at 0:
PHP:
my_map[ count(my_map) ]  = next_var;

Ok, it's basically an informational script! I thought it would be a lot more complicated. I could see myself using this, if only for deciding what to invest in (of course, that would work if you know the usual average price of those IoTMs).

I guess everything would have to be hardcoded - follow frono's advice and plunder code from BCC's snapshot, since he must have done most of the work already (check his mr_items.txt data file).
 
Last edited:

zarqon

Well-known member
The ASH function item_type() would come in particularly handy here. I'd avoid building more maps that need maintaining; it's pretty easy to see what category something is in simply by looking at the mall price.

For example, to get a list of IotM familiars:

PHP:
foreach it in $items[]
   if (item_type(it) == "familiar larva" && mall_price(it) > 4000000) 
      print("This is a Mr. Familiar or other rare familiar.");
 
Top