-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch AI uses trapping abilities aggressively #4669
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few things but looks good otherwise
Ready for re-review :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry didn't catch those first.
Non blocking but do you think it makes sense to make a new test file for the switch ai tests?
YES I thought you'd never ask <3 I'll move everything that has a switch AI flag into its own file called ai_switching.c :) |
This was an extra good idea because I found
while doing it, which links all the way back to #3346 . D'you think we should wait for Egg to be around or is this something we can brainstorm for and then ping Egg when we have an implementation idea? It's something I'm interesting in poking around with in the near future now that I've remembered it exists :) |
You could ping him if you want but I don't think we should intentionally wait for him. |
Description
Encourages the AI to use the trapping abilities Shadow Tag, Arena Trap, and Magnet Pull in its switching decisions. Post-KO trapping switches are tied to the AI_FLAG_SMART_MON_CHOICES, and mid-battle trapping switches are tied to AI_FLAG_SMART_SWITCHING (which requires AI_FLAG_SMART_MON_CHOICES anyways).
The AI will switch in a trapper under the following conditions:
"Winning the 1v1" in this case is defined as KO'ing the player before they get KO'd themselves, based on the same hitsToKO calculations used elsewhere in the switch and scoring AI. These thresholds are different depending on whether the AI is switching mid-battle and needs to tank a hit vs after a KO and doesn't need to, and both cases are accounted for.
I've also included tests for both mid-battle and post-KO cases, as well as one to ensure the trapping mon isn't switched in preferentially when the player doesn't have any mons in their party.
I'm open to the idea of tying some random roll to these behaviours to make them more difficult to predict, though it will also make them more difficult to test as far as I understand it. The HasBadOdds() function uses a 50% chance of failure as a benchmark, but that function is significantly more likely to lead to switch spam than the trapper conditions, which won't lead to switch spam and will instead just deterministically switch in the trapper when the conditions are met. I'm not sure what threshold would be considered appropriate if any at all, but I'm happy to add one in to increase the variance if that's preferred!
This also includes some very minor refactoring in
GetBestMonIntegrated
to clean up some conditionals for readability.Discord contact info
@Pawkkie