// originally written by William Cairns - http://www.cairnsgames.co.za// http://www.pascalgamedevelopment.com/forums/profile.php?mode=viewprofile&u=65// Enchanchements, additional code by Jernej L.// http://www.gtatools.com// please note that the path returned is REVERSED.// Modified by Jordi Coll

I am a full stack Software Architect and I consider myself a problem solver with the ability of getting things to work. Having a keen eye on quality, architecture and risks this lets me build good software. I am mainly interested in Delphi, .NET, Databases, AI, compilers, grammars, graphics and more mathematical stuff. If you like this page you could also visit me on twitter @thunderjordi and on Facebook.

There is a big problem with this code. It is your stack (or lack of stack because you use a linear array). If you check the the biggest performance gain in A*, you will find that it is to use a Priority Queue.Also, why don't you follow the traditional algorithm of the OPEN (priority queue) and CLOSED list?

It certainly is indeed. One of the setbacks of this code is the list which could be heavily improved by using other kind of lists like the one you suggested (priority queue). The main reason here is that in Delphi there is no official version of "Priority Queue List" and it should be implemented. I've got the same code in Java and I've got everything correctly implemented because I already got all my basic structures (hash lists, priority queue list, balanced trees, etc).

Thanks, When I saw some of the online Jump Point Search demos, I thought this must be a clear winner. I did a comparison and found something really interesting. In your code, you use all 8 neighbors. This is a mistake! In some cases, there is only 1 neighbor (and usually less than 4)! By making a smarter neighbor method, my A* algorithm is just as fast as Jump Point Search. So, there are two critical things:1. Priority heap for the OPEN list2. Neighbor routing that only returns realistic cells.

Thanks. I might take another approach if I had to re-do it again. This simple algorithm proves the thing and I´m thinking of adding to my repository in google code as something to work on and make some improvements.Jordi

About the Author

I am a full stack Software Architect and I consider myself a problem solver with the ability of getting things to work. Having a keen eye on quality, architecture and risks this lets me build good software. I am mainly interested in Delphi, .NET, Databases, AI, compilers, grammars, graphics and more mathematical stuff. If you like this page you could also visit me on twitter @thunderjordi and on Facebook.