Packagebe.dauntless.astar.basic2d
Classpublic class Map
InheritanceMap Inheritance Object
Implements IMap

A simple Map implementation for the IMap interface



Public Properties
 PropertyDefined By
  heuristic : String
Returns the heuristic that is currently being used
Map
Public Methods
 MethodDefined By
  
Map(width:int, length:int, defaultCost:int = 1)
Creates a new Map object with the specified width en height
Map
  
getDistance(fromTile:IAstarTile, toTile:IAstarTile):Number
Returns the distance between two tiles.
Map
  
Returns the heuristic for the given start tile to the end.
Map
  
Returns a list with the neighbours of the given tile.
Map
  
getTileAt(position:Point):IPositionTile
Returns the IPositionTile at the given location
Map
  
isDiagonal(from:IAstarTile, to:IAstarTile):Boolean
Checks if the given points are diagonal to eachother.
Map
  
Sets the given tile at the given location
Map
Public Constants
 ConstantDefined By
  DIAGONAL_HEURISTIC : String = diagonalHeuristic
[static] Diagonal heuristic.
Map
  MANHATTAN_HEURISTIC : String = manhattanHeuristic
[static] Horizontal heuristic.
Map
  NO_HEURISTIC : String = noHeuristic
[static] No heuristic.
Map
Property Detail
heuristicproperty
heuristic:String

Returns the heuristic that is currently being used


Implementation
    public function get heuristic():String
    public function set heuristic(value:String):void
Constructor Detail
Map()Constructor
public function Map(width:int, length:int, defaultCost:int = 1)

Creates a new Map object with the specified width en height

Parameters
width:int — The width of the map
 
length:int — The height of the map
 
defaultCost:int (default = 1)
Method Detail
getDistance()method
public function getDistance(fromTile:IAstarTile, toTile:IAstarTile):Number

Returns the distance between two tiles. This distance is multiplied with the cost of the target tile to get its final G cost.

Parameters

fromTile:IAstarTile
 
toTile:IAstarTile

Returns
Number
getHeuristic()method 
public function getHeuristic(tile:IAstarTile, req:PathRequest):Number

Returns the heuristic for the given start tile to the end.

Parameters

tile:IAstarTile
 
req:PathRequest

Returns
Number
getNeighbours()method 
public function getNeighbours(tile:IAstarTile):Vector.<IAstarTile>

Returns a list with the neighbours of the given tile.

Parameters

tile:IAstarTile — The position of the tile to get the neighbours of

Returns
Vector.<IAstarTile> — A Vector containing all the neighbouring tiles
getTileAt()method 
public function getTileAt(position:Point):IPositionTile

Returns the IPositionTile at the given location

Parameters

position:Point — The point specifing the location for the tile

Returns
IPositionTile — IPositionTile at the given location
isDiagonal()method 
public function isDiagonal(from:IAstarTile, to:IAstarTile):Boolean

Checks if the given points are diagonal to eachother.

Parameters

from:IAstarTile — The first point
 
to:IAstarTile — The second point

Returns
Boolean — A boolean indicating if the given tiles are diagonal to eachother
setTile()method 
public function setTile(tile:IPositionTile):void

Sets the given tile at the given location

Parameters

tile:IPositionTile — The tile to place in the map

Constant Detail
DIAGONAL_HEURISTICConstant
public static const DIAGONAL_HEURISTIC:String = diagonalHeuristic

Diagonal heuristic. The following formula is used: H = Math.max(Math.abs(end.x - start.x), Math.abs(end.y - start.y));

MANHATTAN_HEURISTICConstant 
public static const MANHATTAN_HEURISTIC:String = manhattanHeuristic

Horizontal heuristic. This is the manhattan heuristic. The following formula is used: H = (end.x - start.x) + (end.y - start.y)

NO_HEURISTICConstant 
public static const NO_HEURISTIC:String = noHeuristic

No heuristic. When no heuristic is used, Awill behave like a breadth-first search algorithm