Skip to content
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

Fix AI switching in absorbing mon incorrectly #6227

Merged
merged 2 commits into from
Feb 9, 2025

Conversation

Pawkkie
Copy link
Collaborator

@Pawkkie Pawkkie commented Feb 9, 2025

Description

The AI uses FindMonThatAbsorbsOpponentsMove to determine if it should switch in an absorber. This function isn't used when determining what mon to send in after a KO, so there are cases where they AI sends in a new mon, then immediately switch in a mon to try to absorb the incoming attack.

This doesn't sound like bad behaviour, except the AI isn't predicting the incoming attack, it is just referencing whatever attack the player used most recently. This data is no longer reliable if the AI has just sent out a new mon for the player to engage with, so this behaviour should be disabled if the AI just sent out a new mon.

Basically we need some method of checking whether the mon the AI is currently analyzing is the same mon that the player was attacking on the previous turn, as if it isn't we can't assume their moves anymore (without prediction).

This PR fixes this by tracking the AI's species across a turn, and evaluating if the battler at the start of turn X is the same species as the mon at the start of turn X - 1.

Tagging #5229 because this behaviour will need to be overridden if the AI is using AI_FLAG_MOVE_PREDICTION, but that flag doesn't exist yet, and this will remind me to do so when I eventually get to that feature request lol

Issue(s) that this PR fixes

Closes #6124

Discord contact info

@Pawkkie

@Pawkkie Pawkkie added category: battle-ai Pertains to Battle Engine Upgrade's AI bugfix Bugfixes labels Feb 9, 2025
@Pawkkie Pawkkie marked this pull request as draft February 9, 2025 19:28
@Pawkkie Pawkkie marked this pull request as ready for review February 9, 2025 20:52
@Pawkkie
Copy link
Collaborator Author

Pawkkie commented Feb 9, 2025

Fixed and undrafted lol

Copy link
Collaborator

@AlexOn1ine AlexOn1ine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a smart fix. I was going to suggest something like switchin sickness but this is a more general approach that can be applied elsewhere

@AlexOn1ine AlexOn1ine merged commit bd50fe6 into rh-hideout:upcoming Feb 9, 2025
1 check passed
@Pawkkie Pawkkie deleted the fix-absorbing-switches branch February 9, 2025 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Bugfixes category: battle-ai Pertains to Battle Engine Upgrade's AI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants