package CK.IA;

public class AStarNode implements Comparable<AStarNode> {
	public int debuglevel = 0;
	public float estimated_distance_goal;
	public float heuristic;
	public int index;
	public float travelled_distance_start;

	public AStarNode(int index, float travelled_distance_start, float estimated_distance_goal) {
		this.travelled_distance_start = travelled_distance_start;
		this.estimated_distance_goal = estimated_distance_goal;
		this.heuristic = travelled_distance_start + estimated_distance_goal;
		this.index = index;
	}

	public int compareTo(AStarNode o) {
		if (o.heuristic > this.heuristic)
			return -1;
		else if (o.heuristic < this.heuristic) {
			return +1;
		} else
			return 0;
	}

	public boolean equals(AStarNode node) {
		return node.index == this.index;
	}

	public float getEstimatedDistanceToGoal() {
		return estimated_distance_goal;
	}

	public float getHeuristic() {
		return heuristic;
	}

	public int getIndex() {
		return index;
	};

	public float getTravelledDistanceFromStart() {
		return travelled_distance_start;
	}

	public int hashCode() {
		return this.getIndex();
	}

	public String toString() {
		if (debuglevel == 0)
			return "(" + "heuristic=" + this.heuristic + ",index=" + this.index + ",estimated_distance_goal=" + this.estimated_distance_goal
					+ ",travelled_distance_start=" + this.travelled_distance_start + ")";
		else if (debuglevel == 1)
			return "(" + "heuristic=" + this.heuristic + ")";
		else if (debuglevel == 2)
			return "(" + "heuristic=" + this.heuristic + ",index=" + this.index + ")";
		else
			return "";
	}
}
