Add missing adjust scores (#4925)

* Add missing adjust scores

* ai log made the test fail
This commit is contained in:
Alex 2024-07-08 12:05:32 +02:00 committed by GitHub
parent 4ddae07451
commit 637a7072f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 7 deletions

View file

@ -29,8 +29,9 @@
#define STAT_CHANGE_ACC 10
#define STAT_CHANGE_EVASION 11
#define BEST_DAMAGE_MOVE 1 // Move with the most amount of hits with the best accuracy/effect
#define POWERFUL_STATUS_MOVE 10 // Moves with this score will be chosen over a move that faints target
#define BEST_DAMAGE_MOVE 1 // Move with the most amount of hits with the best accuracy/effect
#define POWERFUL_STATUS_MOVE 10 // Moves with this score will be chosen over a move that faints target
#define NO_DAMAGE_OR_FAILS -20 // Move fails or does no damage
// Scores given in AI_CalcMoveEffectScore
#define WEAK_EFFECT 1
@ -64,6 +65,14 @@
score += val; \
} while (0) \
#define ADJUST_AND_RETURN_SCORE(val) \
do \
{ \
TestRunner_Battle_AIAdjustScore(__FILE__, __LINE__, sBattler_AI, AI_THINKING_STRUCT->movesetIndex, val); \
score += val; \
return score; \
} while (0) \
#define ADJUST_SCORE_PTR(val) \
do \
{ \

View file

@ -4734,17 +4734,17 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score
if (gMovesInfo[move].power)
{
if (GetNoOfHitsToKOBattler(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex) == 0)
ADJUST_SCORE(-20);
ADJUST_AND_RETURN_SCORE(NO_DAMAGE_OR_FAILS); // No point in checking the move further so return early
else
{
if ((AI_THINKING_STRUCT->aiFlags[battlerAtk] & AI_FLAG_RISKY) && GetBestDmgMoveFromBattler(battlerAtk, battlerDef) == move)
ADJUST_SCORE(1);
ADJUST_SCORE(BEST_DAMAGE_MOVE);
else
score += AI_CompareDamagingMoves(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex);
ADJUST_SCORE(AI_CompareDamagingMoves(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex));
}
}
score += AI_CalcMoveEffectScore(battlerAtk, battlerDef, move);
ADJUST_SCORE(AI_CalcMoveEffectScore(battlerAtk, battlerDef, move));
return score;
}

View file

@ -170,7 +170,6 @@ AI_DOUBLE_BATTLE_TEST("Spicy Extract user will use it if partner holds Clear Amu
PARAMETRIZE { move = MOVE_TACKLE; }
PARAMETRIZE { move = MOVE_SWIFT;}
AI_LOG;
GIVEN {
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT);
PLAYER(SPECIES_WOBBUFFET) { Speed(10); }