A* in ActionScript 3.0

Started by
4 comments, last by Extrarius 16 years, 8 months ago
Hello, does anyone have any examples of path finding in actionscript 3.0? All of the tutorials I can find are all AS1 or 2, and when I try to convert them i'm not very successful. I keep getting errors like im trying to access something that isnt there, i've gone over my code for 2 days now and I'm not seeing any problems, and i've tried 3 different tutorials and sample code. Any help would be greatly appreciated. ps - it's for a tower defense game, so i've been using a 2D array for my map.
Advertisement
Would anyone be interested making me a flash class for A* that is easy to use :) I can compensate you with some cash. This has been driving me insane for a couple of days now and It's taking away the little time I have to work on other features of the game. I'm building a tower defense game, and I would like the enemies to be able to be free form, no paths, able to build towers on a grid anywhere and update the enemies path finding on the spot. Let me know how much you would want and we can work out a deal. Thanks.
try writing it yourself, A* is a pretty simple algorithm and shouldn't take too long to write and it'll be good practise, I'll even provide steps I used to do A*:
1. Create an array of ints the size of the tiles and set the walkable tiles to one negative value(like -1) and unwalkable ones to another negative value(like -2)
2. set the destination tile to 0 and add it to a to update list
3. set the current number to 1
4. start loop
5. set changes made to false
6. for each tile in the update list check all the tiles around it to see if they're walkable, if so set the value of the tile to the current number, add it to the to update next turn list and then set changes made to true.
7. clear the update list and put all the tiles in the to update next turn into the update list, then clear the to update next turn list
8. increase current number by 1
9. check if changes were made and if the starting tile has a value of walkable, if so go back to 4, otherwise exit the loop
10. if changes made was false and the starting tile has a value of walkable instead of a number it means you cannot get to your destination from the starting tile so you exit
11. you should now have an array that'll count down to the target.

I can't explain as well as it's explained in Programming Isometric Games with DirectX 7, which if you need more information you should pick that book up.
I think I may have one working, still testing =X
Yup its working great :)
Quote:Original post by eedok
[...]
That isn't A*, that is a breadth-first search. It still works and will find the shortest path, but it's worth using the proper names for algorithms =-)

[Edited by - Extrarius on August 7, 2007 3:05:05 PM]
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk

This topic is closed to new replies.

Advertisement