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

AI switches in absorbing mon incorrectly #6124

Open
Pawkkie opened this issue Jan 26, 2025 · 0 comments
Open

AI switches in absorbing mon incorrectly #6124

Pawkkie opened this issue Jan 26, 2025 · 0 comments
Labels
bug Bug category: battle-ai Pertains to Battle Engine Upgrade's AI status: confirmed This bug has been confirmed to exist in the codebase

Comments

@Pawkkie
Copy link
Collaborator

Pawkkie commented Jan 26, 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 to track if the AI sent out a new mon on the previous turn, and if they have, return false inside FindMonThatAbsorbsOpponentsMove. This can then be overridden once we have AI_FLAG_PREDICT_MOVE.

I had a PR for this #6118 that I couldn't get to work properly, tried a few different implementations (only one of which ever got committed), need to take a break. Issue instead lol.

Here's a test it needs to pass

AI_SINGLE_BATTLE_TEST("AI_FLAG_SMART_SWITCHING: AI won't switch in absorbing mon immediately after sending out new mon")
{
    GIVEN {
        AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_TRY_TO_FAINT | AI_FLAG_CHECK_VIABILITY | AI_FLAG_SMART_SWITCHING | AI_FLAG_SMART_MON_CHOICES | AI_FLAG_OMNISCIENT);
        PLAYER(SPECIES_BLAZIKEN) { Moves(MOVE_FLAMETHROWER, MOVE_CLOSE_COMBAT); }
        OPPONENT(SPECIES_FERROTHORN) { Moves(MOVE_GYRO_BALL); }
        OPPONENT(SPECIES_DIALGA) { Moves(MOVE_DRACO_METEOR); }
        OPPONENT(SPECIES_HEATRAN) { Moves(MOVE_EARTH_POWER, MOVE_FLAMETHROWER); }
    } WHEN {
        TURN { MOVE(player, MOVE_FLAMETHROWER); EXPECT_SEND_OUT(opponent, 1); }
        TURN { MOVE(player, MOVE_CLOSE_COMBAT); EXPECT_MOVE(opponent, MOVE_DRACO_METEOR); }
    }
}

Version

upcoming (Edge)

Upcoming/master Version

No response

Discord contact info

@Pawkkie

@Pawkkie Pawkkie added bug Bug category: battle-ai Pertains to Battle Engine Upgrade's AI status: confirmed This bug has been confirmed to exist in the codebase labels Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug category: battle-ai Pertains to Battle Engine Upgrade's AI status: confirmed This bug has been confirmed to exist in the codebase
Projects
None yet
Development

No branches or pull requests

1 participant