Road  4
 All Classes Functions Variables
Classes | Public Member Functions | Public Attributes | List of all members
Road Class Reference

A Road Pathfinder. More...

Classes

class  Cost

Public Member Functions

function GetAuthor ()
function GetName ()
function GetShortName ()
function GetDescription ()
function GetVersion ()
function GetDate ()
function CreateInstance ()
function GetCategory ()
function InitializePath (sources, goals)
 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 _GetBridgeNumSlopes (end_a, end_b)
function _Cost (self, path, new_tile, new_direction)
function _Estimate (self, cur_tile, cur_direction, goal_tiles)
function _Neighbours (self, path, cur_node)
function _CheckDirection (self, tile, existing_direction, new_direction)
function _GetDirection (from, to, is_bridge)
function _GetTunnelsBridges (last_node, cur_node, bridge_dir)
 Get a list of all bridges and tunnels that can be build from the current tile.
function _IsSlopedRoad (start, middle, end)
function _CheckTunnelBridge (current_tile, new_tile)

Public Attributes

 _aystar_class = "graph.aystar"
 _max_cost = null
 The maximum cost for a route.
 _cost_tile = null
 The cost for a single tile.
 _cost_no_existing_road = null
 The cost that is added to _cost_tile if no road exists yet.
 _cost_turn = null
 The cost that is added to _cost_tile if the direction changes.
 _cost_slope = null
 The extra cost if a road tile is sloped.
 _cost_bridge_per_tile = null
 The cost per tile of a new bridge, this is added to _cost_tile.
 _cost_tunnel_per_tile = null
 The cost per tile of a new tunnel, this is added to _cost_tile.
 _cost_coast = null
 The extra cost for a coast tile.
 _pathfinder = null
 A reference to the used AyStar object.
 _max_bridge_length = null
 The maximum length of a bridge that will be build.
 _max_tunnel_length = null
 The maximum length of a tunnel that will be build.
 cost = null
 Used to change the costs.
 _running = null

Detailed Description

A Road Pathfinder.

This road pathfinder tries to find a buildable / existing route for road vehicles. You can changes the costs below using for example roadpf.cost.turn = 30. Note that it's not allowed to change the cost between consecutive calls to FindPath. You can change the cost before the first call to FindPath and after FindPath has returned an actual route. To use only existing roads, set cost.no_existing_road to cost.max_cost.

Member Function Documentation

function Road::_GetTunnelsBridges ( last_node  ,
cur_node  ,
bridge_dir   
)

Get a list of all bridges and tunnels that can be build from the current tile.

Bridges will only be build starting on non-flat tiles for performance reasons. Tunnels will only be build if no terraforming is needed on both ends.

function Road::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.
See Also
AyStar::FindPath()
function Road::InitializePath ( sources  ,
goals   
)
inline

Initialize a path search between sources and goals.

Parameters
sourcesThe source tiles.
goalsThe target tiles.
See Also
AyStar::InitializePath()

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