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_FLAG_RISKY Improvements #4648

Merged
merged 6 commits into from
May 29, 2024

Conversation

Pawkkie
Copy link
Collaborator

@Pawkkie Pawkkie commented May 29, 2024

Description

#4615 added the ability to choose what damage rolls the AI uses when scoring its moves, which introduced the concept of having the pre-existing AI_FLAG_RISKY assume it gets high rolls and score accordingly. This prompted discussing a minor overhaul to AI_FLAG_RISKY, which is otherwise just a simple list of effects that the AI will score more highly.

After that initial discussion, we decided that a fun risky AI would:

  • Prioritize maximizing damage from moves at the cost of accuracy (I'm interpreting this as "When comparing damaging moves, the AI only considers accuracy if expected damage is the same (ie. multiple neutral attacks with the same power), even if hits to KO are the same (if the player switches the AI still wants to do the biggest chunk of damage it can)")
  • Prioritize moves with low chance strong effects like Ancient Power (suggestions for this were crowd-sourced)
  • Use high rolls to evaluate damage calculations (already implemented in Damage roll selection in AI_CalcDamage #4615)
  • Switch offensively mid battle rather than defensively (defensive mid-battle is the default behaviour universally, see GetBestMonIntegrated for details)
  • Enjoy using explosion moves (this seems important to keep for some users)

The list of effects that should be prioritized is likely going to expand and change over time as we have more ideas, but as a starting point that list includes the following:

Strongly Prioritize (+3)

  • EFFECT_COUNTER if player mon is physical attacker (if species' base Atk is 10+ higher than SpAtk)
  • EFFECT_MIRROR_COAT if player mon is special attacker (if species' base SpAtk is 10+ higher than Atk)
  • EFFECT_EXPLOSION

Moderately Prioritize (+2)

  • EFFECT_REVENGE if player mon's species has base Speed 10+ higher than AI mon's
  • EFFECT_BELLY_DRUM (at 90+% HP)
  • EFFECT_MAX_HP_50_RECOIL (Steel Beam)
  • EFFECT_MIND_BLOWN
  • EFFECT_SWAGGER
  • EFFECT_FLATTER
  • EFFECT_ATTRACT
  • EFFECT_OHKO
  • MOVE_EFFECT_ALL_STATS_UP (Ancient Power etc.)
  • High critical hit ratio

This list also included considerations for Destiny Bond initially, but it seems well covered elsewhere in the scoring AI as is in my opinion.

Lastly, I've written tests for the more complex behaviours, including Mirror Coat, Counter, Revenge, mid-battle switches, and prioritizing damage at the expense of accuracy.

People who collaborated with me in this PR

Feedback from @AlexOn1ine and @iriv24 in Discord

Discord contact info

@Pawkkie

@Pawkkie
Copy link
Collaborator Author

Pawkkie commented May 29, 2024

I have no idea why the check has failed by adding case EFFECT_MIND_BLOWN:, it passes all tests and compiles without errors on my machine. It even does so if I pull it into a separate clean upcoming branch.

Copy link
Collaborator

@AlexOn1ine AlexOn1ine left a comment

Choose a reason for hiding this comment

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

One thing but looks good otherwise. I will try to investigate why Mind Blown causes the test to fail /Edit ah, it seems like CI broke again.

src/battle_ai_main.c Outdated Show resolved Hide resolved
@AlexOn1ine AlexOn1ine merged commit a0006d8 into rh-hideout:upcoming May 29, 2024
1 check passed
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.

3 participants