zengm-games / zengm

Basketball GM (and other ZenGM games) are single-player sports management simulation games, made entirely in client-side JavaScript.
https://zengm.com
Other
349 stars 127 forks source link

Only dynamically update pick value when trading with user #439

Closed sumitde22 closed 1 year ago

sumitde22 commented 1 year ago

Same concept/results/testing as all the other PRs I made

Almost all of the previous trade logic is also retained, so not a big diff for this one

The difference in this one is the AI only reevaluates picks in the trade when trading with the user - in AI-to-AI trades the previous behavior is retained

There seems to be some precedent for this type of thing as I see this as adding onto the previous logic of the AI applying "fuzz" as I see if (tradeWithUser && seasons > 0) { if (usersPick) { // Penalty for user draft picks const difficultyFactor = 1 + 1.5 * g.get("difficulty"); estPick = helpers.bound( Math.round((estPick + numPicksPerRound / 3.5) * difficultyFactor), 1, numPicksPerRound, ); } else { // Bonus for AI draft picks estPick = helpers.bound( Math.round(estPick - numPicksPerRound / 3.5), 1, numPicksPerRound, ); } }

draft picks are valued differently if the AI is trading with the user

sumitde22 commented 1 year ago

Think everything you mentioned is fixed, lmk if there's anything else that should be fixed

sumitde22 commented 1 year ago

Made the small fixes. I think going forward if there's small minor adjustments it's prob easier for you to do them, but if there's bigger changes needed or an issue that needs to be debugged I can look into those

dumbmatter commented 1 year ago

Thanks! I will try to get this out tonight, or maybe tomorrow if I decide to write a long blog post (since there is quite a history of attempts at improving the trade AI, and it's something a lot of people are interested in)

sumitde22 commented 1 year ago

One final niche note on this:

This solves the exploit in user-to-AI trades. In AI-to-AI trades, the exploit (tanking a team's ovr while also getting their 1st round picks) is mitigated by the maxAssetsToAdd param that is specified in these AI-to-AI trades. Like when trading with the user, sometimes the AI is willing to give up 10 players which would obviously sabotage its team, but the amount of players exchanged is limited in AI-to-AI trades, so even if some AI-to-AI trades are a little unbalanced, the degree to which they are is not overwhelming.