Pathfinder::AStarTile8DirCached< MOVECOST, DESTCOST, MOVEBLOCKED, COSTTYPE > Class Template Reference

A * path finder for 2d movement in 8 directions with caching. More...

#include <pathfinderastartile8dircached.h>

List of all members.

Public Member Functions

const PathResult FindPath (const std::pair< long, long > &start, const std::pair< long, long > &goal, std::vector< std::pair< long, long > > &finalpath, MOVECOST &movecost, DESTCOST &destinationcost)
 Finds a path from one x,y position to another.
const PathResult FindPath (const std::pair< long, long > &start, const std::pair< long, long > &goal, std::vector< std::pair< long, long > > &finalpath, MOVECOST &movecost, MOVEBLOCKED &moveblocked, DESTCOST &destinationcost)
 Finds a path from one x,y position to another.
void SetMapWidth (const long width)
 Sets the map width.
void ClearCache ()
 Clears the entire cache.
void ClearCachePosition (const std::pair< long, long > &pos)
 Clears one cache element.


Detailed Description

template<class MOVECOST, class DESTCOST, class MOVEBLOCKED, class COSTTYPE = double>
class Pathfinder::AStarTile8DirCached< MOVECOST, DESTCOST, MOVEBLOCKED, COSTTYPE >

A * path finder for 2d movement in 8 directions with caching.

This is an A * path finder for tile based games where movement is possible in 8 directions surrounding each tile. The movement costs from state to state are cached to maximize performance. If state change costs can change frequently, you should use the non-cached version of this class.

Template Parameters:
MOVECOST A functor implementing IMoveCost
DESTCOST A functor implementing IDestinationCost
MOVEBLOCKED A functor implementing IMoveBlocked
COSTTYPE The cost type of moving from state to state, typically a float or double

Member Function Documentation

template<class MOVECOST , class DESTCOST , class MOVEBLOCKED , class COSTTYPE >
void Pathfinder::AStarTile8DirCached< MOVECOST, DESTCOST, MOVEBLOCKED, COSTTYPE >::ClearCachePosition ( const std::pair< long, long > &  pos  )  [inline]

Clears one cache element.

Call this method when the cost of reaching a state has changed.

Parameters:
pos The position of the cache to clear

template<class MOVECOST , class DESTCOST , class MOVEBLOCKED , class COSTTYPE >
const PathResult Pathfinder::AStarTile8DirCached< MOVECOST, DESTCOST, MOVEBLOCKED, COSTTYPE >::FindPath ( const std::pair< long, long > &  start,
const std::pair< long, long > &  goal,
std::vector< std::pair< long, long > > &  finalpath,
MOVECOST &  movecost,
MOVEBLOCKED &  moveblocked,
DESTCOST &  destinationcost 
) [inline]

Finds a path from one x,y position to another.

This method finds a path from one state to another and takes into consideration that any of the surrounding tiles may not be reachable. This method will block until a path from the start to the goal is found or all reachable nodes have been checked without finding a path.

Parameters:
start The starting x,y position
goal The goal x,y position
[out] finalpath A vector of x,y positions from the starting position to the goal position
movecost A functor implementing IMoveCost
moveblocked A functor implementing IMoveBlocked
destinationcost A functor implementing IDestinationCost
Returns:
PATH_FOUND or PATH_NOTFOUND

template<class MOVECOST , class DESTCOST , class MOVEBLOCKED , class COSTTYPE >
const PathResult Pathfinder::AStarTile8DirCached< MOVECOST, DESTCOST, MOVEBLOCKED, COSTTYPE >::FindPath ( const std::pair< long, long > &  start,
const std::pair< long, long > &  goal,
std::vector< std::pair< long, long > > &  finalpath,
MOVECOST &  movecost,
DESTCOST &  destinationcost 
) [inline]

Finds a path from one x,y position to another.

This method finds a path from one state to another and assumes that all 8 surrounding tiles are always reachable. This method will block until a path from the start to the goal is found or all reachable nodes have been checked without finding a path.

Parameters:
start The starting x,y position
goal The goal x,y position
[out] finalpath A vector of x,y positions from the starting position to the goal position
movecost A functor implementing IMoveCost
destinationcost A functor implementing IDestinationCost
Returns:
PATH_FOUND or PATH_NOTFOUND

template<class MOVECOST , class DESTCOST , class MOVEBLOCKED , class COSTTYPE >
void Pathfinder::AStarTile8DirCached< MOVECOST, DESTCOST, MOVEBLOCKED, COSTTYPE >::SetMapWidth ( const long  width  )  [inline]

Sets the map width.

You must call this method with the width of the map before performing any path finding

Parameters:
width The width of the map


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

Generated on Mon Dec 29 19:08:11 2008 by  doxygen 1.5.7.1