I had this laying around from 10th grade lol, releasing random codes now.
So what is Dijkstra`s algorithm? It calculates the shortest path from one node to all the other nodes in a weighted graph. For node-to-node paths use the A* algorithm instead, if you need the path from every node to every node, use Roy-Floyd or Floyd-Warshall algorithm.
The code reads a weighted graph from a file format that looks like this...
void dijkstra(int start, Data & data) { priority_queue<pair<int,int> > q; pair<int, int> node; for(int i=0; i<data.N; ++i) { data.d[i] = 9999999; // distance = infinity, we cant see the node data.father[i] = -1; // we didnt come here from anywhere... data.marked[i] = false; // we didnt visit this node }
Re-Implemented in C#. Was kinda slow so I had to stackalloc the array.
Using it for Co2 pathfinding from A to B on the same map (not mobs, more like a GPS) and it completes from Warehouse man to Mine Teleporter in 161ms (Twin City) I'm satisfied. It also appears to be very close to the Pathfinding algo used in the client. It's almost always aligned. I'm spawning squamas on each node so I can compare that
Re-Implemented in C#. Was kinda slow so I had to stackalloc the array.
Using it for Co2 pathfinding from A to B on the same map (not mobs, more like a GPS) and it completes from Warehouse man to Mine Teleporter in 161ms (Twin City) I'm satisfied. It also appears to be very close to the Pathfinding algo used in the client. It's almost always aligned. I'm spawning squamas on each node so I can compare that
I think that it would be way better if you used this for map-to-map travels (the nodes being the maps), and on the same map A* would probably yield better results. Then again, I`m happy if you`re happy with the results.
I think that it would be way better if you used this for map-to-map travels (the nodes being the maps), and on the same map A* would probably yield better results. Then again, I`m happy if you`re happy with the results.
I used A* before, it's faster for short paths but it tends to have too much "noise" in it.. I don't know if that made sense..
Lets say the path is like
Start-------------------------End (a straight line)
A* would end up having useless 1 node turns in it like:
Start--------___-----_-----------_---End
While Dijkstra does exactly what it should. A straight line:
Start-------------------------End
If i play around with the cost and heuristics it ends up being way slower than Dijkstra's approach in many cases. A* is faster for < 35 nodes but since I expect a min. of 80 nodes for my case of use, I'll stick with Dijkstra for now
Well, yes, A* is a heuristic search, hence it won`t always yield the absolute very best, but a close approximation, putting more focus on efficiency. Also, is that a problem? I mean you have to split that path in jump points anyway, so does it really matter? Or are you using it for walk/run only (ex. mobs)?
A* will also produce a straight line if you implement tie-breaking.
Well, yes, A* is a heuristic search, hence it won`t always yield the absolute very best, but a close approximation, putting more focus on efficiency. Also, is that a problem? I mean you have to split that path in jump points anyway, so does it really matter? Or are you using it for walk/run only (ex. mobs)?
I'm using it to display every step they need to take. It will put a squama on every tile thats in the path. It's used for more complex quests where they have to talk to npcs that may be really far away or on different maps, so it shows them the way. Conquer GPS basically
[Release] AStar Algorithm 03/07/2012 - CO2 PServer Guides & Releases - 1 Replies Well , I was working on the AStar Algorithm , and am almost finished it.
the way I intended to design it with so I don't need anther struct/class for Node, but anyways it needs some Optimization ("like using Heap (data structure) instead of Dictionary") but so far it works fine.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MapData.Interfaces;
L2 enchant algorithm 03/18/2011 - Lineage 2 - 0 Replies Hello everyone!
I wan't to know the algorithm of the enchanting system on L2j if someone could help!.....I actually wanna know how it works and if there's something i can do to proliferate the chances to enchant a weapon for example!
thanks guys! great forum!
Getting blowfish key and using the algorithm 03/17/2011 - SRO Coding Corner - 10 Replies Good evening:)
I am still busy with the packets of silkroad and I'm now trying to understand on how to decrypt the packets but I'm having some problems with it.
I read drew benton's artikel about the silkroad security but I still don't know on which blowfish key is used to decrypt the packets.
let's say these four packets are the first 4
S -> C
00000 25 00 00 50 00 00 0e d2 a9 27 80 2d c3 23 6c f6 %..P.....'.-.#l.
00016 00 00 00 62 00 00 00 8d ac fe 38 3d d0 9c ef 67 ...
Algorithm for Awarding Virtue Points. 03/13/2011 - CO2 Programming - 25 Replies Does anyone have it? I mean the official algorithm, or as close as possible. If all else fails, I'll spend a while looking through the binaries for it... lol.