October 7, 2015

Increasing Performance in Path Finding AI

As I stated in my previous post, performance is a huge issue when it comes to simulating AI. Well, here's a swing at a way to attempt to reduce the amount of time it takes to come up with a solution. Instead of releasing all of the actions at once, release in chunks, with similar actions combined. Then, after coming up with a possible path, test each chunk to see if it can be preformed. If it can't, disable that node chunk, and check again.

For example: Imagine that you had a group of actions:

  • Move Forward
  • Turn Left
  • Turn Right
  • Sprint Forward
  • Heal
  • Fire Arrow
  • Swing Sword
Now, all of the move commands are basically under the same category. So you can simplify the whole process by changing the nodes to:
  • Move to Player
  • Move to Nearest Hiding Location
  • Run away
  • Heal
  • Fire Arrow
  • Swing Sword
Doing it this way significantly lowers the number of nodes that must be traveled in the first attempt. Though the overall amount of possible nodes is increased, the depth is much, much lower by comparison. As always, there are pros and cons to this.

Pros being obviously much higher performance, and faster calculations. Cons: Well, there is not as much flexibility as there would be without. As the AI might have found a potentially better solution to the problem that was not listed as one of your pre-made nodes. In the example above, the pathfinding may have found a spot on the bridge where it can shoot the player, dodge behind a pillar, and heal in less then a second. This solution would not have been available in the chunk based system.

Al-in-all, this solution is only reasonable if you are willing to give up some accuracy in exchange for performance. It may or may not be useful in some situations. Either way, hope this helps. xD (Sorry for the short, quick post. Just a simple idea I thought up earlier today.)

No comments:

Post a Comment