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

Dominion Land System (Road Pathfinder) More...

Classes

class  Info
 

Public Member Functions

function SetDatum (NewDatum)
 Sets network Datum. More...
 
function GetDatum ()
 Returns the currently set Datum. More...
 
function IsGridPoint (Point)
 Is the tile given a grid point. More...
 
function GridPoints (End1, End2)
 Get all the grid points between two tiles. More...
 
function AllGridPoints ()
 Get all grid points. More...
 
function FindPath (cycles=10000)
 Run the pathfinder. More...
 
function InitializePath (StartArray, EndArray)
 Initializes the pathfinder. More...
 
function BuildPath ()
 Build the path. More...
 
function InitializePathOnTowns (StartTown, EndTown)
 Initializes the pathfinder using two towns. More...
 
function GetPath ()
 Returns the path stored by the pathfinder. More...
 
function GetPathLength ()
 Returns the length of the path stored by the pathfinder. More...
 
function PathToTilePairs ()
 Convert the path to tile pairs. More...
 
function PathToTiles ()
 Get all the tiles in the path. More...
 
function TilePairsToBuild ()
 Get the road tile pairs that need built. More...
 
function GetBuildCost ()
 Determine how much it will cost to build the path. More...
 
function PresetOriginal ()
 
function PresetPerfectPath ()
 
function PresetQuickAndDirty ()
 
function PresetCheckExisting ()
 
function PresetPresetMode6 ()
 
function PresetPresetStreetcar ()
 

Private Member Functions

 constructor ()
 

Private Attributes

 _gridx = null
 Grid spacing in x direction (default is 8 tiles) More...
 
 _gridy = null
 Grid spacing in y direction (default is 8 tiles) More...
 
 _datum = null
 This is the 'centre' of our survey system. More...
 
 _basedatum = null
 this is the 'grid point' closest to 0,0 More...
 
 _pathfinder = null
 the pathfinder itself More...
 
 _starttile = null
 starting tile More...
 
 _endtile = null
 ending tile More...
 
 _path = null
 used to store that path as a array of tile pairs More...
 
 _running = null
 Is the pathfinder currently running? More...
 
 _road_type = null
 See http://noai.openttd.org/api/trunk/classAIRoad.html More...
 

Detailed Description

Dominion Land System (Road Pathfinder)

Version
v.1 (2013-01-01)
Author
W. Minchin (MinchinWeb)
Since
MetaLibrary v.6

Dominion Land System refers to the system of survey in Western Canada. Land was surveyed into 1/2 mile x 1/2 mile "quarter sections" that would be sold to settlers (around 1905, the price was $10). Roads were placed on a 1 mile x 2 mile grid along the edges of these quarter sections.

Here, we follow the same idea, although on a square grid. The default grid is 8x8 tiles. This is designed to run as a wrapper on the main road pathfinder.

Depends On:
Pathfinder.Road.nut
See also
_MinchinWeb_RoadPathfinder_

Definition at line 63 of file Dominion.Roads.nut.

Member Function Documentation

function _MinchinWeb_DLS_::AllGridPoints ( )

Get all grid points.

Returns
An array of all the 'grid points' on the map

Definition at line 330 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::BuildPath ( )

Build the path.

Note
requires that the path has already been found.
See also
FindPath()

Definition at line 399 of file Dominion.Roads.nut.

_MinchinWeb_DLS_::constructor ( )
inlineprivate

Definition at line 75 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::FindPath ( cycles  = 10000)

Run the pathfinder.

Parameters
cyclesnumber of iterations to run before returning.
Returns
True when the path is found
See also
BuildPath()
GetPath()
Note
The path must be initialized before it can be run.
See also
InitializePath()
InitializePathOnTowns()
Todo:
stop ignoring the passed parameter of cycles

Definition at line 335 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::GetBuildCost ( )

Determine how much it will cost to build the path.

Turns to 'test mode,' builds the route provided, and returns the cost.

Returns
The build cost, in British Pounds.
False if the test build fails somewhere.
Note
Note that due to inflation, this value can get stale.

Definition at line 558 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::GetDatum ( )
inline

Returns the currently set Datum.

Returns
The current Datum (as a TileIndex)
Note
In surveying, a 'datum' is where all other points are measured from.

Definition at line 99 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::GetPath ( )

Returns the path stored by the pathfinder.

Definition at line 482 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::GetPathLength ( )

Returns the length of the path stored by the pathfinder.

Returns
The lenght of the path in tiles.

Definition at line 492 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::GridPoints ( End1  ,
End2   
)

Get all the grid points between two tiles.

