Find paths through 2D mazes.
File: |
PathFinder.lib |
Version: |
1.0 |
Author: |
John Master |
Details
Constants
Sub routines
With this library you can find the closest path between two points in a discrete map.
Directions |
||
Name |
Description | |
PF_DOWN |
Down. |
|
PF_UP |
Up. |
|
PF_LEFT |
Left. |
|
PF_RIGHT |
Right. |
Name |
Parameters |
Brief description |
|
procedure |
steps |
Set max number of steps to be generated. |
|
function |
&map[][], srcX, srcY, dstX, dstY |
Return path. |
|
function |
&path[][], step |
Return step direction. |
procedure SetMaxPathSteps ( steps )Set the maximum number of steps that may be produced while walking between the two points. If more steps are required, the algorithm will abort, telling the caller that no path could be found. The default value is 128 steps.
[ Back ] |
function FindPath[][] ( &map[][], srcX, srcY, dstX, dstY )Return path between '(srxX, srcY)' and '(dstX, dstY') in 'map' as a 2D integer array. The array will have the form [step][x, y], where either 'x' or 'y' changes between 'step' and 'step' + 1. Anything but 0 in 'map' is treated as an obstacle.
Return value [ Back ] |
function GetStepDirection ( &path[][], step )Return the direction in path returned from 'FindPath' between 'step' and 'step' + 1. The function will return 'PF_DOWN', 'PF_UP', 'PF_LEFT' or 'PF_RIGHT', or 0 on error.
Return value [ Back ] |
Generated with NLDoc 20140630.