[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Pathfinding



Here's a tutorial of pathfinding with A*, specifically for PyGame:

http://eli.thegreenplace.net/2009/01/09/writing-a-game-in-python-with-pygame-part-iii/

On Mon, Jan 26, 2009 at 19:01, Michael George <mdgeorge@xxxxxxxxxxxxxx> wrote:
Marius Gedminas wrote:
My personal snag with A* is that the NPCs seem to know too much about
the map and directly walk the most optimal path without exploration.

 
One possibility to solving this is to have the npc move as it's performing the algorithm.  i.e. as your search explores a path, the character walks along that path.  This could probably be implemented fairly cleverly by using generators.  You'd probably have to experiment with different algorithms to find a more "realistic" approach - I suspect that A* would involve lots of wandering since it assumes constant access time for all known branches (whereas the character has to walk up and down the tree).  DFS would probably be more realistic.

--Mike