Menu:

Sponsor

Discover Master of Alchemy, our first iPad/iPhone and iPod touch game!

Follow Me

 

Forum's topics

Latest Files

Archives

Top Rated

Categories

Photo Gallery


Alessandro Crugnola on September 30, 2003 in actionscript , flash

A* PathFinder for Flash

Use the A* algorithm to create a path finder for your flash games.
The A* can be summarized as:

setup the openlist
setup the closedlist
push the starting node to the open list
while the openlist is not empty
Look for the lowest 'f' cost node on the open list and
pop from the openlist and name it 'current'
if the current node is the goal then exit loop
for each of the node adjacent to the current node
set the parent of this adjacent to 'current'
if a node with the same position as the adjacent /
node is in the open list and its 'f' is lower than /
the node adjacent
then skip current adjacent node
if a node with the same position is in closedlist /
and its 'f' is lower
then skip current adjacent node
otherwise push the current node to the open list
remove occurences of adjacent node from /
OPEN and CLOSED list
Add adjacent node to the OPEN list
end for
add the current node to the closed list
end while
 
Read the article on my wiki 

View the working example

 

Bookmark and Share

 

Tags: a star , path finder 

 

1 comments
This one is great. :) It seems that the grid is 10 x 10. But i got a problem when I tried it with a grid of 17 x 17. What shall I do?? Can anyone help me? Thank you in advance and GOD bless! :)


Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Type the characters you see in the picture above.





 

TrackBacks

TrackBack URL for this entry: http://www.sephiroth.it/cgi-bin/mt/mt-tb.cgi/180