From ab6a97d20da6078dad73efa4f69daf0194b6021d Mon Sep 17 00:00:00 2001 From: Pawkkie Date: Mon, 28 Apr 2025 21:47:17 -0400 Subject: [PATCH] remove predictedScore --- include/battle.h | 1 - include/battle_ai_main.h | 6 ------ src/battle_ai_main.c | 26 +++++++++++++------------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/include/battle.h b/include/battle.h index 384b44c672..588247ad00 100644 --- a/include/battle.h +++ b/include/battle.h @@ -360,7 +360,6 @@ struct AI_ThinkingStruct u8 movesetIndex; u16 moveConsidered; s32 score[MAX_MON_MOVES]; - s32 predictedScore[MAX_MON_MOVES][MAX_BATTLERS_COUNT]; u32 funcResult; u32 aiFlags[MAX_BATTLERS_COUNT]; u8 aiAction; diff --git a/include/battle_ai_main.h b/include/battle_ai_main.h index a8a2071a2b..771d2b7643 100644 --- a/include/battle_ai_main.h +++ b/include/battle_ai_main.h @@ -68,12 +68,6 @@ enum AIScore AI_THINKING_STRUCT->score[movesetIndex] = val; \ } while (0) \ -#define SET_PREDICTED_SCORE(battler, movesetIndex, val) \ - do \ - { \ - AI_THINKING_STRUCT->predictedScore[movesetIndex][battler] = val; \ - } while (0) \ - #define ADJUST_SCORE(val) \ do \ { \ diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index a539b72d0d..8713cf69a0 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -276,11 +276,11 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves, u32 battler) for (moveIndex = 0; moveIndex < MAX_MON_MOVES; moveIndex++) { if (moveLimitationsTarget & (1u << moveIndex)) - SET_PREDICTED_SCORE(opposingBattler, moveIndex, 0); + SET_SCORE(opposingBattler, moveIndex, 0); if (defaultScoreMovesTarget & 1) - SET_PREDICTED_SCORE(opposingBattler, moveIndex, AI_SCORE_DEFAULT); + SET_SCORE(opposingBattler, moveIndex, AI_SCORE_DEFAULT); else - SET_PREDICTED_SCORE(opposingBattler, moveIndex, 0); + SET_SCORE(opposingBattler, moveIndex, 0); defaultScoreMovesTarget >>= 1; } @@ -532,12 +532,12 @@ u32 BattleAI_PredictMove(u32 battler, u32 opposingBattler) for (i = 0; i < MAX_MON_MOVES; i++) { - gAiBattleData->finalScore[opposingBattler][battler][i] = AI_THINKING_STRUCT->predictedScore[i][opposingBattler]; + gAiBattleData->finalScore[opposingBattler][battler][i] = AI_THINKING_STRUCT->score[i]; DebugPrintf("Final score: %d", gAiBattleData->finalScore[opposingBattler][battler][i]); } numOfBestMoves = 1; - currentMoveArray[0] = AI_THINKING_STRUCT->predictedScore[0][opposingBattler]; + currentMoveArray[0] = AI_THINKING_STRUCT->score[0]; consideredMoveArray[0] = 0; for (i = 1; i < MAX_MON_MOVES; i++) @@ -545,15 +545,15 @@ u32 BattleAI_PredictMove(u32 battler, u32 opposingBattler) if (gBattleMons[opposingBattler].moves[i] != MOVE_NONE) { // In ruby, the order of these if statements is reversed. - if (currentMoveArray[0] == AI_THINKING_STRUCT->predictedScore[i][opposingBattler]) + if (currentMoveArray[0] == AI_THINKING_STRUCT->score[i]) { - currentMoveArray[numOfBestMoves] = AI_THINKING_STRUCT->predictedScore[i][opposingBattler]; + currentMoveArray[numOfBestMoves] = AI_THINKING_STRUCT->score[i]; consideredMoveArray[numOfBestMoves++] = i; } - if (currentMoveArray[0] < AI_THINKING_STRUCT->predictedScore[i][opposingBattler]) + if (currentMoveArray[0] < AI_THINKING_STRUCT->score[i]) { numOfBestMoves = 1; - currentMoveArray[0] = AI_THINKING_STRUCT->predictedScore[i][opposingBattler]; + currentMoveArray[0] = AI_THINKING_STRUCT->score[i]; consideredMoveArray[0] = i; } } @@ -776,17 +776,17 @@ static inline void BattleAI_DoAIProcessing_PredictMove(struct AI_ThinkingStruct && sBattleAiFuncTable[aiThink->aiLogicId] != NULL) { // Call AI function - aiThink->predictedScore[aiThink->movesetIndex][opposingBattler] = + aiThink->score[aiThink->movesetIndex] = sBattleAiFuncTable[aiThink->aiLogicId](opposingBattler, battler, aiThink->moveConsidered, - aiThink->predictedScore[aiThink->movesetIndex][opposingBattler]); - DebugPrintf("Current score: %d", aiThink->predictedScore[aiThink->movesetIndex][opposingBattler]); + aiThink->score[aiThink->movesetIndex]); + DebugPrintf("Current score: %d", aiThink->score[aiThink->movesetIndex]); } } else { - aiThink->predictedScore[aiThink->movesetIndex][opposingBattler] = 0; + aiThink->score[aiThink->movesetIndex] = 0; } aiThink->movesetIndex++; } while (aiThink->movesetIndex < MAX_MON_MOVES);