home subscribe to email updates subscribe to RSS updates

My A* Pathfinding in Flash

I’ve been wanting to do this for ages!!!

Path Finding

I’ve put together a little Flash program ( Flash 8 ) to demonstrate the A* pathfinding algorithm. Took me a little while to figure it out - Flash is clearly not the best environment for recursive algorithms!

Instructions:

  1. Click on the Baddie or the Flag to select them, then click again to place them. They can’t be placed on top of each other.
  2. Make walls by pressing the LEFT MOUSE BUTTON or obstaces by using the MOUSE WHEEL. The whiter the square, the greater the movement penalty. The most white setting is a wall and cannot be passed through.
  3. Once you’ve got the grid setup, you are ready to go! Press SPACE to find the path to the Flag.
  4. Selecting the Baddie or the Flag again will reset the grid.

Also:

  1. The grid can be resized by using the ARROW KEYS. Warning - this is quite slow.
  2. Keys 1-9 randomise the heights of the cells (0 = flat, 9 = very bumpy).

If you’d like some more information on A* - the site I used to get this up and running is : here.

Enjoy. Maybe the next game I make will have some AI in it?

Link: pathfinding test


« Superman Returns
AddThis Social Bookmark Button

Related Posts:

Comments:

Dauntless said,

April 12, 2006 @ 11:19 pm

Hi,

You told me on my blog that it hugs the wall… I can’t really say that I noticed it… Do you have an example map?

Greets,
Dauntless

MB said,

April 14, 2006 @ 11:20 am

Thanks for your comment, Dauntless.

It’s just clear that sometimes my solution doesn’t find the quickest path. And most times the path that it does choose isn’t the most aesthetically appropriate (try finding the path on an empty map - it just follows the wall).

However, in saying that… I’m still very happy with the results… and hope that next time I’ll make something a little better.

For those that visit this post, make sure you check out Dauntless’ A* info . He’s even released a number of Actionscript classes for use in your own projects.

Thudfactor » A* Demo said,

November 4, 2006 @ 5:04 am

[…] Michael Battle has done this as well; his is more interactive. […]

RSS feed for comments on this post · TrackBack URI

Leave a Comment



« Superman Returns