import java.lang.Comparable; import java.lang.Float; import java.util.Vector; public class Node implements Comparable { public Point location; public boolean walkable; // A* things public Node parent = null; public float f = 0.0f; public float g = 0.0f; public float h = 0.0f; public Vector neighbours = new Vector(); public Node(Point location, boolean walkable) { this.location = location; this.walkable = walkable; } public void reset() { parent = null; f = g = h = 0.0f; } public int compareTo(Object o) { Node n = (Node)o; return new Float(f).compareTo(new Float(n.f)); } public void setF(Node finish) { setG(); setH(finish); f = g + h; } public void setG() { g = parent.g + location.dist(parent.location); } // using crow-flies distances to estimate costs // manhattan is cheaper, but overestimating is bad? public void setH(Node finish) { h = location.dist(finish.location); //h = location.manhattan(finish.location); } }