Inherited from System.ComponentModel.Component.
Assembly: CarlosB.Path (in CarlosB.PathFind.dll)
This class implements the A* path finding algorithm encapsulating it into a .Net component. You can use it to search for the best path between 2 points on a 2D map defining terrain costs for each map cell which goes from 0 to 255 (byte), a value of 255 (highest cost) identifies an untrespassable cell.
AStar Constructor | Initializes a new instance of the AStar class. |
CellCost |
Terrain cost of map cells with dimensions provided by Height and Width properties. This property is not used if the OnCell event is defined.
|
Directions |
List of possible move directions, by default the values Right, Down, Left, Up are defined. You may change it to add new directions or have the search done with a different direction order.
|
Height |
Height of search map.
|
HeuristicWeight |
Value used to estimate cost to goal, it's multiplied with Manhattan
distance of cells.
|
MaxSteps |
Maximum number of steps allowed for the resulting path.
|
Width |
Width of search map.
|
int FindPath(Point Origin, Point Dest, ref Point[] Steps, out int Cost) |
Searches the map for the shortest path between the points Origin and Dest. The resulting path is returned on Steps and the total cost of the path in Cost. If the MaxSteps property is smaller than the needed steps to get to Dest then a partial answer with MaxSteps movements is returned. The Steps parameter will be initialized if null. Returns -1 if no path could be found or the number of movements returned on Steps. |
OnCell(CellEventArgs e) |
Occurs when the cell is first visited to get the terrain cost of the cell. If you don't define this event all the map terrain cost will be fetched from the CellCost property. You should set the CellEventArgs.Result property with the terrain cost of the map cell located at CellEventArgs.Pos.
|
EstimateGoalCost(EstimateGoalCostEventArgs e) |
Occurs when needs to estimate cost from map cell EstimateGoalCostEventArgs.From to EstimateGoalCostEventArgs.To. The calculated value should be set on EstimateGoalCostEventArgs.Result. If this event is not defined the Manhattan distance between the 2 points multiplied by HeuristicWeight is used. |