using System;
using System.Collections.Generic;
namespace SpriteCompiler.AI
{
public abstract class InformedNodeExpander : INodeExpander
where T : HeuristicSearchNode
where C : IPathCost
{
public abstract T CreateNode(T parent, S state);
public IEnumerable Expand(ISearchProblem problem, T node)
{
foreach (var successor in problem.Successors(node.State))
{
var action = successor.Key;
var state = successor.Value;
var next = CreateNode(node, state);
next.Action = action;
next.StepCost = problem.StepCost(node.State, action, state);
next.Heuristic = problem.Heuristic(state);
yield return next;
}
}
}
}