Closed CameronJung closed 1 month ago
Right now I believe the main culprit for this issue is the A* search algorithm. It might be better just to have a global look up table for navigation and initializing it during a loading screen than conducting these searches at runtime.
Another approach could be to use such a table but to instead store the data obtained during the A* search so that the calculations aren't repeated and the load is distributed over time. This also has the advantage that unnecessary calculations aren't performed. However, the disadvantage is that this also adds to the work done during the search, so benefits could bi minimal and situational.
I decided this warrants a patch, as opposed to lumping it in with a major update
Improvements have been made. However, on android the time the AI takes to make a turn is still too long. I'm not sure why though considering that my phone apparently has a similar processor to my laptop; maybe the graphics is the issue. Further research is warranted.
With the current improvements in the branch the AI makes its turn twice as fast. The biggest improvement came from giving the measurement a time budget instead of a set number of iterations per frame. Additionally, distances measured are now stored in a global look up table so they aren't repeated.
I might have made a breakthrough, it seems that a lot of the yields in the AI commander are holding back the program by not using frames to their fullest potential. With some of these lines commented out Pangea completes its first turn in ~22 seconds, compared to the ~100 seconds it took before. I will need to do some testing on Android but this might be huge.
Larger Maps and larger numbers of units cause the AI's turn to take too long. This is particularly bad on Operation Pangea.