Original Post
i'm thinking about making a tile game similar to packman where you get chased by enemies. i read an article here pointing out that the ghosts in pacman had specific jobs, like one follows shortest path to chase you, one tries to hang out in the middle of the map to cut off your escape, one randomly moves around one part of the map to make life difficult when you gotta go to that area, stuff like that i was wondering about what would be the best way to go about making the one that actively follows shortest path to catch you. i'm thinking the level will be made up of an array of tiles, you can move from tile to tile unless a barrier is between the two tiles. this array of tiles could be reppresented as a graph with each vertex having a path to all adjacent vertices unless theres a wall between the vertices (the wall would only exist on the bitmap, the only thing the graph knows is that there is no path to the blocked tile). its been a while since i last did anything with algorithms, the only thing i remember is dijkstra's algorithm is used to find a minimum spanning tree which can be looked at to find a shortest path. is the best solution to run dijkstra's algorithm once for each square on the map before the game starts and each time the ghost wants to move, he looks at his position and pac man's position and looks up what would be the shortest path and makes his move accordingly? or is that overkill? should the ghost just know his coordinates and pac man's coordinates and try to move in a direction that reduces the distance? or is there another really cool shortest path algorithm that i'm forgetting?