A* Pathfinder (3D map) in samp
#1

In recent days I have developed a pathfinder totally in pawn and until then it is functional. My initial idea was to develop it and make it work even though it was too slow to use and then try to adapt it to a plugin.

How does it work?
The A * algorithm in question is not the biggest problem, in fact it calculates up to 3000 nodes without crashing the server (which is done in pawn is fast). The problem is in the 'spiral' algorithm I'm using to generate the nodes before looking for a path, below is the image of how it basically works:


The spiral begins between the start and end nodes, spreading through both, to each node it creates, I use the CA_RayCastMultiLine function from top to bottom to catch all the collisions and in each collision create a new node in the place, as in the image :

All of these nodes are interconnected with each other if there is no collision between them. Thus, the path between a and b will be found even if it is under a bridge (example).
The problem is how I am connecting the nodes: For each created node I'm looping in the opposite direction of the spiral until I make a complete loop, and for each node the loop passed I'm checking if there is no collision between the nodes, checking if the difference Z is not greater than 1.8.

The discussion here is that based on this method, can you think of any better logic or way to create these nodes and connect them using CA_RayCastMultiLine? Another question is how much better performance will be if I do this same method in C ++ and adapt to a plugin, because currently to calculate a path between 50 meters with 3.0 distance between the nodes takes about 1-2 + seconds.

#EDIT 1
I found a better solution, in fact I do not need to connect them before looking for the path. The algorithm A * itself will seek the neighbors only from the necessary nodes. With this, I can now find a path between 50 meters in just 40 ms.
Reply


Messages In This Thread
A* Pathfinder (3D map) in samp - by ForT - 26.12.2018, 01:47
Re: A* Pathfinder (3D map) in samp - by MrStead - 26.12.2018, 05:16
Re: A* Pathfinder (3D map) in samp - by MrStead - 26.12.2018, 05:19
Re: A* Pathfinder (3D map) in samp - by MrStead - 26.12.2018, 05:26
Re: A* Pathfinder (3D map) in samp - by MrStead - 26.12.2018, 05:29
Re: A* Pathfinder (3D map) in samp - by ForT - 26.12.2018, 15:17
Re: A* Pathfinder (3D map) in samp - by MrStead - 26.12.2018, 16:25
Re: A* Pathfinder (3D map) in samp - by Pottus - 27.12.2018, 00:41
Re: A* Pathfinder (3D map) in samp - by ForT - 27.12.2018, 18:32
Re: A* Pathfinder (3D map) in samp - by Baboon - 28.12.2018, 11:29
Re: A* Pathfinder (3D map) in samp - by Pottus - 29.12.2018, 17:29
Re: A* Pathfinder (3D map) in samp - by Crayder - 29.12.2018, 17:54
Re: A* Pathfinder (3D map) in samp - by MrStead - 30.12.2018, 18:12
Re: A* Pathfinder (3D map) in samp - by MrStead - 30.12.2018, 18:24
Re: A* Pathfinder (3D map) in samp - by ForT - 30.12.2018, 18:36
Re: A* Pathfinder (3D map) in samp - by MrStead - 30.12.2018, 18:42
Re: A* Pathfinder (3D map) in samp - by Kar - 30.12.2018, 19:50
Re: A* Pathfinder (3D map) in samp - by kristo - 31.12.2018, 17:01
Re: A* Pathfinder (3D map) in samp - by Pottus - 01.01.2019, 02:13
Re: A* Pathfinder (3D map) in samp - by Kar - 01.01.2019, 02:21
Re: A* Pathfinder (3D map) in samp - by cessil - 01.01.2019, 05:46
Re: A* Pathfinder (3D map) in samp - by Baboon - 01.01.2019, 15:04
Re: A* Pathfinder (3D map) in samp - by Pottus - 01.01.2019, 15:39
Re: A* Pathfinder (3D map) in samp - by DRIFT_HUNTER - 08.01.2019, 19:42

Forum Jump:


Users browsing this thread: 1 Guest(s)