-
Notifications
You must be signed in to change notification settings - Fork 8
feat(ai): AI Rework v1.0: Enemy Command Selection #1289
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
Draft
innerthunder
wants to merge
63
commits into
beta
Choose a base branch
from
ai-rework
base: beta
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 30 commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
99e1571
[AI-Rework] Add starter code for move scoring functions (#356)
innerthunder a6fd730
Merge branch 'beta' into ai-rework
innerthunder dcb5294
Merge branch 'beta' into ai-rework
innerthunder 8683c7a
Merge branch 'beta' into ai-rework
innerthunder ab30a8e
[AI-Rework] Rewrite enemy command selection (#403)
innerthunder d750b99
[AI-Rework] Add move-property-based scoring (#442)
innerthunder aaed8bf
Merge branch 'beta' into ai-rework
innerthunder 62bcdc7
Prettier
innerthunder e3f3e56
Merge branch 'beta' into ai-rework
innerthunder 7922965
Fix remaining conflicts from latest merge
innerthunder 7c6dd9a
[AI-Rework] Add Move Attribute scoring parameters under `MoveAttrOpti…
innerthunder 7155e44
Merge branch 'beta' into ai-rework
innerthunder 28f65ee
Resolve remaining merge conflicts
innerthunder 9246262
Merge branch 'beta' into ai-rework
innerthunder 7f6b1bc
Resolve leftover conflicts from last merge
innerthunder 6e2538e
Merge branch 'beta' into ai-rework
innerthunder 19def79
Resolve remaining conflicts from last merge
innerthunder 515eb12
[Addendum][AI-Rework][Test] Add matchers + Improve test utils (#1125)
innerthunder ffc11ff
[AI-Rework] Add effect scores for ability-changing effects (#834)
innerthunder 56c5493
[AI-Rework] Add effect scores for arena-tag-based moves (#1158)
innerthunder 899189d
Merge branch 'beta' into ai/beta-update-1
innerthunder 700193e
Fix typecheck and linter issues
innerthunder dadd6c9
[AI-Rework] Rewrite `MoveCondition` + update Condition Score logic (#…
innerthunder 7364400
Merge branch 'beta' into ai-rework
innerthunder 006c3ce
Resolve remaining conflicts from last merge
innerthunder c1095d5
[AI-Rework] Remove `appliesScoreOnKO` option (#1222)
innerthunder 30099ae
[AI-Rework] Add caching for invariant scoring calculations (#1258)
innerthunder 1e06496
Merge branch 'beta' into ai-rework
innerthunder ede5db1
Run linter
innerthunder f95af98
[AI-Rework] Re-implement Instant Tera commands (#1283)
innerthunder 6fafb86
Resolve merge issues
DayKev e5421d8
Remove unnecessary optional chaining
DayKev d7a7750
Apply review suggestions
innerthunder bbbb984
[AI-Rework] Add effect scores for moves with `BattlerTag` effects (#1…
innerthunder 556a779
[AI-Rework] Add Effect Scores for Arena/Battler-tag-modifying effects…
innerthunder 651c183
Merge branch 'beta' into ai-rework
innerthunder b2f357d
Merge branch 'ai-rework' of https://github.com/Despair-Games/poketern…
innerthunder 0ea4e60
Resolve merge issues
innerthunder 17b1c37
Fix flaky Rapid Spin tests
innerthunder b8fe6d0
ai-rework: Add Effect Scores for Status Effect inflicting moves (#1312)
innerthunder 367886d
Simplify Wake Up Slap condition
innerthunder 34e12f9
ai-rework: Add Effect Scores for misc. status-effect-related attribut…
innerthunder ebc2e1a
ai-rework: Add Effect Scores for healing effects (#1330)
innerthunder 5c07d48
Merge branch 'beta' into ai-rework
innerthunder 810d6c9
Fix linter issues
innerthunder 783e2ee
Merge branch 'beta' into ai-rework
innerthunder b669649
Run linters
innerthunder b50943f
ai-rework: Rewrite Ally Target scoring logic (#1331)
innerthunder 4814b46
ai-rework: Add scoring for `StatStageChangeAttr` + subclasses (#1337)
innerthunder 9e94fca
Merge branch 'beta' into ai-rework
innerthunder cf0d2d4
Fix leftover conflict in `overrides-helper`
innerthunder 42b9785
Reduce Focus Energy test flakiness
innerthunder d9069b8
ai-rework: Move ability- and move-revealing test utils to `FieldHelpe…
innerthunder 5eafff2
Add AI paths to `create-test` script
innerthunder eba3d5f
ai-rework: Add Effect Scores for misc. stat-modifying attributes (#1340)
innerthunder 14cdeb9
ai-rework: Rework multi-target move scoring logic (#1344)
innerthunder 816c015
ai-rework: Add Effect Scores for self-damaging move effects (#1346)
innerthunder c35fef1
ai-rework: Add Effect Scores for Terrain- and Weather-changing effect…
innerthunder ad39b43
ai-rework: Update Effect Score calculation for charge moves (#1358)
innerthunder 204dfd8
Merge branch 'beta' into ai-rework
innerthunder c80f075
Merge branch 'beta' into ai-rework
innerthunder 5015ca4
Replace `isNil` references
innerthunder 2bedbae
ai-rework: Add Effect Scores for type-modifying moves (#1362)
innerthunder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,12 @@ | ||
| import type { Pokemon } from "#field/pokemon"; | ||
| import type { Move } from "#moves/move"; | ||
|
|
||
| export type MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => boolean; | ||
| /** | ||
| * A function representing a {@linkcode Move | Move's} condition. | ||
| * @param user - The {@linkcode Pokemon} using the move | ||
| * @param target - The {@linkcode Pokemon} targeted by the move | ||
| * @param move - The {@linkcode Move} being used | ||
| * @param simulated - (Optional) If `true`, suppresses changes to game state | ||
| * @returns `true` if the condition is satisfied in the given battle state | ||
| */ | ||
| export type MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move, simulated?: boolean) => boolean; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import type { MoveId } from "#enums/move-id"; | ||
|
|
||
| /** | ||
| * A function to filter moves based on their properties. | ||
| * @param moveId - The {@linkcode MoveId} of the move to evaluate | ||
| * @returns `true` if the filter applies to the given move | ||
| */ | ||
| export type MoveFilter = (moveId: MoveId) => boolean; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* eslint-enable @typescript-eslint/no-unused-vars */ | ||
| // -- end tsdoc imports -- | ||
|
|
||
| import type { MoveId } from "#enums/move-id"; | ||
|
|
||
| /** | ||
| * Caches invariant data for the Enemy AI to reuse | ||
| * during its score calculations for turn action selection against | ||
| * a "target" {@linkcode Pokemon}. This is stored within a "source" | ||
| * Pokemon's {@linkcode PokemonTurnData}, and is thus reset at the start of each turn. | ||
| */ | ||
| export interface PokemonScoreData { | ||
| /** | ||
| * A score for grading the source Pokemon's matchup against | ||
| * the target Pokemon. | ||
| * @see {@linkcode EnemyPokemon.getMatchupScore} | ||
| */ | ||
| matchupScore?: number; | ||
| /** | ||
| * The expected values of the source Pokemon's Attack Scores | ||
| * against the target Pokemon for each of the source's moves. | ||
| * @see {@linkcode Pokemon.getExpectedAttackScore} | ||
| */ | ||
| expectedAttackScores: Map<MoveId, number>; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,8 @@ | ||
| import type { MoveId } from "#enums/move-id"; | ||
| import type { Arena } from "#field/arena"; | ||
|
|
||
| /** | ||
| * A function to check if a move with the given {@linkcode MoveId} | ||
| * can have its effects negated by a {@linkcode ConditionalProtectTag | conditional protection} | ||
| * field effect (e.g. Wide Guard). | ||
| */ | ||
| export type ProtectConditionFunc = (arena: Arena, moveId: MoveId) => boolean; | ||
| export type ProtectConditionFunc = (moveId: MoveId) => boolean; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /* eslint-enable @typescript-eslint/no-unused-vars */ | ||
| // -- end tsdoc imports -- | ||
|
|
||
| /** The {@link Pokemon.getAttackScore | Attack Score} granted to moves that KO an opponent. */ | ||
| export const KO_ATTACK_SCORE = 4; | ||
|
|
||
| /** | ||
| * The damage (in terms of % maximum HP) a projected attack must deal | ||
| * to a target to reach the next scoring "tier". An attack projected to deal | ||
| * damage below this threshold will receive an Attack Score of either 0 or 1. | ||
| * On the other hand, attacks projected to deal damage above this threshold | ||
| * will receive an Attack Score of either 1 or 2. | ||
| * @see {@linkcode Pokemon.getAttackScore} | ||
| * @see {@linkcode Pokemon.getExpectedAttackScore} | ||
| */ | ||
| export const ATTACK_SCORE_HP_THRESHOLD = 40; | ||
|
|
||
| /** | ||
| * A relatively major bonus to a move attribute's {@link MoveAttr.getEffectScore | Effect Score}. | ||
| * Used when a move with the attribute gains a decisive advantage in | ||
| * a given battle state. | ||
| */ | ||
| export const MAJOR_EFFECT_SCORE_BONUS = 2; | ||
|
|
||
| /** | ||
| * A relatively minor bonus to a move attribute's {@link MoveAttr.getEffectScore | Effect Score}. | ||
| * Used when a move with the attribute gains a slight advantage in | ||
| * a given battle state. | ||
| */ | ||
| export const MINOR_EFFECT_SCORE_BONUS = 1; | ||
|
|
||
| /** | ||
| * A relatively major penalty to a move's score. Used when a move has | ||
| * a significant drawback or is likely to fail from an unresolvable condition | ||
| * in a given battle state. | ||
| */ | ||
| export const MAJOR_EFFECT_SCORE_PENALTY = -MAJOR_EFFECT_SCORE_BONUS; | ||
|
|
||
| /** | ||
| * A relatively minor penalty to a move's score. Used when a move has | ||
| * a potential drawback or has a chance of failing from an unresolvable condition | ||
| * in a given battle state. | ||
| */ | ||
| export const MINOR_EFFECT_SCORE_PENALTY = -MINOR_EFFECT_SCORE_BONUS; | ||
|
|
||
| /** | ||
| * A weakly enforced upper limit for move attributes' {@link MoveAttr.getEffectScore | Effect Scores}. | ||
| * Attributes generally shouldn't give enough of a bonus to supersede | ||
| * attacks that can KO opponents. | ||
| */ | ||
| export const SOFT_EFFECT_SCORE_LIMIT = KO_ATTACK_SCORE - 1; | ||
|
|
||
| /** | ||
| * The score penalty granted to moves that effectively do nothing, e.g. | ||
| * - Attacking into an opponent with a known immunity via typing, Ability, etc. | ||
| * - Using a move that is known to fail before selection. | ||
| * - Using Skill Swap on an enemy with a bad ability (e.g. Truant) | ||
| */ | ||
| export const BAD_MOVE_PENALTY = -5; | ||
|
|
||
| /** | ||
| * The score penalty granted by default when targeting an ally in a double battle. | ||
| * This should prevent the AI from deciding to attack their ally, for example. | ||
| * Certain move attributes may {@link MoveAttrOptions.overridesAllyTargetPenalty | override this penalty}. | ||
| */ | ||
| export const ALLY_TARGET_PENALTY = -20; | ||
|
|
||
| /** | ||
| * The score penalty granted when targeting a Pokemon that is {@link https://bulbapedia.bulbagarden.net/wiki/Commander_(Ability) | Commanding} | ||
| * its ally. The AI should always expect this move to miss. | ||
| */ | ||
| export const COMMANDING_TARGET_PENALTY = -20; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.