Node Pathfinding planning?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Node Pathfinding planning?

Post by Major Cooke »

So, I'm making a pathfinding system using actors placed down via map editor and I get the gist behind what to do with it.
  • Gather all nearby nodes that can be seen and store them in an array per each nodes
  • A function to get the nearest node for the requester, used by anyone
  • Nodes 'radio' out to other nodes via the target alerting the rest
  • Actor receives the list of nodes to traverse in order once the nodes collect the target web and calling actor web
  • Upon reaching the node, the travelling actor checks sight with the target. If in sight, perform regular chasing. If not, radio out again.
Obviously the easiest things I can do is minimize the amount of ThinkerIterator traversing. Set all the nodes to their own statnum, make sure they filter out anything not of their class.

But... What about optimizing this to be even more efficient or better?

(I'd post an image of SUPERNatural's sewer system in GZDB but since getting a new hard drive, I have yet to finalize all my software reinstallation)
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: Node Pathfinding planning?

Post by Apeirogon »

So I try solve one of graph theory problem...
English no my native, and explaining it I can confuse you much more that you been before my explains. So I better give you link
https://en.wikipedia.org/wiki/Shortest_ ... Algorithms
Further you go alone.

But, if you realy place nodes in map editor, you better by hand "draw" path from one node to all others and store all paths to this one nodes. Because amount of avaliable path growing as factorial of nodes quantity
3 nodes = 6 avaliable path, one from which shortest
4 nodes = 24 path, one from which shortest plus some not shortest, but about equal shortest
5 = 120 one from which shortest plus some not shortest, but about equal shortest
...
15 = 1307674368000 one from which shortest plus some not shortest, but about equal shortest
16 = 20922789888000 you get it
n = 1*2*3*.....*(n-1)*n


If you try make something like this
viewtopic.php?f=105&t=58168&p=1024636&h ... n#p1022609
which you already seen, algorithm take much more time to find, at least some, path from point A to point B. So, use it only if you have eternity to wait...
ZippeyKeys12
Posts: 111
Joined: Wed Jun 15, 2016 2:49 pm

Re: Node Pathfinding planning?

Post by ZippeyKeys12 »

I was working on a path finding system but I stored paths between specific nodes. All node are labeled with a letter and have coords and they're spawned with Zscript(stored in a lump) on map start.
Main problem was a ballooning file size and being a pain in the ass to do. I was considering making a script so that when I ran it the first time it spawned the nodes and checked line of sight to generate the connections, but the file got corrupted so I gave up. Also planned on implementing this.
I used this page as a reference, but you've probably already seen it.
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: Node Pathfinding planning?

Post by Apeirogon »

In other topic I see you know, or at least suspect of existence, visual c++, so here algorithm which used in spellforce. Or at least it say so.
https://github.com/recastnavigation/recastnavigation
Instructions inside.
Post Reply

Return to “Scripting”