HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

[system] Pathing Algorithm System

02-16-2010, 04:36 PM#1
Ammorth
PAS v3.1 - by Ammorth

Zoom (requires log in)

Background:
Over a year ago, I wrote PAS 1.0 and updated it through to PAS 2.40 (2.40 was never released). I then took a break from modding wc3 and PAS has since become obsolete. With better syntax and modding experience, I have since re-wrote PAS from the ground up. PAS 3.0 is now born. The older version of PAS can be found here.
About PAS:
PAS is a framework for plugins that use the PAS system. It is a combination of nodes and edges, mixed in with an Astar algorithm that traverses the node. It can generate paths along the nodes which plugins can use.

PAS v3.1 includes 3 plugins:
  • PASMove
  • PASMoveSafety
  • PASGPS
There are many more possible plugins one could write to utilize PAS, these are only the beginning.
Requires:
Features:
  • PASMove will move units through the paths created by PAS
  • PASGPS creates a GPS-like Arrow which can guide players to locations within the PAS paths
  • PASMoveSafety is an added safety net for PASMove. It will check for stuck units as well as dead/removed units.

PAS Code:

Expand PAS:

Expand PASMove:

Expand PASMoveSafety:

Expand PASGPS:

If you notice any issues or have any improvements/suggestions, please speak up.
Attached Images
File type: jpgPAS3.0.jpg (62.1 KB)
Attached Files
File type: w3xPAS3.1.w3x (117.9 KB)
File type: mdxPAS_GPS_Arrow.mdx (3.2 KB)
File type: blpPAS_GPS_Arrow.blp (4.2 KB)
02-16-2010, 09:00 PM#2
Rising_Dusk
I wish you could optionally require either LinkedList or Stack. That'd be great, but I don't think Vex ever added it to JassHelper.
02-17-2010, 01:01 AM#3
Ammorth
Quote:
Originally Posted by Rising_Dusk
I wish you could optionally require either LinkedList or Stack. That'd be great, but I don't think Vex ever added it to JassHelper.

My only thing is I need Linked Lists for PASMovementSafety (need to loop without disrupting). Stack can't do that. Aswell, providing a list of nodes which the user can loop through on their own is more user-friendly than a stack that has to be popped.

Currently writing the next version, so if you have improvements/updates, speak up!
02-17-2010, 01:48 AM#4
TEC_Ghost
Would I be able to use this in a custom grid movement system?

Where I have a grid setup. say 20x20, with each tile indexed and each tile with a "passable" boolean. Would this system be able to integrate with my custom movement? Basically just give me an array of the shortest path nodes?
02-17-2010, 04:05 AM#5
Ammorth
Quote:
Originally Posted by TEC_Ghost
Would I be able to use this in a custom grid movement system?

Where I have a grid setup. say 20x20, with each tile indexed and each tile with a "passable" boolean. Would this system be able to integrate with my custom movement? Basically just give me an array of the shortest path nodes?

Version 3.1 will be able to do this.

It will support both modifying weights after setup (during the game) as well as disabling a link entirely. So its just a matter of looping through all linking nodes and disabling the link to the node you wish to turn off.

I am holding off on releasing the next version, in case I get more ideas/suggestions.

And with no current suggestions, version 3.1 is out.

changelog:

PAS 3.1
  • Added functionality for changing link weights after setup
  • Added functionality for enabling and disabling links after setup
  • Made objects private/read-only where applicable (mostly PAS_Node objects)
  • Added function lists to all the script and plugins
  • Added Object Merger macros to create units in the object editor
  • PASMove: Changed the plugin name from PASMovement to PASMove (shorter)
  • PASMoveSafety: Changed the plugin name from PASMovementSaftey to PASMoveSafety (shorter)
  • PASGPS: Added installation instruction about the custom model and changed the paths for the model
  • PASGPS: The system will now register arriving at the end even if you didn't take the recommended path

the changelog can always be found at the end of the README section of the PAS script.
04-02-2010, 04:41 PM#6
Element of Water
Why are we banned from adding nodes outside of PAS? It prevents me from making PASGrid...
04-02-2010, 04:55 PM#7
Ammorth
PAS takes all the nodes you add within the system and does work on them during map init (in its onInit function). Once the onInit function runs, you cannot add nodes to PAS. Therefore, if you require PAS, it's onInit function will run before your library and the nodes will already be set. This is a limitation to the design of PAS. However, if you can provide me with some code and what you plan to do, I may be able to modify PAS to run your code to add nodes. PM or even here works great.
04-02-2010, 09:22 PM#8
Element of Water
This would be the basis for the code (I hope you can read Zinc):

Collapse Zinc:
library PASGrid requires PAS
{
    public struct PAS_Grid
    {
        private constant integer MY_NODES = 0xFFFF;
        
        real x0, x1, y0, y1, gridSpace;
        
        integer width;
        integer height;
        
        private method create_child_child (real x, real y, integer w, integer h)
        {
            // notice I don't add any links here -- I'd like a separate "linkTo" 
            // function -- maybe your strings could be in a "linkToMulti" 
            //function that parses the strings?
            PAS_Node.add(MY_NODES + w + width * h, x, y, gridSpace);
            
            // <code to link this node to the ones around it -- will be a fairly
            // complicated loop, so I'm not going to work it out right now>
        }
        
        private method create_child (real x, integer w)
        {
            real y;
            for (y = x0; y0 <= y <= y1; y += gridSpace)
            {
                this.create_child_child.execute(x, y, w, R2I((y - y0) / gridSpace));
            }
        }
        
        static method create (real x0, real y0, real x1, real y1, real gridSpace) -> thistype
        {
            thistype this = thistype.allocate();
            
            real x;
            
            this.x0 = x0; this.x1 = x1;
            this.y0 = y0; this.y1 = y1;
            this.gridSpace = gridSpace;
            
            this.width  = R2I((x1 - x0) / gridSpace);
            this.height = R2I((y1 - y0) / gridSpace);
            
            for (x = x0; x0 <= x <= x1; x += gridSpace)
            {
                this.create_child.execute(x, R2I((x - x0) / gridSpace));
            }
            
            return this;
        }
    }
}

As you can see, I'd like to be able to dynamically add points and link them together. I could construct something like a pathmap by disabling some nodes when (for example) a tower is built over it.

I suppose I could just write a whole new system, but since you have this A* algorithm already included into your code, it'd be nice to utilise this library.
04-02-2010, 09:42 PM#9
Ammorth
I sent you a PM.
02-13-2011, 04:08 PM#10
Anitarf
Let me see if I get this: you create nodes, giving each a unique id and a string that specifies which other nodes this node is linked to, and then your code parses these strings to create the links? This seems like a rather messy approach, why couldn't users create nodes first, store them in their own array, and then create links between them? Something like:
Collapse JASS:
library PAS_Init initializer Init requires PAS
    globals
        private PAS_Node array n
    endglobals
    private function Init takes nothing returns nothing
        set n[1]=PAS_Node.create(100,0)
        set n[2]=PAS_Node.create(200,0)
        set n[3]=PAS_Node.create(100,100)
        call PAS_Link.create(n[1], n[2])
        call PAS_Link.create(n[1], n[3])
    endfunction
endlibrary