Tuesday, March 18, 2008

Pathfinding 1.0

So the A* pathfinding is finally up and running. Not perfect tho'

Some cases still mess the algorithm up. Specificly, when no path can be found, the algorith takesthe unit around the playfield is search for the path. And sometimes when the algorithm tries tomake a smoother path, it can drive over a corner of a structure..

Still, it feels great to finally get at least something done and for now I might focus my energy on other issues, insted of polishing the pathfinding.


4 comments:

Zygote said...

Awesome! Any chance of a source code release?

Thanks,
Ziggy
Ziggyware XNA News and Tutorials

Duxx said...

I've struggled with the algorithm for days and done it again and again from scratch so this is the code for the first version that almost worked. There's a lot of errors and it looks like a mess, but if someone thinks they can learn something from it, then here goes...

First read this article to know what's the idea behind A* A* Pathfinding for Beginners

My source code can be found here Pathfinding source

I've used ArrayLists as open and closed list, but the correct way to do it is to have a heap as the openlist.

You can comment about the many mistakes there are on my code, I'll work on them later.

Duxx said...

Hmmm... Just notices that this version doesn't check if a node is accessible or not - the very idea of pathfinding. Change the lines if (!AStarOnClosedList(piste)) into if (!AStarOnClosedList(piste) && AStarIsAccessible(piste)) and in the new function check if the Point piste is walkable or not.

Terrh said...

Any new news?