AStar-Process

This is a Algorithm calculation process Demo of A* (A Star)

Its purpose is to help you understand the A* algorithm quickly and efficiently.

Demo: https://anseyuyin.github.io/AStar-Process/demo

image

Features

Usage

if you want use this code

The origin of this coordinate system is in the upper left corner, and the max point is in the lower right corner

aStar.js file path is /aStar/js/aStar.js

frist load

<script src="aStar.js"></script>

do findPath

var astar = new findPath.aStar(); //new aStar object
var outPath = []; //resulte container Array
astar.findPath(1,1,1,8,outPath);//Calculation get path

map limit Filter

//a temp map
var map = [[1,1,1,1,1,1],
           [1,0,0,0,0,1],
           [1,0,0,0,0,1],
           [1,0,0,0,0,1],
           [1,0,0,0,0,1],
           [1,1,1,1,1,1],]
//set outFilter Filter Function      
astar.outFilter = (x,y)=>{
  return map[y][x] == 0;
}
var outPath = []; //resulte container Array
astar.findPath(1,1,1,8,outPath);//Calculation get path