DevMaster.net Forums
[[ Home | Forums | 3D Engines Database | Wiki | Articles/Tutorials | Game Dev Jobs | IRC Chat Network | Contact Us ]]

Go Back   DevMaster.net Forums > Site Discussions > Articles Discussion
User Name
Password
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
Old 07-15-2003, 11:13 PM   #1
DmEditor
DevMaster Editor
 
Join Date: Jan 2005
Posts: 54
Default

An Introduction to Pathfinding
Author: Russell Long
Description: The author introduces the subject of pathfinding and explains about Dijkstra's Algorithm, which is one of the algorithms for finding the shortest path between two points.

Post your discussions/comments here by clicking on Add Reply.
DmEditor is offline   Reply With Quote
Old 07-16-2003, 07:28 AM   #2
Noor
Senior Member
 
Join Date: Jan 2003
Location: ON, Canada
Posts: 524
Default

A very fine tutorial. That is what I was looking for, thank you very much Russell Long.
___________________________________________
"What ever happened to happily ever after?"
Noor is offline   Reply With Quote
Old 07-16-2003, 07:36 AM   #3
moomin
Member
 
Join Date: May 2003
Posts: 44
Default

np
moomin is offline   Reply With Quote
Old 07-16-2003, 09:19 AM   #4
donBerto
Senior Member
 
donBerto's Avatar
 
Join Date: Jan 2003
Location: East Coast, USA
Posts: 370
Default

yeah - thanks! very informative and useful.

___________________________________________
Imagine.
donBerto is offline   Reply With Quote
Old 07-16-2003, 09:37 AM   #5
moomin
Member
 
Join Date: May 2003
Posts: 44
Default

A* will be my next article and should elegantly proceed the dijkstra tutorial since in essence A* is dijkstra with only one major addition!!!!!


and then I'll probably end with a Civilisation style demo as last article

(maybe pure SDL or opengl in 3D, if I get the hang of textures)


