Coding an A* Pathfinding Visualization

Java

Video is ready, Click Here to View ×


An overview of the popular A* pathfinding algorithm and my experiences coding a visualization in Java swing. This was one of those projects I made a few years back when learning Java, so I pretty much just googled “A* pathfinding for beginners” and ran with that haha. I tried to explain my understanding in the most simple way possible. Bigger projects coming soon.

Download the jar (project page): http://devoncrawford.io/software/pathfinding/

Next Video:
Previous Video:…

48 thoughts on “Coding an A* Pathfinding Visualization

  1. BTW, thanks for making these videos. They’ve shown me how taking time to get immersed into coding can become very rewarding
    After you described how you learned to code, I decided to just jump in, learning in-depth java algorithms, and supporting my hs’s robotics team. Now, I’m going into Comp Sci for college.
    Thank you for being a part of that

  2. Sorry, but that was a bad explanation of the algorithm. You didn't really elaborate on what "G_cost" and "H_cost" were.

    G is the actual cost of getting from the start to this node. H is a heuristic cost; you expect to spend at least this much from this node to the end. (H should be as high as possible, without exceeding the actual cost, which you don't actually know, hence it's a heuristic)

    F is just G+H, meaning that F is how much you expect the path from the start to end through this node to cost.

    You put the partial paths in a priority queue, taking the partial path with the least F (expected total cost) at each iteration, seeing if it reached. If it did, you're done, if not, add its successors (same as this partial path, but with one extra node each) to the priority queue, and repeat.

    Partial paths you already tried get put into a "closed set"/"fringe" so you don't accidentally visit them again later on.

Leave a Reply

Your email address will not be published. Required fields are marked *