[Include] Dijkstra.inc - Dijkstra pathfinding algorithm
#1

Introduction

This is a basic implementation of the dijkstra algorithm, including a basic example of a GPS system working on nodes, using this include.

Function(s)

We have only one basic function:
pawn Код:
stock Dijkstra(const aeNodes[][], iStart, iEnd, aiPath[], const iSize = sizeof(aeNodes))
Here's how the node array should look like:
pawn Код:
enum e_Nodes {
    Float: e_fNX,
    Float: e_fNY,
    Float: e_fNZ,
    e_iLink1,
    e_iLink2,
    e_iLink3,
    e_iLink4
};
If the link is invalid you have to use -1. See usage in the example filterscript.

Example

In the link below, there's a basic GPS system using this pathfinding include. The nodes included are complete LV nodes and were made by me a while ago. I will do the whole San Andreas world once I have some free time and when I feel like it. I don't recommend using the default San Andreas nodes from NODESX.DAT with this include as there are too much to calculate in a reasonable time.

[ame]http://www.youtube.com/watch?v=rENx33otwE4[/ame]

GPS.pwn

Download

Dijkstra.inc
Reply
#2

So, this is basically a sort of system including positions for checkpoints and the system calculates where's the closest position is? Am I right with this? Cause I'm afraid I don't really understand the working and usages of this system.
Reply
#3

Nice done, Ryder. I will be using this in my future project.
Reply
#4

Quote:
Originally Posted by -Danny-
Посмотреть сообщение
So, this is basically a sort of system including positions for checkpoints and the system calculates where's the closest position is? Am I right with this? Cause I'm afraid I don't really understand the working and usages of this system.
dijkstra's algorithm find the shortest path between any 2 points.
Reply
#5

Well, there is this plugin released, you know?
Reply
#6

Just Amazing! Keep your work up.
Reply
#7

Thanks!

Quote:
Originally Posted by wups
Посмотреть сообщение
Well, there is this plugin released, you know?
It is not the same. The GPS thing is just an example using this include. You can create tons of other stuff using this include.
Reply
#8

Nice
Reply
#9

I love Dijkstra and it's really useful.
As you said with this algorithm you can do a lot of things. We learned it at school (graph theory) and it's not only for GPS Systems.

Furthermore the plugin from Gamer_Z doesn't work on every server (on the other hand Gamer_Z work is also good)
Reply
#10

Quote:
Originally Posted by wups
Посмотреть сообщение
Well, there is this plugin released, you know?
Well, there is not a linux version for that plugin...

Thanks RyDeR`, going to upgrade my gps system

the paste id is invalid btw.

EDIT: nvm, lacks on nodes
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)