A* search algorithm: Difference between revisions

Content added Content deleted
mNo edit summary
Line 1,927: Line 1,927:
*/
*/
public void expandAStar(int[][] maze, int xstart, int ystart, boolean diag){
public void expandAStar(int[][] maze, int xstart, int ystart, boolean diag){
Queue<Mazecoord> exploreNodes = new LinkedList<mazecoord>();
Queue<Mazecoord> exploreNodes = new LinkedList<Mazecoord>();
if(maze[stateNode.getR()][stateNode.getC()] == 2){
if(maze[stateNode.getR()][stateNode.getC()] == 2){
if(isNodeILegal(stateNode, stateNode.expandDirection())){
if(isNodeILegal(stateNode, stateNode.expandDirection())){
Line 1,942: Line 1,942:
this.start.setPathCost(0);
this.start.setPathCost(0);
this.start.setAStartCost(this.start.getPathCost() + this.start.getCostToGoal());
this.start.setAStartCost(this.start.getPathCost() + this.start.getCostToGoal());
Coord intialNode = this.start;
Mazecoord intialNode = this.start;
Coord stateNode = intialNode;
Mazecoord stateNode = intialNode;
frontier.add(intialNode);
frontier.add(intialNode);
//explored<Queue> is empty
//explored<Queue> is empty