iigs-sprite-compiler/SpriteCompiler/AI/CostNodeLimiter.cs
2016-12-08 21:59:21 -06:00

25 lines
676 B
C#

namespace SpriteCompiler.AI
{
/// <summary>
/// Class that taken a search node and detemines whether or not to terminate the
/// search at the node. This is different than a goal test and is used in the
/// contect of depth-limited searches.
/// </summary>
public class CostNodeLimiter<T, C> : INodeLimiter<T, C>
where T : ISearchNode<C>
where C : IPathCost<C>, new()
{
private readonly C maxCost;
public CostNodeLimiter(C maxCost)
{
this.maxCost = maxCost;
}
public bool Cutoff(T node)
{
return node.PathCost.CompareTo(maxCost) >= 0;
}
}
}