(i.e. you've got to get a person across some terrain)
moomin is offline   Reply With Quote
Old 07-16-2003, 11:08 AM   #6
Noor
Senior Member
 
Join Date: Jan 2003
Location: ON, Canada
Posts: 524
Default

Wow, yeah, that would be great! Thanks a lot.
___________________________________________
"What ever happened to happily ever after?"
Noor is offline   Reply With Quote
Old 07-17-2003, 02:11 AM   #7
chenbin_osu
New Member
 
Join Date: Jan 2003
Posts: 10
Default

Good Evening:

Thanks for the great article!

My question is: What is the most efficient way of finding the shortest path? Is it Dijastra's Algorithm or is there another one? How efficient is it? Also, how practical is it when using it in a game?

Thank you.
chenbin_osu is offline   Reply With Quote
Old 07-17-2003, 02:31 AM   #8
moomin
Member
 
Join Date: May 2003
Posts: 44
Default

The most effcient in terms of memory speed etc is the A* algorithm (its used in loads of games). The A* algorithm is based upon the dijkstra algorithm but includes a heuristic(guess) element. Thats going to be my next article, and if you grasped my dijkstra article, A* should be trivial
moomin is offline   Reply With Quote
Old 07-17-2003, 10:48 PM   #9
chenbin_osu
New Member
 
Join Date: Jan 2003
Posts: 10
Default

Cool. I'm looking forward to that article. When will get it get posted? Will it get posted here on this site (I am already liking this site, btw).
chenbin_osu is offline   Reply With Quote
Old 07-18-2003, 01:56 AM   #10
moomin
Member
 
Join Date: May 2003
Posts: 44
Default

I'll probably do a write up this weekend of the A* tutorial, maybe a few diagramd to show the different approach, apex will sort the formatting and then whoop it on
moomin is offline   Reply With Quote
Old 07-18-2003, 05:32 AM   #11
Noor
Senior Member
 
Join Date: Jan 2003
Location: ON, Canada
Posts: 524
Default

Great, thank you so much!
___________________________________________
"What ever happened to happily ever after?"
Noor is offline   Reply With Quote
Old 07-18-2003, 07:44 AM   #12
Ed Mack
DevMaster Staff
 
Join Date: Jul 2003
Location: Northern Ireland
Posts: 1,250
Default

Is a heuristic usually just a bit of pythags to find he distance (maybe taking into avg. tile cost too), or is it a lot more complicated than that? How accurate is a guess (I know, more the better in efficiency)

Thanks for this tutorial!
Ed Mack is offline   Reply With Quote
Old 07-21-2003, 02:37 AM   #13
moomin
Member
 
Join Date: May 2003
Posts: 44
Default

Ed Mack your virtually there, basically there are 3 major types eulian which you mention and also arrrg (grid x,y) based. They merely make going to your destination more attractive, thus your likely to get there earlier. Why is this important? Well our dijkstra algorithm finds EVERY path to EVERY node. The A* algorithm stops when it finds the destination node.


ANd your right about talking average tile cost it works by



Attractiveness of edge = Distance from goal + edge weight.


When adding to the shortest path special value though, we only add the edge weight, its not accumulative with the distance from goal
moomin is offline   Reply With Quote
Old 07-21-2003, 03:34 PM   #14
baldurk
DevMaster Staff
 
baldurk's Avatar
 
Join Date: Jan 2003
Location: Mars
Posts: 1,141
Default

Russell Long??

sorry...
___________________________________________
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.
baldurk is offline   Reply With Quote
Old 07-27-2003, 02:12 AM   #15
chenbin_osu
New Member
 
Join Date: Jan 2003
Posts: 10
Default

* bump *

Any ideas of when the next article in the series will be up?
chenbin_osu is offline   Reply With Quote
Old 11-24-2004, 12:41 AM   #16
costasgr43
New Member
 
Join Date: Nov 2004
Posts: 4
Default

This algorithm is quick for small boards ie 5x5, 10x10, at most 20x20. What about a big 100x100 or 200x200 board with 10.000 and 40.000 nodes. It would be inefficient. Pre-calculation of the paths would not only be too memory consuming (you'd have to save every path for each pair of positions (or areas) ). What i have thought and trying to implement (damn it i quit easily whenever i have to think ;-)) is to creating a picture map (a monochrom would be enough: white for passable terrain - black for non passable terrain) and making line tests. That is to check every pixel in the line joining start and end and if we find a black pixel we "crawl" around the obstacle until we find a point that "sees" the end point. So we find all posible paths, we "stretch" them (that is if we have 10 points in the path and 1st "sees" the 3rd or 4th then we delete the between points (needless : a straight line is the quickest way)) and then get the quickest path (simple if we just count the distances - complex if we compute the terrain speed so we also have to compute the non-"stretched" and semi-"stretched" paths). It must surely quickest than computing all the pixels around the start point until we find the path. If you'd like a more carefull description of the "algorithm" please tell me to write an article to present it.

Now i dont want to take the credit for this (truly divine i must confess ;-)) algorithm so if you have seen a good description of it or something like that please tell me to know. Else i will have to give my name to it and get all the fame and recognition to hope that in the future they will say how did Costas beat up Dijkstra (;-) ;-) ;-))
costasgr43 is offline   Reply With Quote
Old 11-25-2004, 09:03 PM   #17
NomadRock
Senior Member
 
NomadRock's Avatar
 
Join Date: Aug 2004
Location: USA
Posts: 829
Default

If dijkstra doesnt meet your needs use A-star (A*) This is pretty much the fastest for general pathfinding.
___________________________________________
Jesse Coyle
NomadRock is offline   Reply With Quote
Old 02-20-2005, 06:10 AM   #18
mustrix
New Member
 
Join Date: Feb 2005
Posts: 1
Default

I really wanted to learn more about this, im not english so its kind of hard to understand it, what do u mena by relax edges ? and what happens when 2 edges adjacent to a node have the same height ? can someone help plz ?
mustrix is offline   Reply With Quote
Old 10-01-2005, 08:03 AM   #19
gasto
New Member
 
gasto's Avatar
 
Join Date: Sep 2005
Location: Rome
Posts: 9
Default Re: An Introduction to Pathfinding

