cameroncondry / cbc-kitten-scientists

Add-on for the wonderful incremental browser game: http://kittensgame.com/web/
MIT License
114 stars 94 forks source link

Trades too frequent #339

Closed rherban closed 2 years ago

rherban commented 2 years ago

Kittens v 1.4.9.1 KS 1.5.0

I'm trying to understand how the trade trigger works. I have it set to .98 which would tell me wait until gold is 98% of capacity before trading.

But occasionally it will send some trades randomly (but only once). My gold was nowhere near maxed at this point (still had an hour before being at cap). image

But the real problem comes where something causes it to trade as soon as I have 15 gold.
image

I have yet to really nail down what causes it to get in this state though I think it has to do with disabling and re-enabling KS.

oliversalzburg commented 2 years ago

The trade trigger logic is fairly complex and I don't remember everything from the top of my head. You might be able to make more sense of it by reading my analysis comments at https://github.com/oliversalzburg/cbc-kitten-scientists/blob/master/packages/userscript/source/TradeManager.ts and https://github.com/oliversalzburg/cbc-kitten-scientists/blob/master/packages/userscript/source/Engine.ts#L1683

Overall, trading is aggressive and the behavior you're seeing is very likely by-design even if it's confusing.

rherban commented 2 years ago

Thanks for those links.

It sounds like it's the limited feature that's causing the aggressive behavior then? Lines 1728 - 1730:

        // If this trade is not limited, it must either not require anything, or
        // the required resource must be over the trigger value.
        // Additionally, gold must also be over the trigger value.

I originally took limited to mean "trade some, but not all" similar to crafting logic. If this is indeed the logic, then perhaps this should be changed to something like aggressive?

oliversalzburg commented 2 years ago

When I ported the code to TS, I also felt like the meaning of "Limited" overall is very confusing in the userscript. I feel like the meaning isn't entirely clear and the checkbox is sometimes "abused" for certain features that don't make perfect sense.

I believe some of this is the result of the JS code base itself. People just hacked whatever feature they were going for into the script and it lost a clear structure along the way. For the TS rewrite, I expected to add a lot more fine-grained options.

Sadly, I really burned myself out with the initial code conversion and didn't find any motivation to port the most recent changes or make useful further additions :( I hope I can revive work on the project soon, so all the work won't be for nothing.

rherban commented 2 years ago

I totally understand and can relate. Without KS, I probably wouldn't even be playing kittens, so I want you to know how useful it is.

Thanks for what you've done.

cameroncondry commented 2 years ago

Just wanted to chime in and say I'm extremely excited that people still use this script. I haven't played in years but it's always nice to see activity here. @oliversalzburg has been an amazing contributor as well, thank you for the continued support.