TIGSource Forums

Developer => Technical => Topic started by: fyamnky on June 06, 2009, 12:14:34 PM



Title: Pathfinding troubles (python)
Post by: fyamnky on June 06, 2009, 12:14:34 PM
I am trying to write a graph search program using python that implements breadth-first, best-first, Dijkstra and A* searches. I've run into a wall with the best-first algorithm. It's taking much too long, and I've been racking my brains out trying to figure out a solution. Ive attached the source code in a zip file but I warn you I am quite an incompetent programmer(this is my first real project). All help is appreciated. :beg:


The link is: http://www.mediafire.com/download.php?tiqxgm2zmje


Title: Re: Pathfinding troubles (python)
Post by: EchoP on June 06, 2009, 05:10:49 PM
I don't know if you think the path finding method itself is too slow, or the whole program, but if you are talking about the program..

You are waiting 50 milliseconds after each tile is checked, which is longer than the whole path finding method takes to run if you cut it out. The drawing code is also refreshing the whole screen after each tile is drawn, it is easier just to refresh the parts of the screen that are needed.

Code:
def tilecreate(locationx,locationy,image):                 
  rec=screen.blit(image, ((locationx*tilew),(locationy*tileh)))
  pygame.display.update(rec)

I hope that helps.


Title: Re: Pathfinding troubles (python)
Post by: fyamnky on June 06, 2009, 05:17:56 PM
Thanks for the help Echo. I'm purposefully waiting 50 milliseconds, but thanks a lot for you updated tilecreate function.