Exemple #1
0
 @Override
 public int compareTo(Node_2 n) {
   if (this.getValue() > n.getValue()) {
     return 1;
   } else if (this.getValue() < n.getValue()) {
     return -1;
   } else if (this.getDepth() < n.getDepth()) {
     return 1;
   } else if (this.getDepth() > n.getDepth()) {
     return -1;
   } else {
     return 0;
   }
 }
Exemple #2
0
  // 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;
    }
  }