AI-Pathfinding-AStar
view release on metacpan or search on metacpan
for your node IDs. As long as they are unique, and can be distinguished
by Perl's "exists $hash{$nodeid}", then they will work. "findPath" then
returns an array (or reference) of node identifiers representing the
least expensive path to your target node. An empty array means that the
target node is entirely unreacheable from the given source.
"findPathIncr" on the other hand allows you to calculate a particularly
long path in chunks. "findPathIncr" also takes the starting and target
node identifiers but also accepts a "state" variable and a maxiumum
number of nodes to calculate before returning. "findPathIncr" then
returns a hash representing the current state that can then be passed
back in for further processing later. The current path can be found in
"$state-"{path}>.
PREREQUISITES
This module requires Heap (specifically Heap::Fibonacci and Heap::Elem)
to function.
SEE ALSO
<http://www.policyalmanac.org/games/aStarTutorial.htm>,
<http://xenon.stanford.edu/~amitp/gameprog.html>
lib/AI/Pathfinding/AStar.pm view on Meta::CPAN
=item * Node ID
=item * Cost to enter that node
=item * Heuristic
=back
Basically you should return an array reference like this: C<[ [$node1, $cost1, $h1], [$node2, $cost2, $h2], [...], ...];> For more information on heuristics and the best ways to calculate them, visit the links listed in the I<SEE ALSO> section below...
As mentioned earlier, AI::Pathfinding::AStar provides two routines named C<findPath> and C<findPathIncr>. C<findPath> requires as input the starting and target node identifiers. It is unimportant what format you choose for your node IDs. As long a...
=head1 PREREQUISITES
This module requires Heap (specifically Heap::Binomial and Heap::Elem) to function.
=head1 SEE ALSO
L<http://www.policyalmanac.org/games/aStarTutorial.htm>, L<http://xenon.stanford.edu/~amitp/gameprog.html>
=head1 AUTHOR
( run in 0.282 second using v1.01-cache-2.11-cpan-8d75d55dd25 )