/** Custom Heuristic Function */ private static int estimatedManhattan(MazeCell currentCell, int goalX, int goalY) { // Obtain the current path String currentPath = currentCell.getPath(); // Get the Current Path Cost int currentPathCost = pathCost(currentPath.toCharArray()); int currNodesExpanded = nodesExpanded; int length = currentPath.length(); if (length == 0) { length += 1; } // Cost per move // int averagePathCost = currentPathCost/length; int averageNodesExpanded = currNodesExpanded / length; // Get the number of moves left int distanceLeft = manhattan(goalX, goalY, currentCell.getX(), currentCell.getY()); return averageNodesExpanded * distanceLeft; }