ai-22 / src / am / aua / search / Node.java
Node.java
Raw
package am.aua.search;

public class Node {
	public final Node parent;
	public final Action action;
	public final State state;
	public final int depth;
	public int value;
	public int pathCost;

	public Node(Node parent, Action action, State state) {
		this(parent, action, state,-1);
	}

	public Node(Node parent, Action action, State state, int depth) {
		this.parent = parent;
		this.action = action;
		this.state = state;
		this.depth = depth;

		int cost = 0;
		if (parent != null && action != null) {
			cost += parent.pathCost;
			cost += action.c(parent, this);
		}
		this.pathCost = cost;
	}
}