AyStar  6
 All Classes Functions
Classes | Public Member Functions | Public Attributes | List of all members
AyStar Class Reference

An AyStar implementation. More...

Classes

class  Path
 The path of the AyStar algorithm. More...

Public Member Functions

function GetAuthor ()
function GetName ()
function GetShortName ()
function GetDescription ()
function GetVersion ()
function GetDate ()
function CreateInstance ()
function GetCategory ()
constructor AyStar (pf_instance, cost_callback, estimate_callback, neighbours_callback, check_direction_callback)
function InitializePath (sources, goals, ignored_tiles=[])
 Initialize a path search between sources and goals.
function FindPath (iterations)
 Try to find the path as indicated with InitializePath with the lowest cost.
function _CleanPath ()

Public Attributes

 _queue_class = "queue.binary_heap"
 _pf_instance = null
 _cost_callback = null
 _estimate_callback = null
 _neighbours_callback = null
 _check_direction_callback = null
 _open = null
 _closed = null
 _goals = null

Detailed Description

An AyStar implementation.

It solves graphs by finding the fastest route from one point to the other.

Constructor & Destructor Documentation

constructor AyStar::AyStar ( pf_instance  ,
cost_callback  ,
estimate_callback  ,
neighbours_callback  ,
check_direction_callback   
)
inline
Parameters
pf_instanceAn instance that'll be used as 'this' for all the callback functions.
cost_callbackA function that returns the cost of a path. It should accept four parameters, old_path, new_tile, new_direction and cost_callback_param. old_path is an instance of AyStar.Path, and new_node is the new node that is added to that path. It should return the cost of the path including new_node.
estimate_callbackA function that returns an estimate from a node to the goal node. It should accept four parameters, tile, direction, goal_nodes and estimate_callback_param. It should return an estimate to the cost from the lowest cost between node and any node out of goal_nodes. Note that this estimate is not allowed to be higher than the real cost between node and any of goal_nodes. A lower value is fine, however the closer it is to the real value, the better the performance.
neighbours_callbackA function that returns all neighbouring nodes from a given node. It should accept three parameters, current_path, node and neighbours_callback_param. It should return an array containing all neighbouring nodes, which are an array in the form [tile, direction].
check_direction_callbackA function that returns either false or true. It should accept four parameters, tile, existing_direction, new_direction and check_direction_callback_param. It should check if both directions can go together on a single tile.

Member Function Documentation

function AyStar::FindPath ( iterations  )

Try to find the path as indicated with InitializePath with the lowest cost.

Parameters
iterationsAfter how many iterations it should abort for a moment. This value should either be -1 for infinite, or > 0. Any other value aborts immediatly and will never find a path.
Returns
A route if one was found, or false if the amount of iterations was reached, or null if no path was found. You can call this function over and over as long as it returns false, which is an indication it is not yet done looking for a route.
function AyStar::InitializePath ( sources  ,
goals  ,
ignored_tiles  = [] 
)

Initialize a path search between sources and goals.

Parameters
sourcesThe source nodes. This can an array of either [tile, direction]-pairs or AyStar.Path-instances.
goalsThe target tiles. This can be an array of either tiles or [tile, next_tile]-pairs.
ignored_tilesAn array of tiles that cannot occur in the final path.

The documentation for this class was generated from the following files: