LoginLogin

GONT Pathfinding Library

Root / Submissions / [.]

PetrifiedLasagnaCreated:
Download:W2DEH3KJ
Version:1.1.2Size:17.87 KB

GONT Library

Goal Oriented Node Traversing Well, it's about time I submitted something after all this time. This is a little library I made which allows you to perform node based path finding. If you are not familiar with goal based path finding I have included a link to a video that explains it quite nicely, or you Google it or whatever. All caught up? Well, I have taken this concept and applied it to a node tree based system which allows you to quickly link nodes together regardless of distance and overlapping paths. This allows for easy creation of complex paths with little overhead when it comes to the actual construction of paths from start to goal. I have included a nice demo application which can help you see the system in action. Understanding Goal-Based Vector Field Pathfinding: https://youtu.be/Bspb9g9nTto
Changelog

1.1.2

-Fixed a bug that was supposed to be fixed in the previous update :P -Changed comparision in DEFAULT_PATH from "ATK_D!=-1 ..." to "ATK_D>-1"

1.1.0

-Changed FIND_PATH so that it now accepts two arguments. The new argument allows you to specify how far ahead the pathfinding algorithm is allowed to go. If you want the whole path then pass zero (0) -Added new function GET_NODE_POS_XY which returns the pos of a node as two variables (i.e. OUT X,Y) -Fixed bug with SET_NODE_LIST which made it not update the number of nodes
Notes: The numbers in the top left corner show a complete path from the node closest to (0,0) to the node most recently tapped

Instructions:

The library itself contains a lot of useful information on how to use the program as well as the demo tool that you can look at. 1. Call GONTINIT 2. Create node with ADD_NODE() 3. Position the node with SET_NODE_POSITION X,Y 4. Link the nodes with LINK_NODES INDEX1,INDEX2 5. Repeat step 2-4 until satisfied. 6. Call CALC_NODE_PATHS INDEX,DIST to build the paths from INDEX 7. Call FIND_PATH INDEX to find a path to the node passed to the previous step. How to use the sample program: L/R: change tool Touchscreen: Use tool (tools that require multiple nodes will require 1 additional tap) Touchscreen (Pathfinding test): Tap a node to display the path distance to all other nodes (calculated dynamically with each tap)
Making a Custom CallbackYou can create just about any pathfinding behavior you like by setting a custom path callback. It is possible to make paths that go away from the target node, wandering around, or any other kind of behavior you can think of. To set a callback, all you have to do is call SET_PATH_CALLBACK and pass a string containing the function name that you want to be referenced. There is already a default function which just finds the shortest path to the target. It gives you a general idea of what your function should look like.
DEF DEFAULT_PATH(DEF_I,DEF_D,ATK_I,ATK_D)
 RETURN ATK_D>-1 AND ATK_D<DEF_D
END
As you can see, the callback will return a true/false value indicating whether or not the nodes sibling (DEF) is more desirable than the current node in question (ATK). The variable with "_I" are for the index of the node while "_D" is for their path distance. So to put it simply the attacking node is more desirable if its distance is greater than -1 (has not been calculated) and it has a shorter path distance "ATK_D<DEF_D"

Fancy. Thanks for the technical submission!

No problem, I have one other library that I am hoping to submit after get a beta for a future game out ;)

Just updated the instructions a bit so everyone knows how to create their own custom callback. Also fixed two "developer errors".

I think library uses DISTANCE() but is commanted :/