MinchinWeb's MetaLibrary  v.9
Library functions of OpenTTD AI writers.
_MinchinWeb_WBC_ Class Reference

Waterbody Check (deprecated) More...

Classes

class  Cost
 

Public Member Functions

function InitializePath (sources, goals)
 
function FindPath (iterations)
 
function GetPathLength ()
 How long is the (found) path? More...
 
function PresetSafety (Start, End)
 Caps the pathfinder as twice the Manhattan distance between the two tiles. More...
 

Private Member Functions

 constructor ()
 
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)
 

Private Attributes

 _aystar_class = import("graph.aystar", "", 6)
 
 _cost_per_tile = null
 
 _max_cost = null
 The maximum cost for a route. More...
 
 _distance_penalty = null
 Penalty to use to speed up pathfinder, 1 is no penalty. More...
 
 _pathfinder = null
 
 cost = null
 Used to change the costs. More...
 
 _running = null
 Is it running? More...
 
 _mypath = null
 

Detailed Description

Waterbody Check (deprecated)

Version
v.1 (2012-01-05)
Author
W. Minchin (MinchinWeb)
Since
MetaLibrary v.1
Note
Waterbody Check has been deprecated in favour of _MinchinWeb_Lakes_ (Lakes).

Waterbody check is in effect a specialized pathfinder. It serves to check whether two points are in the same waterbody (i.e. a ship could travel between them). It is optimized to run extremely fast (I hope!). It can be called separately, but was originally designed as a pre-run check for my Ship Pathfinder (also included in this MetaLibrary).

It is based on the NoAI Team's Road Pathfinder v3.

Depends On:
Graph.AyStar v6 library
See also
_MinchinWeb_ShipPathfinder_
_MinchinWeb_Lakes_
Todo:
Add a cost for turns that then this would function as a 'real' pathfinder (maybe...)

Definition at line 60 of file Waterbody.Check.nut.

Member Function Documentation

function _MinchinWeb_WBC_::_CheckDirection ( self  ,
tile  ,
existing_direction  ,
new_direction   
)
private

Definition at line 221 of file Waterbody.Check.nut.

function _MinchinWeb_WBC_::_Cost ( self  ,
path  ,
new_tile  ,
new_direction   
)
private

Definition at line 173 of file Waterbody.Check.nut.

function _MinchinWeb_WBC_::_Estimate ( self  ,
cur_tile  ,
cur_direction  ,
goal_tiles   
)
private

Definition at line 190 of file Waterbody.Check.nut.

function _MinchinWeb_WBC_::_GetDirection ( from  ,
to   
)
private

Definition at line 225 of file Waterbody.Check.nut.

function _MinchinWeb_WBC_::_Neighbours ( self  ,
path  ,
cur_node   
)
private
Todo:
Add diagonals to possible neighbours

Definition at line 200 of file Waterbody.Check.nut.

_MinchinWeb_WBC_::constructor ( )
inlineprivate

Definition at line 70 of file Waterbody.Check.nut.

function _MinchinWeb_WBC_::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 immediately 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()

Definition at line 165 of file Waterbody.Check.nut.

function _MinchinWeb_WBC_::GetPathLength ( )

How long is the (found) path?

Returns
Path length in tiles

Definition at line 233 of file Waterbody.Check.nut.

function _MinchinWeb_WBC_::InitializePath ( sources  ,
goals   
)
inline

Initialize a path search between sources and goals.

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

Definition at line 86 of file Waterbody.Check.nut.

function _MinchinWeb_WBC_::PresetSafety ( Start  ,
End   
)

Caps the pathfinder as twice the Manhattan distance between the two tiles.

Definition at line 248 of file Waterbody.Check.nut.

Member Data Documentation

_MinchinWeb_WBC_::_aystar_class = import("graph.aystar", "", 6)
private

Definition at line 61 of file Waterbody.Check.nut.

_MinchinWeb_WBC_::_cost_per_tile = null
private

Definition at line 62 of file Waterbody.Check.nut.

_MinchinWeb_WBC_::_distance_penalty = null
private

Penalty to use to speed up pathfinder, 1 is no penalty.

Definition at line 64 of file Waterbody.Check.nut.

_MinchinWeb_WBC_::_max_cost = null
private

The maximum cost for a route.

Definition at line 63 of file Waterbody.Check.nut.

_MinchinWeb_WBC_::_mypath = null
private

Definition at line 68 of file Waterbody.Check.nut.

_MinchinWeb_WBC_::_pathfinder = null
private

Definition at line 65 of file Waterbody.Check.nut.

_MinchinWeb_WBC_::_running = null
private

Is it running?

Definition at line 67 of file Waterbody.Check.nut.

_MinchinWeb_WBC_::cost = null
private

Used to change the costs.

Definition at line 66 of file Waterbody.Check.nut.


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