1
2
In response to Ter13
|
|
Well, I just noticed that mine returns the path in reverse order, so you get my vote :P
|
In response to Jittai
|
|
You got some thought churning at least.
|
In response to Jittai
|
|
Jittai wrote:
Did I help? :( Lol, Your suggestions were actually incredibly useful for later optimization. Apply your heuristic to my code, and it'll function a lot faster in the majority of cases. |
Oh, and when you have time:
http://harablog.wordpress.com/2011/09/07/jump-point-search/ The jump point search is good for equal-cost pathfinding solutions, but that's about it. It won't help you with variable cost at all. |
In response to Ter13
|
|
That's some nice code. A* never really crossed my mind when thinking about this, but I guess there's a lot of similarity.
Ter13 wrote: //pathfinding failed Why do that? It's redundant. The . var will already return null anyway, by default. The failure will make no difference in this case. Redundant code is a habit that I try to stay away from, unless of course I'm feeling extra paranoid at the time! |
Notation in this case, but like I've said before, it's a habit from languages where you don't have a VM to babysit you.
If you don't have a return path in C++, your compiler is going to throw a fit. --It's a micro-optimization in this case, but yeah, I agree. It's a point that gets pointed out a lot to me. In the case of what I try to put on the forums, though, I'd prefer to be extra careful than put out tightly packed, needlessly optimized code. |
1
2
I think, however, what Doohl is struggling with is more specifically in the how to, and not necessarily in optimization.
Doohl: This is a common problem. Your brain is stuck in the grid. Forget the grid for a minute. A grid is just a network of nodes in two-dimensional space.
BYOND's tile-based pathing assumes that nodes are tiles on a grid. So a square having 8 neighbors is completely arbitrary. You are already determining links with your dotted lines. Use those to determine your neighbors.
In your case, you are forgoing locality for the sake of explicitly declared links.
Thus, you can forget about investigating any unusual algorithm, and use A* just like normal for tile-based pathing:
This is hum-drum A*, with no optimizations, and no heuristic. Any node is as good as any other for searching. You can improves this by hunting the shortest nodes first, or by hunting the node in the closest direction first. Whatever you decide.