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

Bug: AI_Smart_Encore can lead to incorrect type matchup checks #785

Open
UnderscorePoY opened this issue Nov 17, 2020 · 3 comments
Open
Labels

Comments

@UnderscorePoY
Copy link

UnderscorePoY commented Nov 17, 2020

File : engine/battle/ai/scoring.asm
(linked to Draft Pull Request #784)

The raw call to CheckTypeMatchup might have some oversights.

  • Contrarily to the general comment of this routine, since wEnemyMoveStruct is
    populated with the last player move, this will be used properly in
    CheckTypeMatchup (putting it in a is indeed not how to use the matchup
    routine, but it is irrelevant in that case).

  • However, if the AI flow can lead to this clause being called with a
    hBattleTurn set to 0, the type matchup will consider the player types
    instead of the enemy types.

  • AI layers which can cause this oversight if called before AI_Smart_Encore
    (without hBattleTurn being set back to 1 unvoluntarily) :

    • AI_Smart_Conversion2
    • TODO : there could be some other very tricky situations like the last turn
      using Metronome->Conversion2 if the AI switching conserves hBattleTurn, etc.
  • AI layers which unvoluntarily avoid this oversight (by setting hBattleTurn to 1) :

    • AI_Types (SuperNerd, Juggler, ExecutiveM/F, PokefanM/F).
    • AI_Status reaching the .typeimmunity jump label.
    • AI_Smart_LeechHit.
    • AI_Smart_LockOn when the player isn't locked on.
    • AI_Smart_Mimic when player used a move & enemy HP > 50%.
    • AI_Smart_PriorityHit when the enemy is slower or speedtied
      and the player is not using Fly or Dig.
    • AI_Smart_HiddenPower.

Example (not encoutered in vanilla) :

  • Player : Ho-Oh with Mud-Slap.
  • Enemy : SMART_AI Raichu with Conversion2, Encore in that order (any other moves before or after).
  • Turn 1 : Raichu uses another move. Ho-Oh uses Mud-Slap.
  • Turn 2 : Raichu will wrongly consider types and will use Ho-Oh's after the AI_Smart_Conversion2 layer. It will see Ho-Oh as immune to Mud-Slap and consider this matchup its. Thus Encore is 72% greatly encouraged (-2 score) despite Mud-Slap being super-effective against Raichu.
@UnderscorePoY UnderscorePoY changed the title BUG : Ai_Smart_Encore can lead to incorrect type matchup checks Bug : AI_Smart_Encore can lead to incorrect type matchup checks Nov 17, 2020
@FredrIQ
Copy link
Contributor

FredrIQ commented Feb 2, 2021

I'm fairly sure that the AI in general assumes that SetEnemyTurn has been prepared, meaning that the problem here is Conversion2, not Encore?

@rawr51919
Copy link
Contributor

Wondering if the documentation from #656 fixed this originally

@rawr51919
Copy link
Contributor

Documented in #936, awaiting on a fix

@Rangi42 Rangi42 changed the title Bug : AI_Smart_Encore can lead to incorrect type matchup checks Bug: AI_Smart_Encore can lead to incorrect type matchup checks Jul 21, 2022
@Rangi42 Rangi42 changed the title Bug: AI_Smart_Encore can lead to incorrect type matchup checks Bug: AI_Smart_Encore can lead to incorrect type matchup checks Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants