![]() |
| [[ Home | Forums | 3D Engines Database | Wiki | Articles/Tutorials | Game Dev Jobs | IRC Chat Network | Contact Us ]] |
|
|
#1 |
|
DevMaster Editor
Join Date: Jan 2005
Posts: 54
|
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. |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Jan 2003
Location: ON, Canada
Posts: 524
|
A very fine tutorial. That is what I was looking for, thank you very much Russell Long.
___________________________________________
"What ever happened to happily ever after?" |
|
|
|
|
|
#3 |
|
Member
Join Date: May 2003
Posts: 44
|
np
|
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Jan 2003
Location: East Coast, USA
Posts: 370
|
yeah - thanks! very informative and useful.
![]()
___________________________________________
Imagine. |
|
|
|
|
|
#5 |
|
Member
Join Date: May 2003
Posts: 44
|
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) |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Jan 2003
Location: ON, Canada
Posts: 524
|
Wow, yeah, that would be great! Thanks a lot.
___________________________________________
"What ever happened to happily ever after?" |
|
|
|
|
|
#7 |
|
New Member
Join Date: Jan 2003
Posts: 10
|
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. |
|
|
|
|
|
#8 |
|
Member
Join Date: May 2003
Posts: 44
|
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
|
|
|
|
|
|
#9 |
|
New Member
Join Date: Jan 2003
Posts: 10
|
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).
|
|
|
|
|
|
#10 |
|
Member
Join Date: May 2003
Posts: 44
|
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
|
|
|
|
|
|
#11 |
|
Senior Member
Join Date: Jan 2003
Location: ON, Canada
Posts: 524
|
Great, thank you so much!
___________________________________________
"What ever happened to happily ever after?" |
|
|
|
|
|
#12 |
|
DevMaster Staff
Join Date: Jul 2003
Location: Northern Ireland
Posts: 1,250
|
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! |
|
|
|
|
|
#13 |
|
Member
Join Date: May 2003
Posts: 44
|
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 |
|
|
|
|
|
#14 |
|
DevMaster Staff
Join Date: Jan 2003
Location: Mars
Posts: 1,141
|
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. |
|
|
|
|
|
#15 |
|
New Member
Join Date: Jan 2003
Posts: 10
|
* bump *
Any ideas of when the next article in the series will be up? |
|
|
|
|
|
#16 |
|
New Member
Join Date: Nov 2004
Posts: 4
|
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 (;-) ;-) ;-)) |
|
|
|
|
|
#17 |
|
Senior Member
Join Date: Aug 2004
Location: USA
Posts: 829
|
If dijkstra doesnt meet your needs use A-star (A*) This is pretty much the fastest for general pathfinding.
___________________________________________
Jesse Coyle |
|
|
|
|
|
#18 |
|
New Member
Join Date: Feb 2005
Posts: 1
|
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 ?
|
|
|
|
|
|
#19 |
|
New Member
Join Date: Sep 2005
Location: Rome
Posts: 9
|
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. |
|
|
|
|
|
#20 | |
|
Senior Member
Join Date: Sep 2005
Location: .nl
Posts: 505
|
If you had read the article more carefully, you would have noticed the following line:
Quote:
|
|
|
|
|
|
|
#21 |
|
DevMaster Staff
Join Date: Oct 2004
Location: Seattle, WA
Posts: 3,707
|
It might make the code more readable to define a constant, like
Code:
Code:
___________________________________________
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. |
|
|
|
|
|
#22 |
|
New Member
Join Date: Mar 2008
Posts: 1
|
Code:
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). |
|
|
|
|
|
#23 | |
|
Member
Join Date: Nov 2004
Posts: 46
|
Quote:
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 |
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|