PathFinder enhanced.

I recently updated the PathFinder algorithm with the ability to attempt diagonal paths, and ability to make diagonal movements. Diagonal movements approximately doubles the time required to find paths, but that is easily overcome by publishing for Flash Player 7.

As with the original PathFinder (original code can be downloaded by clicking here), this PathFinder is aimed at being a fast and reasonably accurate solution. It runs exponentially faster than an A* solution (the larger the map, the larger the speed gap), but will not always find the best path (sometimes it won’t even find a path). It was also developed to be scaleable, so you can adjust the processor usage for different scenarios. To this end, you can adjust the maximum depth of the path (max length), and the “level” of the search. The level is a value between 0 and 7 that indicates how many different paths the PathFinder will attempt and compare (a level of 7 will check 8 different paths and choose the best). PathFinder will also return a best fail path if it is unable to find a solution, so that you can have agents move towards a goal even if a full path can’t be found.

Once I have a chance to finish the updates to PathFinder, and test it fully, I will release the source code for non-commercial uses. If you’re interested in licensing the code for a commercial project, you can contact me using the contact button at the top of the page.

Read on for demos…


Demo, with diagonal movements (FP7 required):

Demo, no diagonal movements (FP7 required):

Grant Skinner

The "g" in gskinner. Also the "skinner".

@gskinner

6 Comments

  1. Great work Grant, just noticed some strange behaviour in the diagonal version path … I’ve taken a screenshot – let me know if you’d like me to send that over :p

  2. Wow, this seems very fast !!!

    But do you plan to implement a “cornering” option, for the diagonals not to cross a corner ?

    Great work !

  3. Harold López September 9, 2005 at 1:27pm

    Cool work!

    Congratulations, I needed it!

    Greetings!

  4. Hello, I’ve done another version for JavaScript and ActionScript 1.0 or 2.0.

    Here there’s a javascript example:

    http://www.devpro.it/examples/astar/index2.html

    http://www.devpro.it/examples/astar/index.html

    and here the AS 2.0 example, inspired to this page 🙂

    http://www.devpro.it/examples/astar/flash.html

    … finally my post about my implementation:

    http://webreflection.blogspot.com/2006/10/javascript-path-finder-with-star.html

    See you

  5. I thought you should build a more flexible version with different type of tiled but you’re wright to just to show the way 😉

    Good work, i will try to translate A* in PHP

  6. Hi,

    Good job !

    Andrea, could you give us how to implement your example for AS2 ?

    Thank you !

Comments are closed.