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

Better Shed Tail Switch AI Handling #5495

Open
Pawkkie opened this issue Oct 9, 2024 · 0 comments
Open

Better Shed Tail Switch AI Handling #5495

Pawkkie opened this issue Oct 9, 2024 · 0 comments
Labels
category: battle-ai Pertains to Battle Engine Upgrade's AI feature-request Requests a new feature

Comments

@Pawkkie
Copy link
Collaborator

Pawkkie commented Oct 9, 2024

Description

#5494 KNOWN_FAILING'd a broken test that was broken by #5488. The test is very straightforward:

AI_SINGLE_BATTLE_TEST("AI will use Shed Tail to pivot to another mon while in damage stalemate with player")
{
    KNOWN_FAILING; // missing AI code
    GIVEN {
        AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT);
        PLAYER(SPECIES_WOBBUFFET) { Speed(100); Ability(ABILITY_RUN_AWAY); Moves(MOVE_TACKLE, MOVE_CELEBRATE); }
        OPPONENT(SPECIES_WOBBUFFET) { Speed(50); Ability(ABILITY_RUN_AWAY); Moves(MOVE_CONFUSION, MOVE_SHED_TAIL); }
        OPPONENT(SPECIES_SCIZOR) { Speed(101); Moves(MOVE_CELEBRATE, MOVE_X_SCISSOR); }
    } WHEN {
        TURN { MOVE(player, MOVE_TACKLE); EXPECT_MOVE(opponent, MOVE_CONFUSION); }
        TURN { MOVE(player, MOVE_TACKLE); EXPECT_MOVE(opponent, MOVE_SHED_TAIL); }
    }
}

The reason it fails is because the AI mon switches out instead of using Shed Tail. This test should have been failing since its inception, because FindMonWithFlagsAndSuperEffective finds Scizor in the party and triggers a switch to it. FindMonWithFlagsAndSuperEffective depends on gLastLandedMoves to function properly, which wasn't working properly for any switching behaviour until #5488 fixed it.

The ideal solution to this would be to implement "Don't switch if you're going to use Shed Tail", but that requires running the move scoring functions before ShouldSwitch, which is awkward because we need to run ShouldSwitch to use its result in the move scoring. It's also a pile of duplicate code and also feels kinda gross to just score everything tagged with IsSwitchOutEffect in ShouldSwitch because the scoring code is expensive, we really don't want to duplicate it.

I'm not entirely sure what the best implementation to solve this problem is, but I wanted to clarify that it existed in some detail as I'm not sure when it'll get addressed.

Discord contact info

@Pawkkie

@Pawkkie Pawkkie added category: battle-ai Pertains to Battle Engine Upgrade's AI feature-request Requests a new feature labels Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: battle-ai Pertains to Battle Engine Upgrade's AI feature-request Requests a new feature
Projects
None yet
Development

No branches or pull requests

1 participant