-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 delay timer #3302
Add ai delay timer #3302
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as ideas for making AI faster - replacing the table of AI flag functions with a table of score changes per move effect speeds things up considerably (we did this in voyager and I got 19 frames for a double battle with partner)
@@ -1889,6 +1889,19 @@ static void HandleChooseActionAfterDma3(u32 battler) | |||
{ | |||
gBattle_BG0_X = 0; | |||
gBattle_BG0_Y = DISPLAY_HEIGHT; | |||
if (gBattleStruct->aiDelayTimer != 0) | |||
{ | |||
gBattleStruct->aiDelayFrames = gMain.vblankCounter1 - gBattleStruct->aiDelayTimer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on adding the frames counter to the battle debug menu?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AI one or in more general sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was thinking just adding the value to the AI Info page but that can just be a separate PR if desired. Otherwise I think this looks good now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do it in a separate PR then
Wow, this is a huge change! Could you share with us how it looks like? |
On mobile and can share more later, but basically it combines all AI calcs into a single function call like so:
And our table is just a table of function pointers:
And each function looks like this, having individual calcs for each ai Flag
So it's a bit cumbersome but having all the AI calcs in a single function and the jump tables speeds things along nicely. Theoretically we don't need a table of functions and could keep the switch statement to just combine CheckBadMove and CheckViability though |
Adds a timer which counts how long it takes for the AI to decide which action and move to choose.
The number of frames will be displayed in the battle box replacing the "What will PKMN do" text.
Uses new config define DEBUG_AI_DELAY_TIMER
I also changed GetAiLogicData function's name to SetAiLogicDataForTurn, because it made more sense to me, but I can revert it or change to something else if needed.
Current benchmarks on upcoming are:
When building with modern these all take less frames(which is all the more reason to ditch agbcc)