Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm looking for pseudo-code examples of the A* pathfinding algorithm that actually works. I tried plenty of different ones where it's not really clear how to implement them at all times. Keep in mind that I'm a newbie, so if everything could be detailed, that'd be great.

share|improve this question

3 Answers 3

up vote 6 down vote accepted

I think the pseudocode in the Wikipedia article is sufficiently detailed. If you need more details and a working implementation then A* Pathfinding for Beginners is a good article. It has C++ sample code with comments.

share|improve this answer

On my site I have an A* implementation I did in Actionscript based on this tutorial.

share|improve this answer
    
It is really good! Although, I didn't know people still use ActionScript... –  jco Nov 8 '11 at 23:07
    
ActionScript is the most common language for Flash development by far. –  Gregory Avery-Weir Nov 9 '11 at 3:30

I implemented this one not too long ago and worked for me.

share|improve this answer
    
That's exactly the one I looked into, but it doesn't work for me. Because when do I set a tile's "Next" step, and where it says "update the neighbor with the new, lower, g value" - what G value is it? I need something simpler. –  Mathias Lykkegaard Lorenzen Nov 6 '11 at 13:52
1  
You calculate the G values as you generate each node, based on the cost to reach that node, and to travel between nodes. You already have that node's old G value from the first time you examined it. Now you have a new G value for the new route to that node. If the new route is quicker, you get to re-open the old node with the new and lower value of G. –  Kylotan Nov 6 '11 at 14:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.