Ephenia / Pokeclicker-Scripts

Various scripts & enhancements for the game Pokéclicker.
https://github.com/Ephenia/Pokeclicker-Scripts
GNU General Public License v3.0
193 stars 261 forks source link

[feature request] [enhancement] AutoTrade #405

Open JohnyDL opened 1 month ago

JohnyDL commented 1 month ago

I know this one is a HUGE ask.

So I've been largely keeping PokeClicker in the background for months now, I've only really got some EVs to finish off and some Vitamins to collect before I've essentially finished the whole game (and should probably restart), and so I'm looking at the auto trading in the underground as one of the last things that isn't really automated either in-game or by mods. There are the deal chains on the wiki site but that's the closest it comes to automation, and it's rather focused on one aspect of the underground's trading value.

What I'd suggest is a new tab for AutoTrading within the Underground menu and a handful of different modes. I'd also suggest making it something like a 5minute to hourly script rather than every tick (or even a click this button to do all the trading as per your set up below -> which could easily be automated with setinterval if a user wanted to fully auto)

Mode 1, "I want all the diamonds" Diamond Deal Chains. Look ahead X number of days for the normal chains method and then make the trades that are good for today. It might even show the best paths for the user to see and the estimated end number of diamonds, it could have a toggle to count down to that goal (and so stick with the calculated route) or keep looking ahead X days recalculating the best route for each day.... I'd imagine for look aheads of 60+ days that it would be rare for day 0 to n and day 1 to n+1 to have significantly different opinions on the paths for day 1, once a highly efficient ramping path is established the question is often how to get into it and when to leave the cycle and go for heartscales for the final bump in diamond value, at least that's been my experience with the Wiki's Calculator

Mode 2, "I want all the gems", Plate Deal Chains, Look ahead X number of days and instead of maximising Diamond Value, maximise the number of plates/average gem value or the minumum gem value and then make all the trades that are good for today (sometimes this might be doing 50% trades rather than 100% trades). The goal of this mode is to maximise the amount of gem currency for being able to buy Furfrou (La Reine), Silvaley, and Magikarp EVs or for Battle Item use. This might be harder to compute than the diamonds mode since there are 18 gem currencies and making sure none of them are left behind might be a challenge, even with only 3 different options for each trade (0%, 50% and 100%) this significantly increases the compute involved compared to 2 (0% or 100%), an alternative option would be autoTrading the gems (would need a toggle) which would convert any plates into gems where the total value of the gems/plates is less than the average for all gems/plates the idea being that it would sink plates where there are least gems and raise the average over time. Again (like Mode 1) it might show the most effective path and the estimated value in X days, and it could have the same toggle to count down or keep updating the look ahead.

Mode 3, "I'm looking for balance", Equalisation, Look at each of today's deals and try to make the value of each item pair equal (if that is possible without sacrificing value). For Value I'd go with Diamonds item count for items with a Diamond value, for all other items that can be on both sides of trades without a diamond value then 1 item count, for items with no diamond value and are only final destinations for trading (so shards, evolution stones, etc) then the value of these is rather nebulous, I'd use some small multiplier like 0.000001 the total value of all other items for the value of each of these upto some X and after that the value is 0... for example, if my total value is 30,000 and I need 103 firestones to get all my EVs to 50 then the first 103 firestones each have a value of 0.03 and the 104th+ have a value of 0, it's probably not worth buying firestones at this point because the value of them would be less than the value of the items on the other side of the trade. if I had 3,000,000 total value instead then each of those firestones is worth 3, so owning 103 firestones instead of 206 plates is a good trade. Similarly, for shards having enough to buy all the furfrou (star) to get 50 EVs is good but only so long as doing that doesn't kill your ability to grow value by trading significantly faster than mining. Because of the way some items trade 1 for 2 or 1 for 3 being a good thing while 3 for 1 or 2 for 1 are disregarded as "sacrificing value" this mode should gradually ramp the value while only looking at the shortest-term plan... This mode is likely the most computationally efficient, it doesn't need to look at thousands of trades to decide on an optimised-ish route, it just looks at today one trade at a time. Does X have a greater value than Y? Yes then n = Max(0, Min(Y_limit-Y_current_count, floor((X_current_countY_trade_quantity - Y_current_count*X_trade_Quantity)/2))) does X+Y+n trades have a greater value than X+Y? Yes, Trade n, else does X+Y+1 trade have greater value than X+Y? Yes trade 1, that's a lot less code than some of the mods, and it doesn't need to be run every tick, once or twice a day would be sufficient, every 5 minutes would be overkill. This might display tomorrow's trades and the chosen path for them.

Mode 4, "I don't care anymore just give me the things", Cash Out, allow users to input their own targets for each item that can be traded (even the ones that don't appear in the treasures tab), the mod will try to get to these as fast as possible and consider the user's setting as the 0 level for that item... It could ask "do we have enough of a destination item", and do the trade that maximises the amount of the destination item without eating into the spending item, and it could look at other modes where 2 of these agree a trade is a good move/needed then Mode 4 would ramp passively. Mode 1 and Mode 2 should line up pretty well for the early stages if the number of days looking ahead is large (getting into a cycle that ramps value as fast as possible but exiting at different points or in different directions), and one or other of them would line up with Mode 3 if the number of days is small, these provide some ramp and access to different trades but really ramp isn't the goal of this mode. Since it is trying to rush to a goal it will always be shortsighted sacrificing ramp for giving the user their desired items. This mode has the downside that it will stall if the user hasn't built up enough value to work with. This is also the most heavy to compute and inefficient since it's trying to do all three of the above modes while actively ignoring some of the ability to ramp further. It would be nice if this could estimate the number of days until all the targets have been reached, but I don't really think that'd be possible it's probably already unreasonable to compute, a % complete bar might be nice though.

All of these have the same problem as the deal chains calculator, any trades made into Heartscales are ultimately a dead end because there's not a single step that gets you more or even equal value, it can often take 3 or 4 trades to get to a bigger diamond value, but I thought all of this was interesting to think about, it might be useful to have a 'cap diamond value at 3' for the Star Piece, Max Revive, Heartscale, Old Key Stone, and Hard Stone to prevent them being dead ends except on very rare occasions.

I'm sure there are other possible modes that people might want and each might have their uses which was why I didn't suggest a one-size-fits-all autotrade toggle/mod. Coding this in such a way that someone could come along and build their own modes would be awesome, and having the modes return an array for the number of each trade they'd do would allow for calling one mode from within another (so long as people don't accidentally make loops, there could be a recursion boolean to prevent this -> is this being called by another mode don't call other modes, [if that is a necessary part of this mode then return an array of zeros for each available trade instead])

umbralOptimatum commented 1 month ago

Given trades no longer increase the number of items, and an upcoming underground overhaul (possibly next update) will be cutting back trades further, I don't think this is worth the effort.

JohnyDL commented 1 month ago

That's disappointing, but understandable I'll be manually doing as much as I can in the meanwhile