Esempio n. 1
0
	/// <summary>
	/// Return nodes after expanding
	/// </summary>
	/// <param name="prob">Problem that generates successors</param>
	public List<Node> Expand(Problem prob)
	{
		List<Node> childNodes = new List<Node> ();
		//Get successors for this state
		State origin = this.State;
		List<KeyValuePair<Vector2,State>> successors = prob.Successor (origin);
		//Create a node with each posibility
		foreach (var successor in successors) {
			Vector2 action = successor.Key;
			State destination = successor.Value;
			int cost = prob.PathCost(this.State,successor.Key,successor.Value);
			int heurtree = prob.HeurTree(destination);
			int heurgraph = prob.HeurGraph(destination);
			double utility = prob.Utility(destination);
			//Node parent = this;

			childNodes.Add(new Node(destination,this,action,cost,heurtree,heurgraph,utility));
		}

		return childNodes;
	}