forked from bgrins/javascript-astar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
32 lines (23 loc) · 1.29 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
javascript-astar: An implementation of the A* Search Algorithm in JavaScript
See a demo at http://www.briangrinstead.com/files/astar/
astar.js: The newest version of the algorithm using a Binary Heap. It is quite faster than the original.
http://www.briangrinstead.com/blog/astar-search-algorithm-in-javascript-updated
Binary Heap taken from http://eloquentjavascript.net/appendix2.html (license: http://creativecommons.org/licenses/by/3.0/)
astar-list.js: The original version of the algorithm based off the original blog post at:
http://www.briangrinstead.com/blog/astar-search-algorithm-in-javascript
I left it in because it may be a little easier for some people to understand, but if you were to use
this in another application, I would strongly recommend using astar.js instead.
If you want just the A* search code (not the demo visualization), use code like this (http://gist.github.com/581352):
<script type='text/javascript' src='graph.js'></script>
<script type='text/javascript' src='astar.js'></script>
<script type='text/javascript'>
var graph = new Graph([
[0,0,0,0],
[1,0,0,1],
[1,1,0,0]
]);
var start = graph.nodes[0][0];
var end = graph.nodes[1][2];
var result = astar.search(graph.nodes, start, end);
// result is an array containing the shortest path
</script>