Hi Everyone. I'm designing and programming a top down shooter in Python. I'm quite new to pathfinding and complicated AI in general and I'm having problems with pathfinding affecting my game's performance. I have written what I believe to be a relatively efficient A* derived pathfinding algorithm. It can find the shortest path on an 100*100 grid with random weights in less than 0.12 seconds reliably. The way I have my world implemented is that the world has a list of game objects, and each game object has an x and y coordinate which are doubles. Right now, I've also created a pathfinding grid to "layer" on top of the world. The grid is separated into squares that are each the size of my smallest character sprite. My pathfinding algorithm checks if there is an obstruction in a square to determine the weight of the square (This is done while loading the level and not in real time). The current grid size I am using for my world is 48*56. I run the pathfinding algorithm for each enemy every half second if and only if their destination has changed. However, I am still noticing a relatively big drop in performance. Every two enemies added drops my fps in game by about 1. This is certainly caused by my pathfinding as rendering them and making them move without pathfinding does not drop my performance. Considering that I'd like to be able to have a peak of around 30 different pathfinding entities in the game at a time, this will really hurt my game's performance. So I was wondering, what should I be doing to pathfind more efficiently? Is my algorithm too slow, is Python too slow, or is there some game design tricks I can use to speed things up?
Thanks for your time,
Jason Wolter