primem0ver
Emperor
I have discovered a major bottleneck in turn times while working on the event engine. I did some painstaking turn time analysis because I thought my new events engine was causing some problems but I realized it was not the main source of the bottleneck.
So what was it? It was three triremes stuck behind my lines that could not move anywhere... so they always triggered the AI_explore() routine. By "moving" these ships back into their own territory I cut down turn times from almost 30 seconds to 10 seconds! This is a MAJOR PROBLEM! Later in the game another 20 seconds were being added to 20 second turn times causing me to wait almost a minute between turns!
The AI_explore() routine takes a minimum of 5 seconds every time it is called by a single unit (on a huge map)! Why? Because it tries every square on the board for a "best plot" and when it does this, it tries generating a path to each plot. THAT IS A LOT OF TIME.... path generation is very time consuming (relatively speaking).
So I want to come up with a way to fix this problem and it won't be easy. I have already come up with a partial solution that divides the board into exploration "areas" in a grid system that keeps track of how much of the area is explored. I have some good ideas on where to go as I have spent some time coming up with them.
My basic algorithm is headed towards direction finding rather than plot finding. Something like this:
Instead of scanning the board for individual plots, it will evaluate each plot it can move to in a single turn and use my "exploration grid" as a means to evaluate how much unexplored territory lies in the general direction of each of those possible moves.
By doing this, we may be able to redo the whole "exploration" algorithm. Currently exploration is done using two seperate algorithms. We may be able to combine them into one that takes quite possibly 1/200th or less of the time!
So what was it? It was three triremes stuck behind my lines that could not move anywhere... so they always triggered the AI_explore() routine. By "moving" these ships back into their own territory I cut down turn times from almost 30 seconds to 10 seconds! This is a MAJOR PROBLEM! Later in the game another 20 seconds were being added to 20 second turn times causing me to wait almost a minute between turns!
The AI_explore() routine takes a minimum of 5 seconds every time it is called by a single unit (on a huge map)! Why? Because it tries every square on the board for a "best plot" and when it does this, it tries generating a path to each plot. THAT IS A LOT OF TIME.... path generation is very time consuming (relatively speaking).
So I want to come up with a way to fix this problem and it won't be easy. I have already come up with a partial solution that divides the board into exploration "areas" in a grid system that keeps track of how much of the area is explored. I have some good ideas on where to go as I have spent some time coming up with them.
My basic algorithm is headed towards direction finding rather than plot finding. Something like this:
Instead of scanning the board for individual plots, it will evaluate each plot it can move to in a single turn and use my "exploration grid" as a means to evaluate how much unexplored territory lies in the general direction of each of those possible moves.
By doing this, we may be able to redo the whole "exploration" algorithm. Currently exploration is done using two seperate algorithms. We may be able to combine them into one that takes quite possibly 1/200th or less of the time!