Last active
December 18, 2024 14:23
-
-
Save bgrins/581352 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type='text/javascript' src='astar.js'></script> | |
<script type='text/javascript'> | |
var graph = new Graph([ | |
[1,1,1,1], | |
[0,1,1,0], | |
[0,0,1,1] | |
]); | |
var start = graph.grid[0][0]; | |
var end = graph.grid[1][2]; | |
var result = astar.search(graph, start, end); | |
// result is an array containing the shortest path | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
why would you need an A* for a 1D array? To find shortest path from X to Y, just do array.join``.match(/X.*?Y/)