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

Add AI_FLAG_PREDICT_INCOMING_MON: AI will score against predicted switchin if predicting switch #6037

Merged
merged 16 commits into from
Jan 20, 2025

Conversation

Pawkkie
Copy link
Collaborator

@Pawkkie Pawkkie commented Jan 16, 2025

Description

If the AI is predicting the player will switch using AI_FLAG_PREDICT_SWITCH introduced in #6028, this PR allows the AI to run its scoring functions against the predicted incoming mon rather than against the target that the AI thinks is about to switch out. This lets us take advantage of the prediction code to have much more sophisticated emergent behaviour, like using a Fighting-type move on a predicted switch to a Steel-type while the player's currently active mon is a Gengar.

Also includes handling to identify if the AI has a chase-effect move (ie. Pursuit), and if so, passes the predicted switchout mon for scoring for that move specifically rather than the switchin mon that it uses for everything else.

The last missing piece of this puzzle is to track the player's knowledge of the AI, through a sort of reverse AI_FLAG_OMNISCIENT. As is, things like crazy "use Focus Punch against a Gengar with a predicted TTar switchin" won't happen because the AI knows its own mon has Focus Punch, and thus won't see the player's TTar as a good switchin candidate. It'd be ideal for the AI to just use the player's knowledge in its predictions. That's future work though lol

Issue(s) that this PR fixes

Closes #5227

Discord contact info

@Pawkkie

@Pawkkie Pawkkie added new-feature Adds a feature category: battle-ai Pertains to Battle Engine Upgrade's AI labels Jan 16, 2025
@Pawkkie Pawkkie marked this pull request as draft January 16, 2025 21:07
@Pawkkie Pawkkie marked this pull request as ready for review January 18, 2025 00:57
@Pawkkie
Copy link
Collaborator Author

Pawkkie commented Jan 18, 2025

Miraculously got this actually working, and it's ready for review :D

@Pawkkie Pawkkie changed the title AI will score against predicted switchin if predicting switch Add AI_FLAG_PREDICT_INCOMING_MON: AI will score against predicted switchin if predicting switch Jan 20, 2025
@Pawkkie
Copy link
Collaborator Author

Pawkkie commented Jan 20, 2025

I extended this to include handling to identify if the AI has a chase-effect move (ie. Pursuit) and pass the predicted switchout mon for scoring for that move specifically rather than the switchin mon that it uses for everything else. It's a bit gross by necessity, and I'm open to ideas for cleaning it up lol

}
}

AI_SINGLE_BATTLE_TEST("AI_FLAG_PREDICT_SWITCH: AI would normally choose prediction-informed move against mon in predicted-incoming-mon scenario")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm kinda lost at what exactly is being checked here, since the player and opponent only have one mon each?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's basically a sanity check for the predict-incoming scenario.

In that scenario, the test passes if it uses the move that I know scores the highest against the incoming mon.

In this test, I confirm that the move I'm checking against in the other test is in fact the highest scoring against the incoming mon in a vaccuum.

It's a sort of safety valve / sanity check, so if the other test ever fails AND this test fails, we know the prediction isn't broken, just that the score of the AI's moves has changed in a vaccuum which will also affect the switching test.

Hopefully that makes sense :D

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I (think) I get it. Could you summarize it in a nice comment and give the other test's name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Pushed comment, let me know if that clarifies :)

@DizzyEggg
Copy link
Collaborator

All good to me, unless @AlexOn1ine has any objections, I'll hit the merge button

@DizzyEggg DizzyEggg merged commit 7d39dd4 into rh-hideout:upcoming Jan 20, 2025
1 check passed
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 new-feature Adds a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants