public static void reRunHeuristic(ArrayList<Node_2> set) { System.out.println("Degree is now: " + degree); ArrayList<Node_2> newSet = new ArrayList<Node_2>(); for (Node_2 n : set) { // if(n.getValue() > 9999){ n.value = n.heuristic(); n.updateSelfDegree(); newSet.add(n); // } else if (n.getValue() <= degree){ // newSet.add(n); // } } set = newSet; System.out.println(); }
public static void addPathCost(Node_2 n, int playerNum, int[][] map1, int[][] map2) { int x; int y; int exitX; int exitY; int[][] map; if (playerNum == 1) { x = n.getX1(); y = n.getY1(); exitX = p1ExitX; exitY = p1ExitY; map = map1; } else { x = n.getX2(); y = n.getY2(); exitX = p2ExitX; exitY = p2ExitY; map = map2; } int toAdd = 0; while (x != exitX && y != exitY) { if (x != exitX) { if (exitX > x) { ++x; } else { --x; } } if (y != exitY) { if (exitY > y) { ++y; } else { --y; } } if (map[y][x] != 0) { ++toAdd; } } n.value += toAdd; if (playerNum == 1) { addPathCost(n, playerNum + 1, map1, map2); } }
public static void addDiff(ArrayList<Node_2> set) { reRunHeuristic(set); for (Node_2 n : set) { n.value += n.calcDiff(); } }