Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411518 Posts in 69380 Topics- by 58436 Members - Latest Member: GlitchyPSI

May 01, 2024, 12:23:53 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)AStar problems
Pages: 1 [2]
Print
Author Topic: AStar problems  (Read 5840 times)
Tycho Brahe
Level 10
*****

λx.x


View Profile
« Reply #20 on: July 29, 2010, 01:32:29 PM »

Thats a good point, however it is likely that they will be better, and a higher likelihood that nodes in the first 50% of the list will have a higher average f_score than nodes in the second 50%. I accept that occasionally new nodes are not better, but the likelihood is that they will be.
Logged
bateleur
Level 10
*****



View Profile
« Reply #21 on: July 29, 2010, 02:30:39 PM »

a sort is going to take much much longer than iterating through once for the lowest value. No sorting!

Of course, if we really cared about efficiency we'd be keeping everything in balanced binary trees instead of lists. That actually makes a much bigger difference than not sorting (at least in terms of formal algorithmic complexity).

(This post brought to you by the Nobody Cares department!)
Logged

st33d
Guest
« Reply #22 on: July 29, 2010, 02:32:28 PM »

(This post brought to you by the Nobody Cares department!)

 Cry
Logged
nikki
Level 10
*****


View Profile
« Reply #23 on: July 30, 2010, 03:42:14 PM »

Quote
(This post brought to you by the Nobody Cares department!)
well i would care but lists are implemented in my language natively (blitzmax) and balanced binary trees are not.

i've read the wikipage, but still am at a loss how i would implement such a thing...
Logged
PleasingFungus
Level 7
**



View Profile WWW
« Reply #24 on: July 30, 2010, 11:19:45 PM »

Actually, better than a balanced binary tree for this case would be a priority queue. You're always retrieving the element from the open list with the smallest f-score (highest priority), so a priority queue is just what you need... and, looking at the article I linked to, it appears I'm not the first one to think of this.

Still from the Department of Nobody Cares, of course.

(Ooo, SMA* sounds interesting...)
Logged

Finished games: Manufactoria! International King of Wine!
And others on my site.
bateleur
Level 10
*****



View Profile
« Reply #25 on: July 30, 2010, 11:28:34 PM »

Actually, better than a balanced binary tree for this case would be a priority queue.

Whilst you're correct that a priority queue is indeed what's wanted, note that it isn't "better" as such since a tree is a data structure whilst a priority queue is an abstract thing (effectively a requirements specification). Indeed, priority queues can be efficiently implemented using binary trees!
Logged

nikki
Level 10
*****


View Profile
« Reply #26 on: July 30, 2010, 11:34:56 PM »

uumhmf , these hardcore termonology technicalities...
i've implemented dijksta (a* without different costing 'terrain tiles' (?right?)) once, and if i remember correctly one/I just pushed/popped the nodes on the open/closedlist , when done correctly this made the order perfect from the start, when backtracking with the smallest distance for every node.... (without the need to sort)

i'm still waking up, but what you guys are talking about, is that even more better  ? Wink
Logged
PleasingFungus
Level 7
**



View Profile WWW
« Reply #27 on: July 31, 2010, 01:17:27 PM »

Actually, better than a balanced binary tree for this case would be a priority queue.

Whilst you're correct that a priority queue is indeed what's wanted, note that it isn't "better" as such since a tree is a data structure whilst a priority queue is an abstract thing (effectively a requirements specification). Indeed, priority queues can be efficiently implemented using binary trees!


You're right; I thought of that after I posted, but didn't end up making an edit. Thanks!

uumhmf , these hardcore termonology technicalities...
i've implemented dijksta (a* without different costing 'terrain tiles' (?right?)) once, and if i remember correctly one/I just pushed/popped the nodes on the open/closedlist , when done correctly this made the order perfect from the start, when backtracking with the smallest distance for every node.... (without the need to sort)

i'm still waking up, but what you guys are talking about, is that even more better  ? Wink

What you're describing sounds like a depth-first search, not Dijkstra's Algorithm. The key thing about Dijkstra is that it checks the closest nodes (to the origin) first; this requires sorting the open list. The difference between A* and Dijkstra is that A* also accounts for the (estimated) distance to the destination as well as the distance travelled from the origin. This requires a heuristic, a guess as to how far any given node will be from the destination; it's generally quite easy to come up with such a heuristic on a tile-based map (just get the manhattan or euclidean distance between the tile and the destination), but much harder with something like, say, a graph of nodes in a wireless network, which is why Dijkstra's algorithm might be used there instead.

A*'s quite nice, but it's an optimization; like all optimizations, it's generally better to implement a simpler solution (like a DFS, or Djikstra's) until you know that you actually need the greater speed. (Optimizations come at the cost of maintainability, which you want to preserve as much as possible.) If you didn't have a problem with your solution, there was probably no need for anything more sophisticated.
Logged

Finished games: Manufactoria! International King of Wine!
And others on my site.
nikki
Level 10
*****


View Profile
« Reply #28 on: July 31, 2010, 02:23:40 PM »

Oops yep your right it was depth-first, my bad  Embarrassed
and it was perfect/not bad at all for what i needed at that moment...

for the sake of learning i'll start with Dijkstra one of these days/weeks then.
bye
Logged
Pages: 1 [2]
Print
Jump to:  

Theme orange-lt created by panic