t-mw / gw2-arbitrage

Finds items in Guild Wars 2 that can be sold on the trading post for a higher price than the cost of crafting the item.
28 stars 5 forks source link

Convert steps into gold per hour #12

Open Iiridayn opened 3 years ago

Iiridayn commented 3 years ago

Splitting this off from #7 as it's not related.

Recipes that require assembly could be another opt-in. Ideally I'd want to be able to keep them in the default output, and accurately calculate the time required for each recipe. Then recipes could be ranked by gold per time. Unfortunately as far as I could tell the crafting times from the API weren't accurate, so I added crafting steps as an approximation of time required.

I noted:

I've also been thinking about a gold per hour calculation, and recognized steps as a proxy for it; I hadn't realized the crafting times were included in the API. Could it be the API crafting time is for a single item? Crafting multiple items provides a speed bonus for each - https://wiki.guildwars2.com/wiki/Crafting says:

When crafting a stack of items, the process speeds up progressively: each item queued will craft in half the time of the previous item. For example, if it takes two seconds to create a single bronze ingot, it will take only one second to create the second, and a half second to craft a third. There is a limit to how fast items can be crafted.

I suspect the halving ends after 4-5 times; but it should be pretty easy to craft a stack of mithril ore or something (do it all the time...) and time the duration. I'll check it out.

Two problems with assembler recipes:

  1. Users might not have access to the assembler in any guild, or the guild may not have the recipe unlocked
  2. Crafting assembler recipes ties you to the computer every 5.5 minutes, unlike other recipes which you autocraft many stacks of. Showing an accurate crafting duration might reasonably answer this point though. Also, "many stacks" still is almost universally less than 5.5 minutes.
Iiridayn commented 3 years ago

Stopwatch measured 7.2 - 7.5s for 30 elder wood planks; default crafting time is 1s (verified w/stopwatch). I am a bit slow; got 1.7-1.9s for 2 planks. 2.2-2.6 for 3 planks. - notably longer (by more than just .2 s) than the wiki predicts. 2.6-2.9 for 4 planks.

43.09s for 252 items w/base time of 1000ms. 44.33s for 124 items w/base time of 2000ms. 62.19s for 372 items w/base time of 1000ms. 13.88s for 70 items w/base time of 1000ms. 11.10s for 52 (same) items w/base time of 1000ms.

So, crafting floor for 1000ms item is around 76.5ms.

baseTime / 1.572 ^ floor(index, 5) (index is 0 based) per item is almost correct. It's around 100-200 ms slower than most outcomes (to account for reaction times), but it overestimates for the 372 items as 62.56s. Also off for smaller values; 30 it estimates as 6.55s (unreasonably low).

Attempts with baseTime / floor(item, 18) ^ .648 for all items after the first (item is 1 based) are also close, but not quite as accurate. I'm not sure offhand what kind of function we're looking at.

Edit: 44.15s for 27 items w/a 7000ms crafting time.

Iiridayn commented 3 years ago

Purchasing/selling time is also a non-trivial part of the crafting time. I've found buying 41 stacks of Sliver of Twitching Forgemetal to take a significant chunk of time. Selling when there are many orders of 1 is also significantly more time consuming than a few bulk orders. This time may be difficult to estimate, as it might be based on how busy the market database is. Still, it should be feasible to estimate an average via wall clock timing with a good number of samples.

Other times I've considered factoring in and rejected:

t-mw commented 3 years ago

baseTime / 1.572 ^ floor(index, 5) (index is 0 based) per item is almost correct

Thanks for looking into this. Did you settle on 1.572 through trial and error? Even if it's not perfect it sounds accurate enough to be more useful than what the tool currently shows.

Iiridayn commented 3 years ago

Yes, trial and error. I guessed (as does the wiki) this was an exponential function of the form C^-n (C being a constant). The slope possibly doesn't quite match, but that is the most common kind of function I've seen in games (also used for XP curves, for example). The constant was determined with a manual binary search; not aiming for terribly high accuracy, so it could be further refined. One thing that makes me uncomfortable about it is I can't find a good ratio or well known irrational number which fits it. People usually prefer familiar numbers, numbers with 5's and 0's, and numbers with few decimal places. It is possible the number was picked via trial and error as well - but I feel that is improbable. The curve not quite matching also confirms I'm missing something important somewhere.

That all said - yeah, it seems close enough to be useful - which maybe is all one can ask of it without knowing the proper formula :).

Iiridayn commented 2 years ago

Another stopwatch value. 1500 items at 1000 ms each took 244.04 seconds. I add this since the average time should be quite close to the minimum time, and I was crafting them anyway.

Notably, this is < 1/6 * base time per item, but only just.

1980 items was around 320 seconds (maybe 319 something, missed the first press, second at 320.05). 793 items at 129.30 seconds. 2700 items at 434.75 seconds. Another 1500 at 242.83 seconds.

The difference between the 1500 and the 1980 works out to roughly 0.1583_s per item, or 19/120 - just under 1/6th. Might be a good estimate for the longer part of the crafting formula, just have to figure out the lower part then.

Though, 0.15993 per item for the 2700 - 1500 matches pretty close with the 0.16102 for the avg per item for 2700. At .16, this would translate to 6.25 items per second.