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

Updated Serene Grace checks in AI_CheckViability #2218

Merged
merged 2 commits into from
Sep 5, 2022

Conversation

LOuroboros
Copy link
Collaborator

Description

It doesn't look like the original author of this suggestion wants to submit a PR themselves, so I'm just gonna do it myself.

Originally brought up by Skeli#3917 in Pret's Discord server.
The checks that encourage the AI to use certain moves with secondary effects if their Pokémon has the ability Serene Grace could use an extra check, so it won't give preferential treatment to moves like Rock Tomb, which despite having a secondary effect, already have a 100% chance of activating said effect.

I wanted to add the check in a small function since that was nicer to read, something like:

bool32 DoesMoveHaveSecondaryEffectChance(u16 moveId)
{
    if (gBattleMoves[moveId].secondaryEffectChance > 0 && gBattleMoves[moveId].secondaryEffectChance < 100)
        return TRUE;
    else
        return FALSE;
}

From what I understand though, the AI calculations are pretty heavy as is, so maybe adding extra function calls without a good reason wouldn't be wise. Then again, surely, a single cheap function call wouldn't do harm. Any thoughts on that?

Also, there was double score addition for EFFECT_SPEED_DOWN_HIT using the same checks for some reason, so I removed one of them and raised the score addition for the check within if (ShouldLowerSpeed(battlerAtk, battlerDef, AI_DATA->abilities[battlerDef])) by 1.

Discord contact info

Lunos#4026

Copy link
Collaborator

@ghoulslash ghoulslash left a comment

Choose a reason for hiding this comment

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

might be cleaner to replace the u8 secondaryEffectChance to bool32 sereneGraceBoost = (AI_DATA->abilities[battlerAtk] == ABILITY_SERENE_GRACE && (gBattleMoves[move].secondaryEffectChance && gBattleMoves[move].secondaryEffectChance < 100); and then replace all of these instances with just if (sereneGraceBoost)`

@ghoulslash
Copy link
Collaborator

Another thing that came up in the pret server is that we don't necessarily want to boost Bubble, for example, since serene grace will only give a 20% chance, and bubble isn't that good of a move. So maybe the sereneGraceBoost check should only be true if the secondary effect chance is like 20<=x<100?

@LOuroboros
Copy link
Collaborator Author

LOuroboros commented Aug 2, 2022

20<=x<100

Just to make sure that I'm understanding the point correctly, you mean >= 20 && < 100, right? 👀

@ghoulslash
Copy link
Collaborator

20<=x<100

Just to make sure that I'm understanding the point correctly, you mean >= 20 && < 100, right? 👀

Yep!

@LOuroboros
Copy link
Collaborator Author

20<=x<100

Just to make sure that I'm understanding the point correctly, you mean >= 20 && < 100, right? 👀

Yep!

Done 👀

@AsparagusEduardo AsparagusEduardo changed the base branch from battle_engine to master August 24, 2022 04:53
DizzyEggg
DizzyEggg previously approved these changes Aug 24, 2022
@AsparagusEduardo
Copy link
Collaborator

Now that I think about it, we should probably add a comment as to why it only checks from 20% onwards. I got confused until I read @ghoulslash's comment in this thread.

@ghoulslash
Copy link
Collaborator

Now that I think about it, we should probably add a comment as to why it only checks from 20% onwards. I got confused until I read @ghoulslash's comment in this thread.

Agreed. @LOuroboros can you add a comment?

@LOuroboros
Copy link
Collaborator Author

Now that I think about it, we should probably add a comment as to why it only checks from 20% onwards. I got confused until I read @ghoulslash's comment in this thread.

Agreed. @LOuroboros can you add a comment?

I meeean... sure, I don't mind, but it's probably going to look ugly since sereneGraceBoost occupies most of the line.

sublime_text_20220824_112005218

@LOuroboros
Copy link
Collaborator Author

Done 👀

@AsparagusEduardo
Copy link
Collaborator

going to look ugly since sereneGraceBoost occupie

Yeah, in those cases what I do is put the comment above the line of code needed.

@LOuroboros
Copy link
Collaborator Author

going to look ugly since sereneGraceBoost occupie

Yeah, in those cases what I do is put the comment above the line of code needed.

Alrighty.

Should I rebase and force push? This doesn't look like something that should take 5 commits, lol.

@AsparagusEduardo
Copy link
Collaborator

going to look ugly since sereneGraceBoost occupie

Yeah, in those cases what I do is put the comment above the line of code needed.

Alrighty.

Should I rebase and force push? This doesn't look like something that should take 5 commits, lol.

Neither? Just add another commit to your branch and normal push

@LOuroboros
Copy link
Collaborator Author

LOuroboros commented Aug 24, 2022

going to look ugly since sereneGraceBoost occupie

Yeah, in those cases what I do is put the comment above the line of code needed.

Alrighty.
Should I rebase and force push? This doesn't look like something that should take 5 commits, lol.

Neither? Just add another commit to your branch and normal push

I mean, I already did push the commit moving the comment.

I was asking if I should rebase and force push to clean up this PR before it's merged.

@AsparagusEduardo
Copy link
Collaborator

AsparagusEduardo commented Aug 24, 2022

I've never seen the point of "cleaning up" PRs. If you want to see the overall changes of a PR in a single commit, that's what the merge commit is for imo

@LOuroboros
Copy link
Collaborator Author

I've never seen the point of "cleaning up" PRs.

A cleaner Git history.

@StephenLynx
Copy link

Its easier to understand a change the fewer commits it is spread across.

@AsparagusEduardo
Copy link
Collaborator

Alright, I'll allow this time :P

@LOuroboros
Copy link
Collaborator Author

Alright, I'll allow this time :P

k.

Done.

@AsparagusEduardo AsparagusEduardo dismissed ghoulslash’s stale review September 5, 2022 13:30

Ghoul's suggested changes have already been implemented, dismissing to merge.

@AsparagusEduardo AsparagusEduardo merged commit 99a9b9f into rh-hideout:master Sep 5, 2022
@LOuroboros LOuroboros deleted the patch-1 branch September 5, 2022 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants