Class AStar
AStar path finding algorithm implementation by Benjamin Hardin.
Defined in: a_star.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
AStar(initial_board)
Finds a path between two different squares on a two dimensional board of squares with some squares marked as impassable.
|
| Method Attributes | Method Name and Description |
|---|---|
|
find_path(start, destination)
Finds a short path between two points on a 2 dimensional board.
|
|
|
heuristic(current_node, destination_node)
Function that defines the heuristic for closeness of two nodes.
|
|
|
update_board(new_board)
Update the board to a new configuration.
|
Class Detail
AStar(initial_board)
Finds a path between two different squares on a two dimensional board of squares with some squares marked as impassable. Original MIT licensed source code from http://46dogs.blogspot.com/2009/10/star-pathroute-finding-javascript-code.html
- Parameters:
- initial_board
- is a two dimensional array of 1/0 values for passable/non-passable squares.
Method Detail
find_path(start, destination)
Finds a short path between two points on a 2 dimensional board.
- Parameters:
- start
- is a two-value array of x, y position e.g. [5, 4]
- destination
- is a two-value array of x, y position e.g. [5, 4]
heuristic(current_node, destination_node)
Function that defines the heuristic for closeness of two nodes. Override this to define your own heuristic for distance between two nodes. An A* heurisitic must be admissible, meaning it must never overestimate the distance to the goal. In other words, it must either underestimate or return exactly the distance to the goal.
- Parameters:
- current_node
- is the source node we are measuring a path from in the current iteration.
- destination_node
- is the endpoint of the current path being tested.
update_board(new_board)
Update the board to a new configuration.
- Parameters:
- new_board
- is the new board data - a two dimensional array.
