To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > General Help > Games

Reply
 
Thread Tools Search this Thread Display Modes
Old 12-17-2006, 04:40 AM   #1
andreaskrenmair
Senior Member
 
Join Date: May 2003
Location: Austria
Posts: 146
[MX]Node based path finding

I wanted to know how fast this would be in Flash. So I coded this version of a node based path finder:

Just click on a node. The start node is in the upper left corner.

http://mitglied.lycos.de/andreaskrenmair/flash/bfs.html

I used the breadth-first search algorithm for the pathfinding. The graph was built with simple objects that are linked together.

I was quite surprised that it is that fast with Flash Player 9.
andreaskrenmair is offline   Reply With Quote
Old 12-17-2006, 07:42 AM   #2
SaphuA
SaphuA
 
SaphuA's Avatar
 
Join Date: Oct 2002
Location: The Netherlands
Posts: 2,182
What exactly is the point of this thread? Do you want feedback or.. ?

25ms for the farthest path isn't too bad of a result imo.

However, if it's not fast enough I think you might need to rethink your logic behind it. I've seen some ultra fast nodebased pathfinders around here which were still made in a version other then Flash 9.

PS. I don't think search that the search results are accurate. The path to the node above the one in the lower right corner, is not the shortest.
__________________
SaphuA is offline   Reply With Quote
Old 12-17-2006, 09:47 AM   #3
andreaskrenmair
Senior Member
 
Join Date: May 2003
Location: Austria
Posts: 146
Hi,

actually I had two reasons creating this thread: feedback an to show an alternative for pathfinding examples for tilebased games. Eventhough this example is in an tilebased environment you could adapt it to every sort of map. Sorry, I forgot to mention that.

Quote:
...were still made in a version other then Flash 9.
That´s the point. I made it with mx in AS1. With Flash Player I got 160 - 183 ms for the longest path. With Flash Player 9 I got 26 - 30 ms.

Quote:
PS. I don't think search that the search results are accurate. The path to the node above the one in the lower right corner, is not the shortest.
That´s because I did not distinguish the different edges (I was a bit lazy). So even an edge is longer as the shortest one for example they are treated as equal. If you count the nodes to the path the trace for the actual shortest path will have the same(or more) amount of nodes of the trace the pathfinder returns.

Last edited by andreaskrenmair; 12-17-2006 at 09:50 AM.
andreaskrenmair is offline   Reply With Quote
Old 12-17-2006, 11:31 AM   #4
renderhjs
Student
 
Join Date: Apr 2001
Location: -
Posts: 4,756
Quote:
Originally Posted by andreaskrenmair
...show an alternative for pathfinding examples for tilebased games. Eventhough this example is in an tilebased environment you could adapt it to every sort of map.
like you said not only tile- based, I made a node based pathfinding a while ago for my ortho engine wich has something like a polygonal map structure:
http://board.flashkit.com/board/show...4&postcount=13

mine is propapbly slower (esspecially with AS2) but back then I really gave it some thoughts so I added features within the editor such as zones or unique node directions that speed up searches (used for example as dead ends = level leaving).

(screenshot of a level in the editor as top view)

I wrote about this as well some time ago in a pacman thread and described excactly what you did (pacman with node- based pathfinding)

edit:
could it be that you dont compare the actual node distances all together but instead right now only the amount of nodes within the path to determine the shortest path (wich is very wrong if so).
Sometimes I had as well the feeling the the result was not the fastest path but always the path with the smalest amount of nodes

Last edited by renderhjs; 12-17-2006 at 11:39 AM.
renderhjs is offline   Reply With Quote
Old 12-17-2006, 05:32 PM   #5
andreaskrenmair
Senior Member
 
Join Date: May 2003
Location: Austria
Posts: 146
Quote:
could it be that you dont compare the actual node distances all together but instead right now only the amount of nodes within the path to determine the shortest path (wich is very wrong if so).
Yes, I did not add something that calculates the distance between two nodes. So this two nodes are treted as equal:

O--O == O-----O

but I could either add a simple cost function or create a workaround and split long paths up.
So actually it is not working correctly. I will try to fis that without loosing too much speed.

I am curious about the unique node directions. How did you achieve that?

The algorithm looks for every node he vistits if there are connctions to other nodes if so store them and treat them as visited.

I think I can make it a little bit faster if I use a heap to store the visited nodes, but that will only pay of if the list of visited nodes is very big.

EDIT: Updated the version and added two extra nodes in order to get better paths.

Last edited by andreaskrenmair; 12-17-2006 at 05:55 PM.
andreaskrenmair is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > General Help > Games

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:20 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.