Parameters
End1expected to be a TileIndex
End2expected to be a TileIndex
Returns
An array of TileIndexs that are 'grid points' or where roads will have intersections.
Note
End1 and End2 will NOT be included in the return array.

Definition at line 272 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::InitializePath ( StartArray  ,
EndArray   
)

Initializes the pathfinder.

Parameters
StartArraythe first item assumed be a TileIndex, the of the items in the array are ignored.
EndArraythe first item assumed be a TileIndex, the of the items in the array are ignored.

Definition at line 391 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::InitializePathOnTowns ( StartTown  ,
EndTown   
)

Initializes the pathfinder using two towns.

Parameters
StartTownAssumed to be a TownID
EndTownAssumed to be a TownID
Note
This assumes that the town centres are road tiles (if this is not the case, the pathfinder will still run, but it will take a long time and eventually fail to return a path). This is not typically an issue because on map generation, the centre of each town is a road tile.

Definition at line 473 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::IsGridPoint ( Point  )

Is the tile given a grid point.

Returns
True if and only if Point is a gird point; False otherwise.

Definition at line 263 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::PathToTilePairs ( )

Convert the path to tile pairs.

Returns
A 2D array that has each pair of tiles that the path joins.
See also
TileParisToBuild()

Definition at line 512 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::PathToTiles ( )
inline

Get all the tiles in the path.

Returns
A 1D array of the tiles in the path

Definition at line 176 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::PresetCheckExisting ( )
inline

Pass-thru functions to RoadPathfinder

See also
_MinchinWeb_RoadPathfinder_.PresetCheckExisting()

Definition at line 221 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::PresetOriginal ( )
inline

Pass-thru functions to RoadPathfinder

See also
_MinchinWeb_RoadPathfinder_.PresetOriginal()

Definition at line 200 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::PresetPerfectPath ( )
inline

Pass-thru functions to RoadPathfinder

See also
_MinchinWeb_RoadPathfinder_.PresetPerfectPath()

Definition at line 207 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::PresetPresetMode6 ( )
inline

Pass-thru functions to RoadPathfinder

See also
_MinchinWeb_RoadPathfinder_.PresetMode6()

Definition at line 228 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::PresetPresetStreetcar ( )
inline

Pass-thru functions to RoadPathfinder

See also
_MinchinWeb_RoadPathfinder_.PresetStreetcar()

Definition at line 235 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::PresetQuickAndDirty ( )
inline

Pass-thru functions to RoadPathfinder

See also
_MinchinWeb_RoadPathfinder_.PresetQuickAndDirty()

Definition at line 214 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::SetDatum ( NewDatum  )

Sets network Datum.

Used to set the datum for our road system.

Note
In surveying, a 'datum' is where all other points are measured from.
Parameters
NewDatumassumed to be a TileIndex
Todo:
Add error check

Definition at line 255 of file Dominion.Roads.nut.

function _MinchinWeb_DLS_::TilePairsToBuild ( )

Get the road tile pairs that need built.

Similar to PathToTilePairs(), but only returns those pairs where there isn't a current road connection.

See also
PathToTilePairs()
Returns
A 2D array that has each pair of tiles that the path joins that are not current joined by road.

Definition at line 534 of file Dominion.Roads.nut.

Member Data Documentation

_MinchinWeb_DLS_::_basedatum = null
private

this is the 'grid point' closest to 0,0

Definition at line 67 of file Dominion.Roads.nut.

_MinchinWeb_DLS_::_datum = null
private

This is the 'centre' of our survey system.

Definition at line 66 of file Dominion.Roads.nut.

_MinchinWeb_DLS_::_endtile = null
private

ending tile

Definition at line 70 of file Dominion.Roads.nut.

_MinchinWeb_DLS_::_gridx = null
private

Grid spacing in x direction (default is 8 tiles)

Definition at line 64 of file Dominion.Roads.nut.

_MinchinWeb_DLS_::_gridy = null
private

Grid spacing in y direction (default is 8 tiles)

Definition at line 65 of file Dominion.Roads.nut.

_MinchinWeb_DLS_::_path = null
private

used to store that path as a array of tile pairs

Definition at line 71 of file Dominion.Roads.nut.

_MinchinWeb_DLS_::_pathfinder = null
private

the pathfinder itself

Definition at line 68 of file Dominion.Roads.nut.

_MinchinWeb_DLS_::_road_type = null
private
_MinchinWeb_DLS_::_running = null
private

Is the pathfinder currently running?

Definition at line 72 of file Dominion.Roads.nut.

_MinchinWeb_DLS_::_starttile = null
private

starting tile

Definition at line 69 of file Dominion.Roads.nut.


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