Comments on: Plug-n-Play pathfinding http://xnafan.net/2009/11/plug-n-play-pathfinding/ XNA tutorials, code and games Fri, 10 Aug 2018 04:55:21 +0000 hourly 1 https://wordpress.org/?v=4.2.22 By: admin http://xnafan.net/2009/11/plug-n-play-pathfinding/comment-page-1/#comment-45 Wed, 27 Jan 2010 09:10:30 +0000 http://xnafan.net/?p=24#comment-45 Excellent Roy - thanks for the tips. I will certainly have a look at your code as well :).
I have a penchant for optimization and you seem to have quite a few really worthy goldnuggets there.

]]>
By: Roy http://xnafan.net/2009/11/plug-n-play-pathfinding/comment-page-1/#comment-43 Tue, 26 Jan 2010 22:54:04 +0000 http://xnafan.net/?p=24#comment-43 Altough Eric Lipperts' sollution is indeed much more sophisticated than a solution I wrote a while ago, I would like to point out that 46ms for finding a path in a 10x10 is a bit long, even for a maze.

I've got a few tips to improve speed:

-Give the nodes an open and closed lists boolean flags so the lookup for "is in open" is O(1) (you can now even get rid of the closed list).

-Use integers for scores rather than floats. (diagonal movement is usual 1.4x the cost of orthogonal movement, so make the standard costs 14(dia) and 10(ortho)).

-Use a MinHeap for the openlist.

This should make your implementation a lot faster. You can have a look at my sample code:
http://roy-t.nl/index.php/2009/07/07/new-version-a-pathfinding-in-3d/ but I think it would be faster to change your existing code with some speed ups you find usefull. than to change to my "not so elegant and pluggable" version.

My implementation takes an average of 1.7ms on 10x10x10 grid. Although this was not a maze but a randomly constructed 3d grid I think you should be able to get your code down to taking at most 10ms to find a path.

(This is really handy because it means you might not have to spawn a seperate thread for pathfinding, an extra 50ms would really disrupt the game loop, but an extra 10ms might not be noticeable enough to need an extra pathfinding thread, as long as you only try to find one path per iteration).

Anyway I hope these are some useful tips! Oh and btw, you've been featured on http://www.sgtconker.com !

]]>
By: admin http://xnafan.net/2009/11/plug-n-play-pathfinding/comment-page-1/#comment-41 Tue, 26 Jan 2010 16:39:34 +0000 http://xnafan.net/?p=24#comment-41 So busy at work I'm still catching up on the 3.0 (and 2.0 - *sigh*) framework. :)
Thanks for the clarification Nik!

]]>
By: Nik Radford http://xnafan.net/2009/11/plug-n-play-pathfinding/comment-page-1/#comment-40 Tue, 26 Jan 2010 13:33:16 +0000 http://xnafan.net/?p=24#comment-40 ah, it stripped my < and &rt; symbols. Meh at WordPress.

]]>
By: Nik Radford http://xnafan.net/2009/11/plug-n-play-pathfinding/comment-page-1/#comment-39 Tue, 26 Jan 2010 13:32:26 +0000 http://xnafan.net/?p=24#comment-39 Just to let you know, Func isn't a key word, it's a delegate type. Actually, several generic delegates Func, Func, Func etc, etc,etc.

There are also similar delegates which are similar Action, Action, etc are used the same as Func except where no return value is required :)

Predicate used when you want a function that compares and return true or false based on the comparison (Pretty much the same as Func, except it's just Predicate :))

Delegates are useful things 😀

]]>