Pathfinder algorithm

Blitz3D Forums/Blitz3D Programming/Pathfinder algorithm

ThePict(Posted 2012) [#1]
I'm trying to write a function that finds a path within a 2D grid, so that every square is visited but only once. Just four directions of travel (n,s,e,w or u,d,l,r if you like) no diagonals.
So far I got it to work on a small grid 5 by 5, but as the grid size increases so the random trial and error method begins to fail.
I used a method that looks beyond the current available move, to look ahead at best next move before choosing a direction to go, this helped a little but still no result.

Has anyone seen anything relating to this, I've searched a bit, but don't know if there is a name for this kind of pathfinder.


Charrua(Posted 2012) [#2]
probably you have to look for A* (A star)

http://www.policyalmanac.org/games/aStarTutorial.htm


RemiD(Posted 2012) [#3]
Good link Charrua.

Also i like these explanations :
http://youtube.com/watch?v=Kw8AMmyc6vg


psychicbottle(Posted 2012) [#4]
Yeah, im actually working on pathfinding myself (failing miserably), but from what ive studied your going to want to look into A*


Matty(Posted 2012) [#5]
djikstra's algorithm works well...


stanrol(Posted 2012) [#6]
djiksta yeah yeah