Package horizons :: Package util :: Package pathfinding :: Module pathfinding :: Class FindPath
[hide private]
[frames] | no frames]

Class FindPath

source code

Finds best path from source to destination via a*-algo "best path" means path with shortest travel time, which is not necessarily the shortest path (cause roads have different speeds)

Instance Methods [hide private]
 
__call__(self, source, destination, path_nodes, blocked_coords=None, diagonal=False, make_target_walkable=True)
@param source: Rect, Point or BasicBuilding @param destination: Rect, Point or BasicBuilding @param path_nodes: dict { (x, y) = speed_on_coords } or list [(x, y), ..] @param blocked_coords: temporarily blocked coords (e.g.
source code
 
setup(self)
Sets up variables for execution of algorithm
source code
 
execute(self)
Executes algorithm
source code
Class Variables [hide private]
  log = logging.getLogger("world.pathfinding")
Method Details [hide private]

__call__(self, source, destination, path_nodes, blocked_coords=None, diagonal=False, make_target_walkable=True)
(Call operator)

source code 

@param source: Rect, Point or BasicBuilding
@param destination: Rect, Point or BasicBuilding
@param path_nodes: dict { (x, y) = speed_on_coords }  or list [(x, y), ..]
@param blocked_coords: temporarily blocked coords (e.g. by a unit) as list or dict of tuples
@param diagonal: whether the unit is able to move diagonally
@param make_target_walkable: whether we force the tiles of the target to be walkable,
       even if they actually aren't (used e.g. when walking to a building)
@return: list of coords as tuples that are part of the best path
         (from first coord after source to first coord in destination)
                                 or None if no path is found

setup(self)

source code 

Sets up variables for execution of algorithm

Returns:
bool, whether setup was successful