No ofense intended in the following comments. Just to show you why your article is uneffective.

It was suposed to be an introduction to Pathfinding, and it all went well until I got to:

EdgeWeights[node1][node3] = 999999999999999;

What on earth is that suposed to mean?!

And then you just keep talking about a heightmap which I know what it is but, due to the nature of the article, you should have explained and made a graphical example.

Then you keep your 999999... madness with the specialDistance[MAX_NODES] without explaining why it should be set up at a large number.

Advancing through the article, ideas become more confusing, and even with patience, no true beginner would make it to the end.

Your technical knowledge is O.K. , but the article's rough walkthrough makes it badly named, considering the word 'introduction' in the title.
___________________________________________
To live is to be eager to die.
gasto is offline   Reply With Quote
Old 10-01-2005, 09:00 AM   #20
roel
Senior Member
 
roel's Avatar
 
Join Date: Sep 2005
Location: .nl
Posts: 505
Default Re: An Introduction to Pathfinding

If you had read the article more carefully, you would have noticed the following line:

Quote:
But what if there exists no edges between nodes!! Well you'd have to have a number that’s large i.e. take it as infinity, which will be used to indicate no edges exists. That is... 999999999999999
roel is offline   Reply With Quote
Old 10-01-2005, 12:59 PM   #21
Reedbeta
DevMaster Staff
 
Join Date: Oct 2004
Location: Seattle, WA
Posts: 3,707
Default Re: An Introduction to Pathfinding

It might make the code more readable to define a constant, like
Code:
const float infinity = 999999999999;
and use that instead of hard-coding the extremely large value. In fact, what's even better is to use
Code:
#include <limits> const float infinity = std::numeric_limits<float>::infinity();
as this gives you the true floating-point infinity value, which is guaranteed to compare as greater than any finite floating-point value.
___________________________________________
Currently working at Sucker Punch
reedbeta.com - OpenGL demos and other projects
Luabridge - a lightweight, dependency-free C++/Lua binding library.
CD Lite - an unobtrusive, minimal CD player application for Windows.

Last edited by Reedbeta : 10-01-2005 at 01:02 PM.
Reedbeta is offline   Reply With Quote
Old 03-10-2008, 04:46 PM   #22
Brullig
New Member
 
Join Date: Mar 2008
Posts: 1
Default Re: An Introduction to Pathfinding

Code:
We have a series of nodes, with edges. This is our first consideration, we need to know which nodes are connected before we start (a limitation of dijkstra's algorithm). For this article we'll use a 2D array, in which we store the edge weights. The maximum number of edges that could possibly exist would be: Number of Nodes * Number of Nodes

This is wrong. The maximum number of nodes for Djikstra's Algorithm is n(n-1)/2, where n is the total number of nodes in your graph. This is because Djikstra's does not consider a node having a path to itself, nor does it consider a path being traversed from different directions as possibly having different weights (e.g. EdgeBA has weight 5, but EdgeAB has weight 3).
Brullig is offline   Reply With Quote
Old 08-19-2008, 04:57 AM   #23
rego
Member
 
Join Date: Nov 2004
Posts: 46
Default Re: An Introduction to Pathfinding

Quote:
Originally Posted by Brullig
Code:
We have a series of nodes, with edges. This is our first consideration, we need to know which nodes are connected before we start (a limitation of dijkstra's algorithm). For this article we'll use a 2D array, in which we store the edge weights. The maximum number of edges that could possibly exist would be: Number of Nodes * Number of Nodes

This is wrong. The maximum number of nodes for Djikstra's Algorithm is n(n-1)/2, where n is the total number of nodes in your graph. This is because Djikstra's does not consider a node having a path to itself, nor does it consider a path being traversed from different directions as possibly having different weights (e.g. EdgeBA has weight 5, but EdgeAB has weight 3).

i was just about to query this - didnt think it made sense if there is only a maximum number of 2 edges to 1 node - thanks for clearing this up
rego is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Forum Jump


All times are GMT -7. The time now is 09:52 AM.


Powered by vBulletin
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.