// Constructor, for the first node, have parent = null; public Node_2(int p1X, int p1Y, int p2X, int p2Y, Node_2 expanded, int action) { x1 = p1X; y1 = p1Y; x2 = p2X; y2 = p2Y; p1HasReached = false; p2HasReached = false; parent = expanded; if (x1 == 148 && y1 == 150 && x2 == 155 && y2 == 149) { x1 += 0; } updateSelfDegree(); if (parent == null) { depth = 0; actionPath = new ArrayList<Integer>(); value = -1; } else { depth = parent.getDepth() + 1; actionPath = ((ArrayList<Integer>) parent.getActionPath().clone()); actionPath.add(action); // Set the value of this node equal to our heuristic rating for it value = this.heuristic_2(); } if (parent != null && parent.x1 == p1ExitX && parent.y1 == p1ExitY && parent.selfDegree == 0) { x1 += 0; } if (x1 == p1ExitX && y1 == p1ExitY && selfDegree == 0) { x1 += 0; } }
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(); }