Posts Tagged ‘A*’

AS3 A* Pathfinding Engine (v1.0)

Friday, March 21st, 2008

She ain’t much to look at, but she sure do work. Honestly, I’m not exactly sure how it works. A recursive function is a fierce and fickle mistress.

Pathfinding engine v1.0

Actually, I do know how it works; I was just startled at how fast it came together. There are a lot of great resources on the subject, as well. Here’s the one I used:

A* Tutorial for Beginners

And if you’d like to play around with it, just click the image.

The real problem I have with it is that it’s pretty short-sighted. Units don’t see a wall until they’re right on top of it. Obviously this makes sense for a lot of units- sometimes you don’t know where you’re going until you get there. But I think I’m going to try some smoothing algorithms to remove some waypoints and get those paths a little more natural-looking.