ssjskipp on DeviantArthttp://creativecommons.org/licenses/by/3.0/https://www.deviantart.com/ssjskipp/art/Pathfinding-AS3-94121757ssjskipp

Deviation Actions

ssjskipp's avatar

Pathfinding AS3

By
Published:
1.6K Views

Description

SOURCE:
[link]

How To:
1. Click any node. The selected node will highlight red.
2. Select any other node to create a link between them (sorry if it looks like the line passes through other nodes, I was going to add arrows, but whatever). Please note this creates a bi-direction connection, although I could make it go one-way (for like, a one-way portal in a game or something), but for path finding it was easier to link nodes bi-directional from the start.
When adding connections, think of them as "If I'm here, I can walk to there.", so it's like a hallway. Nodes can connect to any other node, as well as any number of other nodes.
3. Once you've set up a nice connected grid (you can leave nodes disconnected, it doens't matter), click the "Finished Linking" button. Now for pathfinding.
4. Click any node to select it as the "start" node.
5. Move the mouse around. Destinations are the closest node to the mouse, and are highlighted blue. The blue line marks the path taken from node A to node B.
6. You can press 'Clear Nodes' at the end if you wana try another graph without refreshing.

-----------------------------------------------------------------------
Okay, so, I FINALLY decided to try out these data types: [link]
For this, I was testing the Graph data type, which seemed REALLY nifty for doing node path finding, AI, etc (as he says). I also used the Heap data type to store the open nodes, as I can pull the heuristically best node using a compare function.

I implemented an A* style path finding algorithm, this is the result. It's not PERFECT, but god damn it, it's good, and fairly quick.

Entire thing, including creating graph and AS for buttons, as well as API AS is 225 lines. The path finding itself is only 63 lines....programmed in AS3.
Image size
400x400px 27.53 KB
Comments10
Join the community to add your comment. Already a deviant? Log In
bertoloco's avatar
ohh noooo! the source link dosnt work!! I guess I was a few years too late :(